diff mbox

Non existing DMA functions in ARC: dma_alloc_attrs, dma_free_attrs, dma_mmap_attrs

Message ID C2D7FE5348E1B147BCA15975FBA23075F44D45E5@IN01WEMBXA.internal.synopsys.com
State Not Applicable, archived
Delegated to: Vineet Gupta
Headers show

Commit Message

Vineet Gupta Dec. 2, 2015, 6:32 a.m. UTC
On Wednesday 02 December 2015 01:09 AM, Carlos Palminha wrote:
> Hi guys,
>
> I'm bringing up a new ARC PGU driver for DRM framework with latest kernel tree.
> I'm using ARC AXS101 as a base and selected one the DRM required config: HAVE_DMA_ATTRS due to some memory allocation helpers in DRM.
>
> I'm getting some errors with DMA functions not implemented in ARC: dma_alloc_attrs, dma_free_attrs, dma_mmap_attrs
>
> Any clue?
>
> Regards,
> C.Palminha
>
> ---
> include/linux/dma-mapping.h: In function ‘dma_alloc_writecombine’:
> include/linux/dma-mapping.h:283:2: error: implicit declaration of function ‘dma_alloc_attrs’ [-Werror=implicit-function-declaration]
>   return dma_alloc_attrs(dev, size, dma_addr, gfp, &attrs);

This is because ARC port current lacks support for dma_attr_t and associated helpers.
There is a series in flight in linux-next, by Christoph, which already addresses that.

You can either cherry-pick those or in the interim use the hack attached.

P.S. Per your comment at top, I'm assuming you are working off of mainline 4.3 or 4.4

-Vineet
diff mbox

Patch

From 433f5bfff88d0db9a1f86c622510e491e0daf045 Mon Sep 17 00:00:00 2001
From: Vineet Gupta <vgupta@synopsys.com>
Date: Wed, 2 Dec 2015 12:00:41 +0530
Subject: [PATCH] [donot merge]: minimal dma_attr_t support for ARC

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/Kconfig                   |  1 +
 arch/arc/include/asm/dma-mapping.h | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 2c2ac3f3ff80..fdf217cf5041 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -38,6 +38,7 @@  config ARC
 	select OF_EARLY_FLATTREE
 	select PERF_USE_VMALLOC
 	select HAVE_DEBUG_STACKOVERFLOW
+	select HAVE_DMA_ATTRS
 
 config TRACE_IRQFLAGS_SUPPORT
 	def_bool y
diff --git a/arch/arc/include/asm/dma-mapping.h b/arch/arc/include/asm/dma-mapping.h
index 2d28ba939d8e..2b68e2a7b3a1 100644
--- a/arch/arc/include/asm/dma-mapping.h
+++ b/arch/arc/include/asm/dma-mapping.h
@@ -36,6 +36,27 @@  extern int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
 #define dma_mmap_coherent(d, v, c, h, s) dma_common_mmap(d, v, c, h, s)
 #define dma_get_sgtable(d, t, v, h, s) dma_common_get_sgtable(d, t, v, h, s)
 
+static inline void *dma_alloc_attrs(struct device *dev, size_t size,
+				       dma_addr_t *dma_handle, gfp_t flag,
+				       struct dma_attrs *attrs)
+{
+	return dma_alloc_coherent(dev, size, dma_handle, flag);
+}
+
+static inline void dma_free_attrs(struct device *dev, size_t size,
+				     void *cpu_addr, dma_addr_t dma_handle,
+				     struct dma_attrs *attrs)
+{
+	dma_free_coherent(dev, size, cpu_addr, dma_handle);
+}
+
+static inline int
+dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr,
+	       dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
+{
+	return dma_mmap_coherent(dev, vma, cpu_addr, dma_addr, size);
+}
+
 /*
  * streaming DMA Mapping API...
  * CPU accesses page via normal paddr, thus needs to explicitly made
-- 
1.9.1