Skip to content

Commit cf560c1

Browse files
billauermichalsimek
authored andcommitted
microblaze: Moved __dma_sync() to dma-mapping.h
__dma_sync_page() was replaced by __dma_sync(), and parameters of calls to the new function were adjusted to match __dma_sync()'s format. Signed-off-by: Eli Billauer <eli.billauer@gmail.com> Signed-off-by: Michal Simek <monstr@monstr.eu>
1 parent 2309f7c commit cf560c1

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎arch/microblaze/include/asm/dma-mapping.h‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
#include <linux/dma-attrs.h>
2929
#include <asm/io.h>
3030
#include <asm-generic/dma-coherent.h>
31+
#include <asm/cacheflush.h>
3132

3233
#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
3334

3435
#define __dma_alloc_coherent(dev, gfp, size, handle) NULL
3536
#define __dma_free_coherent(size, addr) ((void)0)
36-
#define __dma_sync(addr, size, rw) ((void)0)
3737

3838
static inline unsigned long device_to_mask(struct device *dev)
3939
{
@@ -95,6 +95,22 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
9595

9696
#include <asm-generic/dma-mapping-common.h>
9797

98+
static inline void __dma_sync(unsigned long paddr,
99+
size_t size, enum dma_data_direction direction)
100+
{
101+
switch (direction) {
102+
case DMA_TO_DEVICE:
103+
case DMA_BIDIRECTIONAL:
104+
flush_dcache_range(paddr, paddr + size);
105+
break;
106+
case DMA_FROM_DEVICE:
107+
invalidate_dcache_range(paddr, paddr + size);
108+
break;
109+
default:
110+
BUG();
111+
}
112+
}
113+
98114
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
99115
{
100116
struct dma_map_ops *ops = get_dma_ops(dev);
@@ -135,7 +151,7 @@ static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
135151
enum dma_data_direction direction)
136152
{
137153
BUG_ON(direction == DMA_NONE);
138-
__dma_sync(vaddr, size, (int)direction);
154+
__dma_sync(virt_to_phys(vaddr), size, (int)direction);
139155
}
140156

141157
#endif /* _ASM_MICROBLAZE_DMA_MAPPING_H */

‎arch/microblaze/kernel/dma.c‎

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/gfp.h>
1212
#include <linux/dma-debug.h>
1313
#include <asm/bug.h>
14-
#include <asm/cacheflush.h>
1514

1615
/*
1716
* Generic direct DMA implementation
@@ -21,21 +20,6 @@
2120
* can set archdata.dma_data to an unsigned long holding the offset. By
2221
* default the offset is PCI_DRAM_OFFSET.
2322
*/
24-
static inline void __dma_sync_page(unsigned long paddr, unsigned long offset,
25-
size_t size, enum dma_data_direction direction)
26-
{
27-
switch (direction) {
28-
case DMA_TO_DEVICE:
29-
case DMA_BIDIRECTIONAL:
30-
flush_dcache_range(paddr + offset, paddr + offset + size);
31-
break;
32-
case DMA_FROM_DEVICE:
33-
invalidate_dcache_range(paddr + offset, paddr + offset + size);
34-
break;
35-
default:
36-
BUG();
37-
}
38-
}
3923

4024
static unsigned long get_dma_direct_offset(struct device *dev)
4125
{
@@ -91,7 +75,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
9175
/* FIXME this part of code is untested */
9276
for_each_sg(sgl, sg, nents, i) {
9377
sg->dma_address = sg_phys(sg) + get_dma_direct_offset(dev);
94-
__dma_sync_page(page_to_phys(sg_page(sg)), sg->offset,
78+
__dma_sync(page_to_phys(sg_page(sg)) + sg->offset,
9579
sg->length, direction);
9680
}
9781

@@ -116,7 +100,7 @@ static inline dma_addr_t dma_direct_map_page(struct device *dev,
116100
enum dma_data_direction direction,
117101
struct dma_attrs *attrs)
118102
{
119-
__dma_sync_page(page_to_phys(page), offset, size, direction);
103+
__dma_sync(page_to_phys(page) + offset, size, direction);
120104
return page_to_phys(page) + offset + get_dma_direct_offset(dev);
121105
}
122106

@@ -131,7 +115,7 @@ static inline void dma_direct_unmap_page(struct device *dev,
131115
* phys_to_virt is here because in __dma_sync_page is __virt_to_phys and
132116
* dma_address is physical address
133117
*/
134-
__dma_sync_page(dma_address, 0 , size, direction);
118+
__dma_sync(dma_address, size, direction);
135119
}
136120

137121
struct dma_map_ops dma_direct_ops = {

0 commit comments

Comments
 (0)