compat: fix dma_common_get_sgtable() backport placements
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Mon, 6 May 2013 21:52:05 +0000 (14:52 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 7 May 2013 13:22:48 +0000 (15:22 +0200)
We added dma_common_get_sgtable() assuming it should only
be available to older kernels as of 3.6 but it was only
up to 3.8 where it was detangled from depending on
CONFIG_HAVE_GENERIC_DMA_COHERENT. Its a mess to express
this on compat files so just word it via kconfig and throw this
onto its own files given that there may be other helpers
we may need to backport later with the same circumstances.

One last hack was required for 3.3-3.6 and that is due
to header changes between kernels.

$ time ckmake --check-exports --allyesconfig

1   2.6.24              [  OK  ]
2   2.6.25              [  OK  ]
3   2.6.26              [  OK  ]
4   2.6.27              [  OK  ]
5   2.6.28              [  OK  ]
6   2.6.29              [  OK  ]
7   2.6.30              [  OK  ]
8   2.6.31              [  OK  ]
9   2.6.32              [  OK  ]
10  2.6.33              [  OK  ]
11  2.6.34              [  OK  ]
12  2.6.35              [  OK  ]
13  2.6.36              [  OK  ]
14  2.6.37              [  OK  ]
15  2.6.38              [  OK  ]
16  2.6.39              [  OK  ]
17  3.0.65              [  OK  ]
18  3.1.10              [  OK  ]
19  3.2.38              [  OK  ]
20  3.3.8               [  LINK  ]
21  3.4.32              [  LINK  ]
22  3.5.7               [  LINK  ]
23  3.6.11              [  OK  ]
24  3.7.9               [  OK  ]
25  3.8.0               [  OK  ]
26  3.9-rc1             [  OK  ]

real    30m3.120s
user    795m40.684s
sys     123m29.995s

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/backport-include/asm/dma-mapping.h
backport/backport-include/linux/dma-attrs.h [new file with mode: 0644]
backport/compat/Kconfig
backport/compat/Makefile
backport/compat/compat-3.6.c
backport/compat/dma-shared-helpers.c [new file with mode: 0644]

index 81e5d91d3b77fb8464db1c09791071d93c04e2e3..844fe3b39ae22f196164fb052d904f6e7735252c 100644 (file)
@@ -3,12 +3,14 @@
 #include_next <asm/dma-mapping.h>
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
-
+#if defined(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS)
 #define dma_common_get_sgtable LINUX_BACKPORT(dma_common_get_sgtable)
 int
 dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
                       void *cpu_addr, dma_addr_t dma_addr, size_t size);
+#endif /* defined(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 
 #define dma_get_sgtable_attrs LINUX_BACKPORT(dma_get_sgtable_attrs)
 struct dma_attrs;
@@ -20,6 +22,6 @@ dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr,
 }
 
 #define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL)
-#endif
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) */
 
 #endif /* __BACKPORT_ASM_DMA_MAPPING_H */
diff --git a/backport/backport-include/linux/dma-attrs.h b/backport/backport-include/linux/dma-attrs.h
new file mode 100644 (file)
index 0000000..ee4cd5f
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __BACKPORT_DMA_ATTR_H
+#define __BACKPORT_DMA_ATTR_H
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+#include_next <linux/dma-attrs.h>
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) */
+#endif /* __BACKPORT_DMA_ATTR_H */
index afa410ea36039b14186abf41ec51505bd8cbab28..215de8e525883376ce2e1fa8631c2590ff855692 100644 (file)
@@ -158,6 +158,17 @@ config BACKPORT_BUILD_HDMI
 config BACKPORT_HDMI
        bool
 
+config BACKPORT_BUILD_DMA_SHARED_HELPERS
+       bool
+       depends on HAS_DMA
+       # Build on other kernels kernels < 3.9 if HAVE_GENERIC_DMA_COHERENT is
+       # not set. Kernels >= 3.8 have this if HAS_DMA is set.
+       depends on (!HAVE_GENERIC_DMA_COHERENT || BACKPORT_KERNEL_3_9)
+       # Always build if on 3.3 - 3.5
+       default y if (BACKPORT_KERNEL_3_4 || BACKPORT_KERNEL_3_5 || BACKPORT_KERNEL_3_6)
+       # build for testing
+       default y if BACKPORT_USERSEL_BUILD_ALL
+
 config BACKPORT_BUILD_LEDS
        bool
        depends on !NEW_LEDS || !LEDS_CLASS || !LEDS_TRIGGERS
index 41f223fa8ac769b441f2f3c88265007efcf97869..19d4d2d259db32e7d396460ab5930edbb1b911ad 100644 (file)
@@ -37,3 +37,4 @@ compat-$(CPTCFG_BACKPORT_KERNEL_3_9) += compat-3.9.o
 
 compat-$(CPTCFG_BACKPORT_BUILD_KFIFO) += kfifo.o
 compat-$(CPTCFG_BACKPORT_BUILD_GENERIC_ATOMIC64) += compat_atomic.o
+compat-$(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o
index 1e4480b00e8d02edaad160a35554903b1eb24156..05954d451fa8a5eec8f34834a040d69c4241228a 100644 (file)
 #include <linux/i2c.h>
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
-#include <linux/dma-attrs.h>
-/*
- * Create scatter-list for the already allocated DMA buffer.
- */
-int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
-                void *cpu_addr, dma_addr_t handle, size_t size)
-{
-       struct page *page = virt_to_page(cpu_addr);
-       int ret;
-
-       ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
-       if (unlikely(ret))
-               return ret;
-
-       sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(dma_common_get_sgtable);
-
 /**
  * __i2c_transfer - unlocked flavor of i2c_transfer
  * @adap: Handle to I2C bus
diff --git a/backport/compat/dma-shared-helpers.c b/backport/compat/dma-shared-helpers.c
new file mode 100644 (file)
index 0000000..e09dd6b
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013  Luis R. Rodriguez <mcgrof@do-not-panic.com>
+ *
+ * Backport compatibility file for Linux for some DMA helpers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/scatterlist.h>
+#include <linux/dma-attrs.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0)
+#include <linux/dma-direction.h>
+#include <linux/dma-mapping.h>
+#include <asm/dma-mapping.h>
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */
+
+/*
+ * Create scatter-list for the already allocated DMA buffer.
+ */
+int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
+                void *cpu_addr, dma_addr_t handle, size_t size)
+{
+       struct page *page = virt_to_page(cpu_addr);
+       int ret;
+
+       ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
+       if (unlikely(ret))
+               return ret;
+
+       sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(dma_common_get_sgtable);