linux-omap 2.6.37: replace various patch with upstream versions and rediff
[openembedded.git] / recipes / linux / linux-handhelds-2.6-2.6.16 / block-pio.patch
blob294140b6e89194255506716b013ca2c4826600ba
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>
14 ---
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
25 @@ -21,7 +21,6 @@
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
37 @@ -6,6 +6,7 @@
38 #include <linux/mm.h>
40 #include <asm/cacheflush.h>
41 +#include <asm/kmap_types.h>
43 #ifdef CONFIG_HIGHMEM
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
54 DMAing devices.
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
65 @@ -17,6 +17,10 @@
67 #include <asm/scatterlist.h>
69 +/* for PIO kmap helpers */
70 +#include <linux/highmem.h>
71 +#include <linux/dma-mapping.h>
73 struct request_queue;
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);
80 +/*
81 + * PIO kmap helpers.
82 + *
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.
87 + */
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)
104 + return kmap(page);
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);
111 + kunmap(page);
114 struct work_struct;
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;
126 struct page *page;
127 #ifdef CONFIG_HIGHMEM
128 unsigned long flags;
129 @@ -277,7 +278,7 @@ static void ide_pio_sector(ide_drive_t *
130 #ifdef CONFIG_HIGHMEM
131 local_irq_save(flags);
132 #endif
133 - buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
134 + buf = blk_kmap_atomic(page, KM_BIO_SRC_IRQ, dir) + offset;
136 hwif->nleft--;
137 hwif->cursg_ofs++;
138 @@ -293,7 +294,7 @@ static void ide_pio_sector(ide_drive_t *
139 else
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);
146 #endif