aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-09-09 18:39:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-10 16:29:01 -0400
commit1e8937526e2309d48fccd81bb30a590ac21a5516 (patch)
treedbe633c56156a394445c33a64f41678609958e68
parent6894258eda2f9badc28c878086c0e54bd5b7fb30 (diff)
dma-mapping: consolidate dma_{alloc,free}_noncoherent
Most architectures do not support non-coherent allocations and either define dma_{alloc,free}_noncoherent to their coherent versions or stub them out. Openrisc uses dma_{alloc,free}_attrs to implement them, and only Mips implements them directly. This patch moves the Openrisc version to common code, and handles the DMA_ATTR_NON_CONSISTENT case in the mips dma_map_ops instance. Note that actual non-coherent allocations require a dma_cache_sync implementation, so if non-coherent allocations didn't work on an architecture before this patch they still won't work after it. [jcmvbkbc@gmail.com: fix xtensa] Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Russell King <linux@arm.linux.org.uk> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Michal Simek <monstr@monstr.eu> Cc: Jonas Bonn <jonas@southpole.se> Cc: Chris Metcalf <cmetcalf@ezchip.com> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/alpha/include/asm/dma-mapping.h3
-rw-r--r--arch/arm/include/asm/dma-mapping.h21
-rw-r--r--arch/arm64/include/asm/dma-mapping.h14
-rw-r--r--arch/h8300/include/asm/dma-mapping.h3
-rw-r--r--arch/hexagon/include/asm/dma-mapping.h3
-rw-r--r--arch/ia64/include/asm/dma-mapping.h3
-rw-r--r--arch/microblaze/include/asm/dma-mapping.h3
-rw-r--r--arch/mips/include/asm/dma-mapping.h6
-rw-r--r--arch/mips/mm/dma-default.c20
-rw-r--r--arch/openrisc/include/asm/dma-mapping.h20
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h3
-rw-r--r--arch/s390/include/asm/dma-mapping.h3
-rw-r--r--arch/sh/include/asm/dma-mapping.h3
-rw-r--r--arch/sparc/include/asm/dma-mapping.h3
-rw-r--r--arch/tile/include/asm/dma-mapping.h3
-rw-r--r--arch/unicore32/include/asm/dma-mapping.h3
-rw-r--r--arch/x86/include/asm/dma-mapping.h3
-rw-r--r--arch/xtensa/include/asm/dma-mapping.h3
-rw-r--r--include/asm-generic/dma-mapping-common.h18
19 files changed, 39 insertions, 99 deletions
diff --git a/arch/alpha/include/asm/dma-mapping.h b/arch/alpha/include/asm/dma-mapping.h
index 9fef5bd59a82..0552bf097245 100644
--- a/arch/alpha/include/asm/dma-mapping.h
+++ b/arch/alpha/include/asm/dma-mapping.h
@@ -27,9 +27,6 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
27 return get_dma_ops(dev)->set_dma_mask(dev, mask); 27 return get_dma_ops(dev)->set_dma_mask(dev, mask);
28} 28}
29 29
30#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
31#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
32
33#define dma_cache_sync(dev, va, size, dir) ((void)0) 30#define dma_cache_sync(dev, va, size, dir) ((void)0)
34 31
35#endif /* _ALPHA_DMA_MAPPING_H */ 32#endif /* _ALPHA_DMA_MAPPING_H */
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index bc404473f1ca..0b7787167b64 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -38,6 +38,12 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
38 dev->archdata.dma_ops = ops; 38 dev->archdata.dma_ops = ops;
39} 39}
40 40
41/*
42 * Note that while the generic code provides dummy dma_{alloc,free}_noncoherent
43 * implementations, we don't provide a dma_cache_sync function so drivers using
44 * this API are highlighted with build warnings.
45 */
46
41#include <asm-generic/dma-mapping-common.h> 47#include <asm-generic/dma-mapping-common.h>
42 48
43static inline int dma_set_mask(struct device *dev, u64 mask) 49static inline int dma_set_mask(struct device *dev, u64 mask)
@@ -175,21 +181,6 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
175 return dma_addr == DMA_ERROR_CODE; 181 return dma_addr == DMA_ERROR_CODE;
176} 182}
177 183
178/*
179 * Dummy noncoherent implementation. We don't provide a dma_cache_sync
180 * function so drivers using this API are highlighted with build warnings.
181 */
182static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
183 dma_addr_t *handle, gfp_t gfp)
184{
185 return NULL;
186}
187
188static inline void dma_free_noncoherent(struct device *dev, size_t size,
189 void *cpu_addr, dma_addr_t handle)
190{
191}
192
193extern int dma_supported(struct device *dev, u64 mask); 184extern int dma_supported(struct device *dev, u64 mask);
194 185
195extern int arm_dma_set_mask(struct device *dev, u64 dma_mask); 186extern int arm_dma_set_mask(struct device *dev, u64 dma_mask);
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index 5e11b3f0fe3a..178e60b80922 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -118,19 +118,5 @@ static inline void dma_mark_clean(void *addr, size_t size)
118{ 118{
119} 119}
120 120
121/*
122 * There is no dma_cache_sync() implementation, so just return NULL here.
123 */
124static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
125 dma_addr_t *handle, gfp_t flags)
126{
127 return NULL;
128}
129
130static inline void dma_free_noncoherent(struct device *dev, size_t size,
131 void *cpu_addr, dma_addr_t handle)
132{
133}
134
135#endif /* __KERNEL__ */ 121#endif /* __KERNEL__ */
136#endif /* __ASM_DMA_MAPPING_H */ 122#endif /* __ASM_DMA_MAPPING_H */
diff --git a/arch/h8300/include/asm/dma-mapping.h b/arch/h8300/include/asm/dma-mapping.h
index 826aa9b519b7..72465ce59453 100644
--- a/arch/h8300/include/asm/dma-mapping.h
+++ b/arch/h8300/include/asm/dma-mapping.h
@@ -20,9 +20,6 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
20 return 0; 20 return 0;
21} 21}
22 22
23#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
24#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
25
26static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 23static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
27{ 24{
28 return 0; 25 return 0;
diff --git a/arch/hexagon/include/asm/dma-mapping.h b/arch/hexagon/include/asm/dma-mapping.h
index c20d3caa7dad..58d2d8f1544a 100644
--- a/arch/hexagon/include/asm/dma-mapping.h
+++ b/arch/hexagon/include/asm/dma-mapping.h
@@ -34,9 +34,6 @@ extern int bad_dma_address;
34 34
35extern struct dma_map_ops *dma_ops; 35extern struct dma_map_ops *dma_ops;
36 36
37#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
38#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
39
40static inline struct dma_map_ops *get_dma_ops(struct device *dev) 37static inline struct dma_map_ops *get_dma_ops(struct device *dev)
41{ 38{
42 if (unlikely(dev == NULL)) 39 if (unlikely(dev == NULL))
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index d36f83cc226a..a925ff03c964 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -23,9 +23,6 @@ extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t,
23extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int, 23extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
24 enum dma_data_direction); 24 enum dma_data_direction);
25 25
26#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
27#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
28
29#define get_dma_ops(dev) platform_dma_get_ops(dev) 26#define get_dma_ops(dev) platform_dma_get_ops(dev)
30 27
31#include <asm-generic/dma-mapping-common.h> 28#include <asm-generic/dma-mapping-common.h>
diff --git a/arch/microblaze/include/asm/dma-mapping.h b/arch/microblaze/include/asm/dma-mapping.h
index 801dbe215a8c..bc81625d486f 100644
--- a/arch/microblaze/include/asm/dma-mapping.h
+++ b/arch/microblaze/include/asm/dma-mapping.h
@@ -98,9 +98,6 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
98 return (dma_addr == DMA_ERROR_CODE); 98 return (dma_addr == DMA_ERROR_CODE);
99} 99}
100 100
101#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
102#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
103
104static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 101static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
105 enum dma_data_direction direction) 102 enum dma_data_direction direction)
106{ 103{
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index b197595134ba..709b2ba79cc3 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -64,10 +64,4 @@ dma_set_mask(struct device *dev, u64 mask)
64extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 64extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
65 enum dma_data_direction direction); 65 enum dma_data_direction direction);
66 66
67void *dma_alloc_noncoherent(struct device *dev, size_t size,
68 dma_addr_t *dma_handle, gfp_t flag);
69
70void dma_free_noncoherent(struct device *dev, size_t size,
71 void *vaddr, dma_addr_t dma_handle);
72
73#endif /* _ASM_DMA_MAPPING_H */ 67#endif /* _ASM_DMA_MAPPING_H */
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 6c0fd13fa8e8..a914dc1cb6d1 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -112,7 +112,7 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
112 return gfp | dma_flag; 112 return gfp | dma_flag;
113} 113}
114 114
115void *dma_alloc_noncoherent(struct device *dev, size_t size, 115static void *mips_dma_alloc_noncoherent(struct device *dev, size_t size,
116 dma_addr_t * dma_handle, gfp_t gfp) 116 dma_addr_t * dma_handle, gfp_t gfp)
117{ 117{
118 void *ret; 118 void *ret;
@@ -128,7 +128,6 @@ void *dma_alloc_noncoherent(struct device *dev, size_t size,
128 128
129 return ret; 129 return ret;
130} 130}
131EXPORT_SYMBOL(dma_alloc_noncoherent);
132 131
133static void *mips_dma_alloc_coherent(struct device *dev, size_t size, 132static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
134 dma_addr_t * dma_handle, gfp_t gfp, struct dma_attrs *attrs) 133 dma_addr_t * dma_handle, gfp_t gfp, struct dma_attrs *attrs)
@@ -137,6 +136,13 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
137 struct page *page = NULL; 136 struct page *page = NULL;
138 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; 137 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
139 138
139 /*
140 * XXX: seems like the coherent and non-coherent implementations could
141 * be consolidated.
142 */
143 if (dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs))
144 return mips_dma_alloc_noncoherent(dev, size, dma_handle, gfp);
145
140 gfp = massage_gfp_flags(dev, gfp); 146 gfp = massage_gfp_flags(dev, gfp);
141 147
142 if (IS_ENABLED(CONFIG_DMA_CMA) && !(gfp & GFP_ATOMIC)) 148 if (IS_ENABLED(CONFIG_DMA_CMA) && !(gfp & GFP_ATOMIC))
@@ -161,13 +167,12 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
161} 167}
162 168
163 169
164void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr, 170static void mips_dma_free_noncoherent(struct device *dev, size_t size,
165 dma_addr_t dma_handle) 171 void *vaddr, dma_addr_t dma_handle)
166{ 172{
167 plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL); 173 plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
168 free_pages((unsigned long) vaddr, get_order(size)); 174 free_pages((unsigned long) vaddr, get_order(size));
169} 175}
170EXPORT_SYMBOL(dma_free_noncoherent);
171 176
172static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr, 177static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
173 dma_addr_t dma_handle, struct dma_attrs *attrs) 178 dma_addr_t dma_handle, struct dma_attrs *attrs)
@@ -176,6 +181,11 @@ static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
176 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; 181 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
177 struct page *page = NULL; 182 struct page *page = NULL;
178 183
184 if (dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) {
185 mips_dma_free_noncoherent(dev, size, vaddr, dma_handle);
186 return;
187 }
188
179 plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL); 189 plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
180 190
181 if (!plat_device_is_coherent(dev) && !hw_coherentio) 191 if (!plat_device_is_coherent(dev) && !hw_coherentio)
diff --git a/arch/openrisc/include/asm/dma-mapping.h b/arch/openrisc/include/asm/dma-mapping.h
index a81d6f68e9c8..57722528ea4d 100644
--- a/arch/openrisc/include/asm/dma-mapping.h
+++ b/arch/openrisc/include/asm/dma-mapping.h
@@ -37,26 +37,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
37 37
38#include <asm-generic/dma-mapping-common.h> 38#include <asm-generic/dma-mapping-common.h>
39 39
40static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
41 dma_addr_t *dma_handle, gfp_t gfp)
42{
43 struct dma_attrs attrs;
44
45 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
46
47 return dma_alloc_attrs(dev, size, dma_handle, gfp, &attrs);
48}
49
50static inline void dma_free_noncoherent(struct device *dev, size_t size,
51 void *cpu_addr, dma_addr_t dma_handle)
52{
53 struct dma_attrs attrs;
54
55 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
56
57 dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs);
58}
59
60static inline int dma_supported(struct device *dev, u64 dma_mask) 40static inline int dma_supported(struct device *dev, u64 dma_mask)
61{ 41{
62 /* Support 32 bit DMA mask exclusively */ 42 /* Support 32 bit DMA mask exclusively */
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index e6ca63ac4c6c..7971b421c677 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -177,9 +177,6 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
177 return daddr - get_dma_offset(dev); 177 return daddr - get_dma_offset(dev);
178} 178}
179 179
180#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
181#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
182
183#define ARCH_HAS_DMA_MMAP_COHERENT 180#define ARCH_HAS_DMA_MMAP_COHERENT
184 181
185static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 182static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
diff --git a/arch/s390/include/asm/dma-mapping.h b/arch/s390/include/asm/dma-mapping.h
index c29c9c7d81e8..b729efeb9ad8 100644
--- a/arch/s390/include/asm/dma-mapping.h
+++ b/arch/s390/include/asm/dma-mapping.h
@@ -25,9 +25,6 @@ static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
25{ 25{
26} 26}
27 27
28#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
29#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
30
31#include <asm-generic/dma-mapping-common.h> 28#include <asm-generic/dma-mapping-common.h>
32 29
33static inline int dma_supported(struct device *dev, u64 mask) 30static inline int dma_supported(struct device *dev, u64 mask)
diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h
index 3c78059e66ff..2c3fa2ccbe9b 100644
--- a/arch/sh/include/asm/dma-mapping.h
+++ b/arch/sh/include/asm/dma-mapping.h
@@ -38,9 +38,6 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
38void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 38void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
39 enum dma_data_direction dir); 39 enum dma_data_direction dir);
40 40
41#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
42#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
43
44static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 41static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
45{ 42{
46 struct dma_map_ops *ops = get_dma_ops(dev); 43 struct dma_map_ops *ops = get_dma_ops(dev);
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index a8c678494ce7..2564edcb9728 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -9,9 +9,6 @@
9 9
10int dma_supported(struct device *dev, u64 mask); 10int dma_supported(struct device *dev, u64 mask);
11 11
12#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
14
15static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 12static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
16 enum dma_data_direction dir) 13 enum dma_data_direction dir)
17{ 14{
diff --git a/arch/tile/include/asm/dma-mapping.h b/arch/tile/include/asm/dma-mapping.h
index 4aba10e49310..e982dfa5d2f4 100644
--- a/arch/tile/include/asm/dma-mapping.h
+++ b/arch/tile/include/asm/dma-mapping.h
@@ -116,9 +116,6 @@ dma_set_mask(struct device *dev, u64 mask)
116 return 0; 116 return 0;
117} 117}
118 118
119#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL)
120#define dma_free_noncoherent(d, s, v, h) dma_free_attrs(d, s, v, h, NULL)
121
122/* 119/*
123 * dma_alloc_noncoherent() is #defined to return coherent memory, 120 * dma_alloc_noncoherent() is #defined to return coherent memory,
124 * so there's no need to do any flushing here. 121 * so there's no need to do any flushing here.
diff --git a/arch/unicore32/include/asm/dma-mapping.h b/arch/unicore32/include/asm/dma-mapping.h
index 5294d03e59de..636e942940a0 100644
--- a/arch/unicore32/include/asm/dma-mapping.h
+++ b/arch/unicore32/include/asm/dma-mapping.h
@@ -80,9 +80,6 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
80 return 0; 80 return 0;
81} 81}
82 82
83#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
84#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
85
86static inline void dma_cache_sync(struct device *dev, void *vaddr, 83static inline void dma_cache_sync(struct device *dev, void *vaddr,
87 size_t size, enum dma_data_direction direction) 84 size_t size, enum dma_data_direction direction)
88{ 85{
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index f9b1b6cc48b6..7e47e4d6e69c 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -56,9 +56,6 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
56 return (dma_addr == DMA_ERROR_CODE); 56 return (dma_addr == DMA_ERROR_CODE);
57} 57}
58 58
59#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
60#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
61
62extern int dma_supported(struct device *hwdev, u64 mask); 59extern int dma_supported(struct device *hwdev, u64 mask);
63extern int dma_set_mask(struct device *dev, u64 mask); 60extern int dma_set_mask(struct device *dev, u64 mask);
64 61
diff --git a/arch/xtensa/include/asm/dma-mapping.h b/arch/xtensa/include/asm/dma-mapping.h
index bf24c908e5ff..0a19581375da 100644
--- a/arch/xtensa/include/asm/dma-mapping.h
+++ b/arch/xtensa/include/asm/dma-mapping.h
@@ -32,9 +32,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
32 32
33#include <asm-generic/dma-mapping-common.h> 33#include <asm-generic/dma-mapping-common.h>
34 34
35#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL)
36#define dma_free_noncoherent(d, s, v, h) dma_free_attrs(d, s, v, h, NULL)
37
38static inline int 35static inline int
39dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 36dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
40{ 37{
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index 56dd9ea2bc8c..ec321dd98f93 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -295,4 +295,22 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
295 return dma_free_attrs(dev, size, cpu_addr, dma_handle, NULL); 295 return dma_free_attrs(dev, size, cpu_addr, dma_handle, NULL);
296} 296}
297 297
298static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
299 dma_addr_t *dma_handle, gfp_t gfp)
300{
301 DEFINE_DMA_ATTRS(attrs);
302
303 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
304 return dma_alloc_attrs(dev, size, dma_handle, gfp, &attrs);
305}
306
307static inline void dma_free_noncoherent(struct device *dev, size_t size,
308 void *cpu_addr, dma_addr_t dma_handle)
309{
310 DEFINE_DMA_ATTRS(attrs);
311
312 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
313 dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs);
314}
315
298#endif 316#endif