path: root/include/asm-generic/dma-mapping-common.h
diff options
authorChristoph Hellwig <>2015-09-09 15:39:42 -0700
committerLinus Torvalds <>2015-09-10 13:29:01 -0700
commit1e8937526e2309d48fccd81bb30a590ac21a5516 (patch)
treedbe633c56156a394445c33a64f41678609958e68 /include/asm-generic/dma-mapping-common.h
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. [ fix xtensa] Signed-off-by: Christoph Hellwig <> Cc: Arnd Bergmann <> Cc: Russell King <> Cc: Catalin Marinas <> Cc: Will Deacon <> Cc: Yoshinori Sato <> Cc: Michal Simek <> Cc: Jonas Bonn <> Cc: Chris Metcalf <> Cc: Guan Xuetao <> Cc: Ralf Baechle <> Cc: Benjamin Herrenschmidt <> Cc: Ingo Molnar <> Cc: Thomas Gleixner <> Cc: "H. Peter Anvin" <> Cc: Andy Shevchenko <> Signed-off-by: Max Filippov <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'include/asm-generic/dma-mapping-common.h')
1 files changed, 18 insertions, 0 deletions
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,
return dma_free_attrs(dev, size, cpu_addr, dma_handle, NULL);
+static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
+ dma_addr_t *dma_handle, gfp_t gfp)
+ dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
+ return dma_alloc_attrs(dev, size, dma_handle, gfp, &attrs);
+static inline void dma_free_noncoherent(struct device *dev, size_t size,
+ void *cpu_addr, dma_addr_t dma_handle)
+ dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
+ dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs);