diff options
Diffstat (limited to 'arch/microblaze/kernel/dma.c')
-rw-r--r-- | arch/microblaze/kernel/dma.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c index 300fea46737e..64bc39f40ba7 100644 --- a/arch/microblaze/kernel/dma.c +++ b/arch/microblaze/kernel/dma.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/dma-mapping.h> | 10 | #include <linux/dma-mapping.h> |
11 | #include <linux/dma-debug.h> | 11 | #include <linux/dma-debug.h> |
12 | #include <asm/bug.h> | 12 | #include <asm/bug.h> |
13 | #include <asm/cacheflush.h> | ||
13 | 14 | ||
14 | /* | 15 | /* |
15 | * Generic direct DMA implementation | 16 | * Generic direct DMA implementation |
@@ -20,6 +21,23 @@ | |||
20 | * default the offset is PCI_DRAM_OFFSET. | 21 | * default the offset is PCI_DRAM_OFFSET. |
21 | */ | 22 | */ |
22 | 23 | ||
24 | static inline void __dma_sync_page(void *vaddr, unsigned long offset, | ||
25 | size_t size, enum dma_data_direction direction) | ||
26 | { | ||
27 | unsigned long start = virt_to_phys(vaddr); | ||
28 | |||
29 | switch (direction) { | ||
30 | case DMA_TO_DEVICE: | ||
31 | flush_dcache_range(start + offset, start + offset + size); | ||
32 | break; | ||
33 | case DMA_FROM_DEVICE: | ||
34 | invalidate_dcache_range(start + offset, start + offset + size); | ||
35 | break; | ||
36 | default: | ||
37 | BUG(); | ||
38 | } | ||
39 | } | ||
40 | |||
23 | static unsigned long get_dma_direct_offset(struct device *dev) | 41 | static unsigned long get_dma_direct_offset(struct device *dev) |
24 | { | 42 | { |
25 | if (dev) | 43 | if (dev) |
@@ -85,11 +103,11 @@ static inline dma_addr_t dma_direct_map_page(struct device *dev, | |||
85 | struct page *page, | 103 | struct page *page, |
86 | unsigned long offset, | 104 | unsigned long offset, |
87 | size_t size, | 105 | size_t size, |
88 | enum dma_data_direction dir, | 106 | enum dma_data_direction direction, |
89 | struct dma_attrs *attrs) | 107 | struct dma_attrs *attrs) |
90 | { | 108 | { |
91 | BUG_ON(dir == DMA_NONE); | 109 | BUG_ON(direction == DMA_NONE); |
92 | __dma_sync_page(page, offset, size, dir); | 110 | __dma_sync_page(page, offset, size, direction); |
93 | return page_to_phys(page) + offset + get_dma_direct_offset(dev); | 111 | return page_to_phys(page) + offset + get_dma_direct_offset(dev); |
94 | } | 112 | } |
95 | 113 | ||
@@ -99,6 +117,8 @@ static inline void dma_direct_unmap_page(struct device *dev, | |||
99 | enum dma_data_direction direction, | 117 | enum dma_data_direction direction, |
100 | struct dma_attrs *attrs) | 118 | struct dma_attrs *attrs) |
101 | { | 119 | { |
120 | /* There is not necessary to do cache cleanup */ | ||
121 | /* __dma_sync_page(dma_address, 0 , size, direction); */ | ||
102 | } | 122 | } |
103 | 123 | ||
104 | struct dma_map_ops dma_direct_ops = { | 124 | struct dma_map_ops dma_direct_ops = { |