From: Tejun Heo <htejun@gmail.com>
To: axboe@suse.de, bzolnier@gmail.com, rmk@arm.linux.org.uk,
james.steward@dynamicratings.com, jgarzik@pobox.com,
James.Bottomley@SteelEye.com, linux-kernel@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 3/8] block: convert bio kmap helpers to use blk_kmap helpers
Date: Sat, 14 Jan 2006 00:24:16 +0900 [thread overview]
Message-ID: <11371658562445-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11371658562541-git-send-email-htejun@gmail.com>
Convert __bio_kmap_atomic, bvec_kmap_irq, __bio_kmap_irq, bio_kmap_irq
and their unmap counterparts such that they take @dir argument and use
blk_kmap helpers instead of directly calling kmap/unmap. This patch
also converts all users accordingly.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/ide/ide-floppy.c | 8 +++---
drivers/md/raid5.c | 9 +++++--
drivers/md/raid6main.c | 9 +++++--
drivers/scsi/scsi_lib.c | 5 ++--
fs/bio.c | 5 ++--
include/linux/bio.h | 59 --------------------------------------------
include/linux/blkdev.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 84 insertions(+), 72 deletions(-)
b35899fcc1babe0d74c9eb6d05beddb5992f4a60
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 5945f55..af39130 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -615,9 +615,9 @@ static void idefloppy_input_buffers (ide
count = min(bvec->bv_len, bcount);
- data = bvec_kmap_irq(bvec, &flags);
+ data = bvec_kmap_irq(bvec, &flags, DMA_FROM_DEVICE);
drive->hwif->atapi_input_bytes(drive, data, count);
- bvec_kunmap_irq(data, &flags);
+ bvec_kunmap_irq(data, &flags, DMA_FROM_DEVICE);
bcount -= count;
pc->b_count += count;
@@ -649,9 +649,9 @@ static void idefloppy_output_buffers (id
count = min(bvec->bv_len, bcount);
- data = bvec_kmap_irq(bvec, &flags);
+ data = bvec_kmap_irq(bvec, &flags, DMA_TO_DEVICE);
drive->hwif->atapi_output_bytes(drive, data, count);
- bvec_kunmap_irq(data, &flags);
+ bvec_kunmap_irq(data, &flags, DMA_TO_DEVICE);
bcount -= count;
pc->b_count += count;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 54f4a98..db1fcd2 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -689,12 +689,17 @@ static void copy_data(int frombio, struc
else clen = len;
if (clen > 0) {
- char *ba = __bio_kmap_atomic(bio, i, KM_USER0);
+ enum dma_data_direction dir;
+ char *ba;
+
+ dir = frombio ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
+ ba = __bio_kmap_atomic(bio, i, KM_USER0, dir);
+
if (frombio)
memcpy(pa+page_offset, ba+b_offset, clen);
else
memcpy(ba+b_offset, pa+page_offset, clen);
- __bio_kunmap_atomic(ba, KM_USER0);
+ __bio_kunmap_atomic(ba, KM_USER0, dir);
}
if (clen < len) /* hit end of page */
break;
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 8c823d6..f320291 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -720,12 +720,17 @@ static void copy_data(int frombio, struc
else clen = len;
if (clen > 0) {
- char *ba = __bio_kmap_atomic(bio, i, KM_USER0);
+ enum dma_data_direction dir;
+ char *ba;
+
+ dir = frombio ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
+ ba = __bio_kmap_atomic(bio, i, KM_USER0, dir);
+
if (frombio)
memcpy(pa+page_offset, ba+b_offset, clen);
else
memcpy(ba+b_offset, pa+page_offset, clen);
- __bio_kunmap_atomic(ba, KM_USER0);
+ __bio_kunmap_atomic(ba, KM_USER0, dir);
}
if (clen < len) /* hit end of page */
break;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 00c9bf3..73285eb 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -942,9 +942,10 @@ void scsi_io_completion(struct scsi_cmnd
else if (cmd->buffer != req->buffer) {
if (rq_data_dir(req) == READ) {
unsigned long flags;
- char *to = bio_kmap_irq(req->bio, &flags);
+ char *to = bio_kmap_irq(req->bio, &flags,
+ DMA_FROM_DEVICE);
memcpy(to, cmd->buffer, cmd->bufflen);
- bio_kunmap_irq(to, &flags);
+ bio_kunmap_irq(to, &flags, DMA_FROM_DEVICE);
}
kfree(cmd->buffer);
}
diff --git a/fs/bio.c b/fs/bio.c
index 7b30695..c7b5442 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -199,10 +199,9 @@ void zero_fill_bio(struct bio *bio)
int i;
bio_for_each_segment(bv, bio, i) {
- char *data = bvec_kmap_irq(bv, &flags);
+ char *data = bvec_kmap_irq(bv, &flags, DMA_FROM_DEVICE);
memset(data, 0, bv->bv_len);
- flush_dcache_page(bv->bv_page);
- bvec_kunmap_irq(data, &flags);
+ bvec_kunmap_irq(data, &flags, DMA_FROM_DEVICE);
}
}
EXPORT_SYMBOL(zero_fill_bio);
diff --git a/include/linux/bio.h b/include/linux/bio.h
index b60ffe3..8c80a14 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -186,18 +186,6 @@ struct bio {
#define bvec_to_phys(bv) (page_to_phys((bv)->bv_page) + (unsigned long) (bv)->bv_offset)
/*
- * queues that have highmem support enabled may still need to revert to
- * PIO transfers occasionally and thus map high pages temporarily. For
- * permanent PIO fall back, user is probably better off disabling highmem
- * I/O completely on that queue (see ide-dma for example)
- */
-#define __bio_kmap_atomic(bio, idx, kmtype) \
- (kmap_atomic(bio_iovec_idx((bio), (idx))->bv_page, kmtype) + \
- bio_iovec_idx((bio), (idx))->bv_offset)
-
-#define __bio_kunmap_atomic(addr, kmtype) kunmap_atomic(addr, kmtype)
-
-/*
* merge helpers etc
*/
@@ -310,51 +298,4 @@ extern struct bio *bio_copy_user(struct
extern int bio_uncopy_user(struct bio *);
void zero_fill_bio(struct bio *bio);
-#ifdef CONFIG_HIGHMEM
-/*
- * remember to add offset! and never ever reenable interrupts between a
- * bvec_kmap_irq and bvec_kunmap_irq!!
- *
- * This function MUST be inlined - it plays with the CPU interrupt flags.
- */
-static inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags)
-{
- unsigned long addr;
-
- /*
- * might not be a highmem page, but the preempt/irq count
- * balancing is a lot nicer this way
- */
- local_irq_save(*flags);
- addr = (unsigned long) kmap_atomic(bvec->bv_page, KM_BIO_SRC_IRQ);
-
- BUG_ON(addr & ~PAGE_MASK);
-
- return (char *) addr + bvec->bv_offset;
-}
-
-static inline void bvec_kunmap_irq(char *buffer, unsigned long *flags)
-{
- unsigned long ptr = (unsigned long) buffer & PAGE_MASK;
-
- kunmap_atomic((void *) ptr, KM_BIO_SRC_IRQ);
- local_irq_restore(*flags);
-}
-
-#else
-#define bvec_kmap_irq(bvec, flags) (page_address((bvec)->bv_page) + (bvec)->bv_offset)
-#define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0)
-#endif
-
-static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
- unsigned long *flags)
-{
- return bvec_kmap_irq(bio_iovec_idx(bio, idx), flags);
-}
-#define __bio_kunmap_irq(buf, flags) bvec_kunmap_irq(buf, flags)
-
-#define bio_kmap_irq(bio, flags) \
- __bio_kmap_irq((bio), (bio)->bi_idx, (flags))
-#define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags)
-
#endif /* __LINUX_BIO_H */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1040029..ed432cf 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -850,6 +850,67 @@ static inline void blk_kunmap(struct pag
kunmap(page);
}
+static inline void * __bio_kmap_atomic(struct bio *bio, unsigned short idx,
+ enum km_type type,
+ enum dma_data_direction dir)
+{
+ struct bio_vec *bvec = bio_iovec_idx(bio, idx);
+ return blk_kmap_atomic(bvec->bv_page, type, dir) + bvec->bv_offset;
+}
+
+static inline void __bio_kunmap_atomic(void *addr, enum km_type type,
+ enum dma_data_direction dir)
+{
+ addr = (void *)((unsigned long)addr & PAGE_MASK);
+ return blk_kunmap_atomic(addr, type, dir);
+}
+
+/*
+ * Never ever reenable interrupts between a bvec_kmap_irq and
+ * bvec_kunmap_irq!! This function MUST be inlined - it plays with
+ * the CPU interrupt flags.
+ */
+static inline char * bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags,
+ enum dma_data_direction dir)
+{
+ char *addr;
+
+ /*
+ * might not be a highmem page, but the preempt/irq count
+ * balancing is a lot nicer this way
+ */
+#ifdef CONFIG_HIGHMEM
+ local_irq_save(*flags);
+#endif
+ addr = blk_kmap_atomic(bvec->bv_page, KM_BIO_SRC_IRQ, dir);
+
+ BUG_ON(((unsigned long)addr) & ~PAGE_MASK);
+
+ return addr + bvec->bv_offset;
+}
+
+static inline void bvec_kunmap_irq(char *addr, unsigned long *flags,
+ enum dma_data_direction dir)
+{
+ addr = (char *)((unsigned long)addr & PAGE_MASK);
+ blk_kunmap_atomic(addr, KM_BIO_SRC_IRQ, dir);
+#ifdef CONFIG_HIGHMEM
+ local_irq_restore(*flags);
+#endif
+}
+
+static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
+ unsigned long *flags,
+ enum dma_data_direction dir)
+{
+ return bvec_kmap_irq(bio_iovec_idx(bio, idx), flags, dir);
+}
+#define __bio_kunmap_irq(buf, flags, dir) bvec_kunmap_irq(buf, flags, dir)
+
+#define bio_kmap_irq(bio, flags, dir) \
+ __bio_kmap_irq((bio), (bio)->bi_idx, (flags), dir)
+#define bio_kunmap_irq(buf,flags, dir) __bio_kunmap_irq(buf, flags, dir)
+
struct work_struct;
int kblockd_schedule_work(struct work_struct *work);
void kblockd_flush(void);
--
1.0.6
next prev parent reply other threads:[~2006-01-13 15:25 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-13 15:24 [PATCHSET] block: fix PIO cache coherency bug Tejun Heo
2006-01-13 15:24 ` Tejun Heo [this message]
2006-01-13 15:24 ` [PATCH 5/8] block: convert libata to use blk_kmap helpers Tejun Heo
2006-01-13 15:24 ` [PATCH 2/8] block: implement blk kmap helpers Tejun Heo
2006-01-13 15:24 ` [PATCH 4/8] block: convert IDE to use blk_kmap helpers Tejun Heo
2006-02-14 19:07 ` Matt Reimer
2006-02-15 2:05 ` Tejun Heo
2006-02-16 18:01 ` Russell King
2006-02-16 18:10 ` Linus Torvalds
2006-02-16 19:02 ` Russell King
2006-01-13 15:24 ` [PATCH 1/8] highmem: include asm/kmap_types.h in linux/highmem.h Tejun Heo
2006-01-13 15:24 ` [PATCH 7/8] block: convert block/rd.c to use blk_kmap helpers Tejun Heo
2006-01-13 15:24 ` [PATCH 8/8] block: convert md " Tejun Heo
2006-01-13 15:24 ` [PATCH 6/8] block: convert scsi " Tejun Heo
2006-01-13 15:37 ` [PATCHSET] block: fix PIO cache coherency bug Jens Axboe
2006-01-13 15:47 ` Bartlomiej Zolnierkiewicz
2006-01-13 15:50 ` James Bottomley
2006-01-13 18:20 ` Russell King
2006-01-13 18:35 ` James Bottomley
2006-01-13 19:06 ` Russell King
2006-02-22 8:27 ` Tejun Heo
2006-03-02 18:46 ` James Bottomley
2006-03-02 20:30 ` Russell King
2006-03-02 20:43 ` James Bottomley
2006-03-02 20:57 ` Russell King
2006-03-02 20:44 ` Jens Axboe
2006-05-29 19:17 ` Nicolas Pitre
2006-05-30 11:19 ` Tejun Heo
2006-05-30 21:07 ` Guennadi Liakhovetski
2006-05-30 21:32 ` Nicolas Pitre
2006-05-31 0:57 ` David S. Miller
2006-03-02 20:40 ` Jens Axboe
2006-03-20 16:12 ` James Bottomley
2006-03-20 16:26 ` Tejun Heo
2006-03-20 16:33 ` James Bottomley
2006-03-20 16:40 ` Tejun Heo
2006-03-20 16:48 ` James Bottomley
2006-03-23 14:23 ` James Bottomley
2006-03-20 16:50 ` Randy.Dunlap
2006-03-20 16:52 ` James Bottomley
2006-01-13 22:02 ` Russell King
2006-01-13 22:38 ` James Bottomley
2006-01-13 22:43 ` David S. Miller
2006-01-14 4:58 ` James Bottomley
2006-01-17 15:00 ` Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11371658562445-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=James.Bottomley@SteelEye.com \
--cc=axboe@suse.de \
--cc=bzolnier@gmail.com \
--cc=james.steward@dynamicratings.com \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.