Merge tag 'memblock-v5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt...
[linux-2.6-microblaze.git] / block / bounce.c
index 94081e0..05fc714 100644 (file)
@@ -67,18 +67,6 @@ static __init int init_emergency_pool(void)
 
 __initcall(init_emergency_pool);
 
-/*
- * highmem version, map in to vec
- */
-static void bounce_copy_vec(struct bio_vec *to, unsigned char *vfrom)
-{
-       unsigned char *vto;
-
-       vto = kmap_atomic(to->bv_page);
-       memcpy(vto + to->bv_offset, vfrom, to->bv_len);
-       kunmap_atomic(vto);
-}
-
 /*
  * Simple bounce buffer support for highmem pages. Depending on the
  * queue gfp mask set, *to may or may not be a highmem page. kmap it
@@ -86,7 +74,6 @@ static void bounce_copy_vec(struct bio_vec *to, unsigned char *vfrom)
  */
 static void copy_to_high_bio_irq(struct bio *to, struct bio *from)
 {
-       unsigned char *vfrom;
        struct bio_vec tovec, fromvec;
        struct bvec_iter iter;
        /*
@@ -104,11 +91,8 @@ static void copy_to_high_bio_irq(struct bio *to, struct bio *from)
                         * been modified by the block layer, so use the original
                         * copy, bounce_copy_vec already uses tovec->bv_len
                         */
-                       vfrom = page_address(fromvec.bv_page) +
-                               tovec.bv_offset;
-
-                       bounce_copy_vec(&tovec, vfrom);
-                       flush_dcache_page(tovec.bv_page);
+                       memcpy_to_bvec(&tovec, page_address(fromvec.bv_page) +
+                                      tovec.bv_offset);
                }
                bio_advance_iter(from, &from_iter, tovec.bv_len);
        }
@@ -255,24 +239,19 @@ void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
         * because the 'bio' is single-page bvec.
         */
        for (i = 0, to = bio->bi_io_vec; i < bio->bi_vcnt; to++, i++) {
-               struct page *page = to->bv_page;
+               struct page *bounce_page;
 
-               if (!PageHighMem(page))
+               if (!PageHighMem(to->bv_page))
                        continue;
 
-               to->bv_page = mempool_alloc(&page_pool, GFP_NOIO);
-               inc_zone_page_state(to->bv_page, NR_BOUNCE);
+               bounce_page = mempool_alloc(&page_pool, GFP_NOIO);
+               inc_zone_page_state(bounce_page, NR_BOUNCE);
 
                if (rw == WRITE) {
-                       char *vto, *vfrom;
-
-                       flush_dcache_page(page);
-
-                       vto = page_address(to->bv_page) + to->bv_offset;
-                       vfrom = kmap_atomic(page) + to->bv_offset;
-                       memcpy(vto, vfrom, to->bv_len);
-                       kunmap_atomic(vfrom);
+                       flush_dcache_page(to->bv_page);
+                       memcpy_from_bvec(page_address(bounce_page), to);
                }
+               to->bv_page = bounce_page;
        }
 
        trace_block_bio_bounce(*bio_orig);