1 On architectures where highmem isn't used, arguments to kmap/unmap are
2 simply thrown away without being evaluated. This is fine until a
3 wrapper function is written. Even though it got ignored in the end,
4 the arguments are evaulated. As asm/highmem.h is not included by
5 linux/highmem.h when CONFIG_HIGHMEM is off, none of KM_* constants get
6 defined which results in error if those are evaluated.
8 This patch makes linux/highmem.h include asm/kmap_types.h regardless
9 of CONFIG_HIGHMEM. To deal with the same problem, crypto subsystem
10 used to include asm/kmap_types.h directly. This patch kills it.
12 Signed-off-by: Tejun Heo <htejun@gmail.com>
16 crypto/internal.h | 1 -
17 include/linux/highmem.h | 1 +
18 2 files changed, 1 insertions(+), 1 deletions(-)
20 4e0462fa09e87da901867f37b2c7311ef714c3e7
21 diff --git a/crypto/internal.h b/crypto/internal.h
22 index 959e602..4188672 100644
23 --- a/crypto/internal.h
24 +++ b/crypto/internal.h
26 #include <linux/kernel.h>
27 #include <linux/rwsem.h>
28 #include <linux/slab.h>
29 -#include <asm/kmap_types.h>
31 extern struct list_head crypto_alg_list;
32 extern struct rw_semaphore crypto_alg_sem;
33 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
34 index 6bece92..c605f01 100644
35 --- a/include/linux/highmem.h
36 +++ b/include/linux/highmem.h
40 #include <asm/cacheflush.h>
41 +#include <asm/kmap_types.h>
46 When block requests are handled via DMA dma mapping functions take
47 care of cache coherency. Unfortunately, cache coherencly was left
48 unhandled until now for block PIOs, resulting in data corruption
49 issues on architectures with aliasing caches.
51 All block PIO operations use kmap/unmap to access target memory area
52 and the mapping/unmapping points are the perfect places for cache
53 flushing. kmap/unmap are to PIO'ing cpus what dma_map/unmap are to
56 This patch implements blk kmap helpers which additionally take
57 @direction argument and deal with cache coherency.
59 Signed-off-by: Tejun Heo <htejun@gmail.com>
61 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
62 index 02a585f..1040029 100644
63 --- a/include/linux/blkdev.h
64 +++ b/include/linux/blkdev.h
67 #include <asm/scatterlist.h>
69 +/* for PIO kmap helpers */
70 +#include <linux/highmem.h>
71 +#include <linux/dma-mapping.h>
74 typedef struct request_queue request_queue_t;
75 struct elevator_queue;
76 @@ -812,6 +816,40 @@ static inline void put_dev_sector(Sector
77 page_cache_release(p.v);
83 + * Block PIO requires cache flushes on architectures with aliasing
84 + * caches. If a driver wants to perform PIO on a user-mappable page
85 + * (page cache page), it MUST use one of the following kmap/unmap
86 + * helpers unless it handles cache coherency itself.
88 +static inline void * blk_kmap_atomic(struct page *page, enum km_type type,
89 + enum dma_data_direction dir)
91 + return kmap_atomic(page, type);
94 +static inline void blk_kunmap_atomic(void *addr, enum km_type type,
95 + enum dma_data_direction dir)
97 + if (dir == DMA_BIDIRECTIONAL || dir == DMA_FROM_DEVICE)
98 + flush_dcache_page(kmap_atomic_to_page(addr));
99 + kunmap_atomic(addr, type);
102 +static inline void * blk_kmap(struct page *page, enum dma_data_direction dir)
107 +static inline void blk_kunmap(struct page *page, enum dma_data_direction dir)
109 + if (dir == DMA_BIDIRECTIONAL || dir == DMA_FROM_DEVICE)
110 + flush_dcache_page(page);
115 int kblockd_schedule_work(struct work_struct *work);
116 void kblockd_flush(void);
117 diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
118 index 62ebefd..24d5e56 100644
119 --- a/drivers/ide/ide-taskfile.c
120 +++ b/drivers/ide/ide-taskfile.c
121 @@ -260,6 +260,7 @@ static void ide_pio_sector(ide_drive_t *
123 ide_hwif_t *hwif = drive->hwif;
124 struct scatterlist *sg = hwif->sg_table;
125 + enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
127 #ifdef CONFIG_HIGHMEM
129 @@ -277,7 +278,7 @@ static void ide_pio_sector(ide_drive_t *
130 #ifdef CONFIG_HIGHMEM
131 local_irq_save(flags);
133 - buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
134 + buf = blk_kmap_atomic(page, KM_BIO_SRC_IRQ, dir) + offset;
138 @@ -293,7 +294,7 @@ static void ide_pio_sector(ide_drive_t *
140 taskfile_input_data(drive, buf, SECTOR_WORDS);
142 - kunmap_atomic(buf, KM_BIO_SRC_IRQ);
143 + blk_kunmap_atomic(buf, KM_BIO_SRC_IRQ, dir);
144 #ifdef CONFIG_HIGHMEM
145 local_irq_restore(flags);