]> err.no Git - linux-2.6/commitdiff
ARM: support generic per-device coherent dma mem
authorDmitry Baryshkov <dbaryshkov@gmail.com>
Fri, 18 Jul 2008 09:30:14 +0000 (13:30 +0400)
committerIngo Molnar <mingo@elte.hu>
Fri, 18 Jul 2008 19:14:01 +0000 (21:14 +0200)
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/arm/Kconfig
arch/arm/mm/consistent.c
include/asm-arm/dma-mapping.h

index c7ad324ddf2cf407c89839f75487f8e27f9fa0cc..ea8b9be02b605d72b8bd1074221f1055c7fda6d3 100644 (file)
@@ -16,6 +16,7 @@ config ARM
        select HAVE_KRETPROBES if (HAVE_KPROBES)
        select HAVE_FTRACE if (!XIP_KERNEL)
        select HAVE_DYNAMIC_FTRACE if (HAVE_FTRACE)
+       select HAVE_GENERIC_DMA_COHERENT
        help
          The ARM series is a line of low-power-consumption RISC chip designs
          licensed by ARM Ltd and targeted at embedded applications and
index 333a82a3717e07daa8979986480579b943507e53..db7b3e38ef1d1410287f8ca7a84cd435e73f5c2c 100644 (file)
@@ -274,6 +274,11 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
 void *
 dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
 {
+       void *memory;
+
+       if (dma_alloc_from_coherent(dev, size, handle, &memory))
+               return memory;
+
        if (arch_is_coherent()) {
                void *virt;
 
@@ -362,6 +367,9 @@ void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr
 
        WARN_ON(irqs_disabled());
 
+       if (dma_release_from_coherent(dev, get_order(size), cpu_addr))
+               return;
+
        if (arch_is_coherent()) {
                kfree(cpu_addr);
                return;
index e99406a7bece7264569542b85a72ea8c7d3aaa1e..943f23bc99a2035c165eb78577387babdab905af 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <linux/scatterlist.h>
 
+#include <asm-generic/dma-coherent.h>
+
 /*
  * DMA-consistent mapping functions.  These allocate/free a region of
  * uncached, unwrite-buffered mapped memory space for use with DMA