linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC] dma-mapping: Provide write-combine allocations
@ 2014-01-13 13:53 Thierry Reding
  2014-01-14  9:15 ` Marek Szyprowski
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2014-01-13 13:53 UTC (permalink / raw)
  To: linux-arm-kernel

Provide an implementation for dma_{alloc,free}_writecombine() when the
architecture supports DMA attributes.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 arch/arm/include/asm/dma-mapping.h | 16 ----------------
 include/linux/dma-mapping.h        | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index e701a4d9aa59..96b7634a7edc 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -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
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index fd4aee29ad10..8475e02b4bd1 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -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
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [RFC] dma-mapping: Provide write-combine allocations
  2014-01-13 13:53 [RFC] dma-mapping: Provide write-combine allocations Thierry Reding
@ 2014-01-14  9:15 ` Marek Szyprowski
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Szyprowski @ 2014-01-14  9:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On 2014-01-13 14:53, Thierry Reding wrote:
> Provide an implementation for dma_{alloc,free}_writecombine() when the
> architecture supports DMA attributes.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   arch/arm/include/asm/dma-mapping.h | 16 ----------------
>   include/linux/dma-mapping.h        | 16 ++++++++++++++++
>   2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
> index e701a4d9aa59..96b7634a7edc 100644
> --- a/arch/arm/include/asm/dma-mapping.h
> +++ b/arch/arm/include/asm/dma-mapping.h
> @@ -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
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index fd4aee29ad10..8475e02b4bd1 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -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

I would also add dma_mmap_writecombine() to the above functions.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-14  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-13 13:53 [RFC] dma-mapping: Provide write-combine allocations Thierry Reding
2014-01-14  9:15 ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).