diff options
author | Christoph Hellwig <hch@lst.de> | 2017-08-27 04:12:57 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2017-10-19 10:37:25 -0400 |
commit | 64dc8700c01d94c46fd26b38b7e7d2891934a33b (patch) | |
tree | e92980b34228b26ed64930f26e2a471914e61776 | |
parent | 562437a81aa48e54231896ad36d46439278df4b3 (diff) |
microblaze: make dma_cache_sync a no-op
microblaze does not implement DMA_ATTR_NON_CONSISTENT allocations, so it
doesn't make any sense to do any work in dma_cache_sync given that it
must be a no-op when dma_alloc_attrs returns coherent memory.
This also allows moving __dma_sync out of the microblaze asm/dma-mapping.h
and thus greatly reduce the amount of includes there.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
-rw-r--r-- | arch/microblaze/include/asm/dma-mapping.h | 34 | ||||
-rw-r--r-- | arch/microblaze/kernel/dma.c | 17 |
2 files changed, 17 insertions, 34 deletions
diff --git a/arch/microblaze/include/asm/dma-mapping.h b/arch/microblaze/include/asm/dma-mapping.h index e15cd2f76e23..ad448e4aedb6 100644 --- a/arch/microblaze/include/asm/dma-mapping.h +++ b/arch/microblaze/include/asm/dma-mapping.h | |||
@@ -16,22 +16,6 @@ | |||
16 | #define _ASM_MICROBLAZE_DMA_MAPPING_H | 16 | #define _ASM_MICROBLAZE_DMA_MAPPING_H |
17 | 17 | ||
18 | /* | 18 | /* |
19 | * See Documentation/DMA-API-HOWTO.txt and | ||
20 | * Documentation/DMA-API.txt for documentation. | ||
21 | */ | ||
22 | |||
23 | #include <linux/types.h> | ||
24 | #include <linux/cache.h> | ||
25 | #include <linux/mm.h> | ||
26 | #include <linux/scatterlist.h> | ||
27 | #include <linux/dma-debug.h> | ||
28 | #include <asm/io.h> | ||
29 | #include <asm/cacheflush.h> | ||
30 | |||
31 | #define __dma_alloc_coherent(dev, gfp, size, handle) NULL | ||
32 | #define __dma_free_coherent(size, addr) ((void)0) | ||
33 | |||
34 | /* | ||
35 | * Available generic sets of operations | 19 | * Available generic sets of operations |
36 | */ | 20 | */ |
37 | extern const struct dma_map_ops dma_direct_ops; | 21 | extern const struct dma_map_ops dma_direct_ops; |
@@ -41,27 +25,9 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) | |||
41 | return &dma_direct_ops; | 25 | return &dma_direct_ops; |
42 | } | 26 | } |
43 | 27 | ||
44 | static inline void __dma_sync(unsigned long paddr, | ||
45 | size_t size, enum dma_data_direction direction) | ||
46 | { | ||
47 | switch (direction) { | ||
48 | case DMA_TO_DEVICE: | ||
49 | case DMA_BIDIRECTIONAL: | ||
50 | flush_dcache_range(paddr, paddr + size); | ||
51 | break; | ||
52 | case DMA_FROM_DEVICE: | ||
53 | invalidate_dcache_range(paddr, paddr + size); | ||
54 | break; | ||
55 | default: | ||
56 | BUG(); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | 28 | static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
61 | enum dma_data_direction direction) | 29 | enum dma_data_direction direction) |
62 | { | 30 | { |
63 | BUG_ON(direction == DMA_NONE); | ||
64 | __dma_sync(virt_to_phys(vaddr), size, (int)direction); | ||
65 | } | 31 | } |
66 | 32 | ||
67 | #endif /* _ASM_MICROBLAZE_DMA_MAPPING_H */ | 33 | #endif /* _ASM_MICROBLAZE_DMA_MAPPING_H */ |
diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c index 94700c5270a9..e52b684f8ea2 100644 --- a/arch/microblaze/kernel/dma.c +++ b/arch/microblaze/kernel/dma.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/dma-debug.h> | 12 | #include <linux/dma-debug.h> |
13 | #include <linux/export.h> | 13 | #include <linux/export.h> |
14 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
15 | #include <asm/cacheflush.h> | ||
15 | 16 | ||
16 | #define NOT_COHERENT_CACHE | 17 | #define NOT_COHERENT_CACHE |
17 | 18 | ||
@@ -51,6 +52,22 @@ static void dma_direct_free_coherent(struct device *dev, size_t size, | |||
51 | #endif | 52 | #endif |
52 | } | 53 | } |
53 | 54 | ||
55 | static inline void __dma_sync(unsigned long paddr, | ||
56 | size_t size, enum dma_data_direction direction) | ||
57 | { | ||
58 | switch (direction) { | ||
59 | case DMA_TO_DEVICE: | ||
60 | case DMA_BIDIRECTIONAL: | ||
61 | flush_dcache_range(paddr, paddr + size); | ||
62 | break; | ||
63 | case DMA_FROM_DEVICE: | ||
64 | invalidate_dcache_range(paddr, paddr + size); | ||
65 | break; | ||
66 | default: | ||
67 | BUG(); | ||
68 | } | ||
69 | } | ||
70 | |||
54 | static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, | 71 | static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, |
55 | int nents, enum dma_data_direction direction, | 72 | int nents, enum dma_data_direction direction, |
56 | unsigned long attrs) | 73 | unsigned long attrs) |