dma-mapping: Provide write-combine allocations
Subsystems (2)
RFC 1/1 dma-mapping: Provide write-combine allocations
Provide an implementation for dma_{alloc,free}_writecombine() when the architecture supports DMA attributes.
Signed-off-by Thierry Reding <[email protected]>
--- arch/arm/include/asm/dma-mapping.h | 16 ---------------- include/linux/dma-mapping.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-)
arch/arm/include/asm/dma-mapping.h +0 -16
@@ -242,22 +242,6 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs); -static inline void *dma_alloc_writecombine (struct device *dev,size_t size, -dma_addr_t *dma_handle,gfp_t flag) -{ -DEFINE_DMA_ATTRS (attrs); -dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); -return dma_alloc_attrs (dev, size, dma_handle, flag, &attrs); -} - -static inline void dma_free_writecombine (struct device *dev,size_t size, -void *cpu_addr,dma_addr_t dma_handle) -{ -DEFINE_DMA_ATTRS (attrs); -dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); -return dma_free_attrs (dev, size, cpu_addr, dma_handle, &attrs); -} -/* * This can be called during early boot to increase the size of the atomic * coherent DMA pool above the default value of 256KiB. It must be called
include/linux/dma-mapping.h +16 -0
@@ -249,6 +249,22 @@ struct dma_attrs;#define dma_unmap_sg_attrs (dev, sgl, nents, dir, attrs) \ dma_unmap_sg(dev, sgl, nents, dir) +#else +static inline void *dma_alloc_writecombine (struct device *dev,size_t size, +dma_addr_t *dma_addr,gfp_t gfp) +{ +DEFINE_DMA_ATTRS (attrs); +dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); +return dma_alloc_attrs (dev, size, dma_addr, gfp, &attrs); +} + +static inline void dma_free_writecombine (struct device *dev,size_t size, +void *cpu_addr,dma_addr_t dma_addr) +{ +DEFINE_DMA_ATTRS (attrs); +dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); +return dma_free_attrs (dev, size, cpu_addr, dma_addr, &attrs); +}#endif /* CONFIG_HAVE_DMA_ATTRS */ #ifdef CONFIG_NEED_DMA_MAP_STATE
Signature · 1 line
1.8.4.2
Marek Szyprowski
maintainerHello,
Quoted 53 lines · Thierry Reding
Provide an implementation for dma_{alloc,free}_writecombine() when the architecture supports DMA attributes.
Signed-off-by Thierry Reding <[email protected]>--- arch/arm/include/asm/dma-mapping.h | 16 ---------------- include/linux/dma-mapping.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-)arch/arm/include/asm/dma-mapping.h +0
-16@@ -242,22 +242,6 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs); -static inline void *dma_alloc_writecombine (struct device *dev,size_t size, -dma_addr_t *dma_handle,gfp_t flag) -{ -DEFINE_DMA_ATTRS (attrs); -dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); -return dma_alloc_attrs (dev, size, dma_handle, flag, &attrs); -} - -static inline void dma_free_writecombine (struct device *dev,size_t size, -void *cpu_addr,dma_addr_t dma_handle) -{ -DEFINE_DMA_ATTRS (attrs); -dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); -return dma_free_attrs (dev, size, cpu_addr, dma_handle, &attrs); -} -/* * This can be called during early boot to increase the size of the atomic * coherent DMA pool above the default value of 256KiB. It must be called include/linux/dma-mapping.h +9
-0@@ -249,6 +249,22 @@ struct dma_attrs;#define dma_unmap_sg_attrs (dev, sgl, nents, dir, attrs) \ dma_unmap_sg(dev, sgl, nents, dir) +#else +static inline void *dma_alloc_writecombine (struct device *dev,size_t size, +dma_addr_t *dma_addr,gfp_t gfp) +{ +DEFINE_DMA_ATTRS (attrs); +dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); +return dma_alloc_attrs (dev, size, dma_addr, gfp, &attrs); +} +
include/linux/dma-mapping.h struct dma_attrs; · line 270
Quoted 10 lines
include/linux/dma-mapping.h +7
-0+static inline void dma_free_writecombine (struct device *dev,size_t size, +void *cpu_addr,dma_addr_t dma_addr) +{ +DEFINE_DMA_ATTRS (attrs); +dma_set_attr (DMA_ATTR_WRITE_COMBINE , &attrs); +return dma_free_attrs (dev, size, cpu_addr, dma_addr, &attrs); +}#endif /* CONFIG_HAVE_DMA_ATTRS */ #ifdef CONFIG_NEED_DMA_MAP_STATE
I would also add dma_mmap_writecombine() to the above functions.
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland