summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuman Anna <s-anna@ti.com>2021-04-20 15:22:17 -0500
committerSuman Anna <s-anna@ti.com>2021-04-20 15:49:01 -0500
commit8aba20e20bf746df9bd2ab49643609e2127cf04d (patch)
tree63fd2b71e8fb542e2ed7a39b9f76e88aa69f7a39
parent8c3270d48d6598a7c0ea0e41c03c8e1af6ae1626 (diff)
downloadlinuxutils-8aba20e20bf746df9bd2ab49643609e2127cf04d.tar.gz
cmemk: Fix build errors for 5.10+ kernels
The Linux kernel v5.10 has couple of changes in the DMA layers that causes build failures with the CMEM kernel module: - The dma-mapping.h header file is split up to separate out the dma_map_ops related code into a separate dma-map-ops.h header file [1]. The dma-mapping.h itself is included in this new header file. - The dma-contiguous.h header file is merged into the dma-map-ops.h file [2]. - The dma_pfn_offset is removed from struct device and is replaced with multiple DMA range maps [3]. Update the CMEM kernel module to deal with all the above changes to build properly against v5.10+ kernels - The DMA headers are fixed by just including the new dma-map-ops.h - The dma_pfn_offset removal is addressed by using the newly added dma_direct_set_offset(). This is only an interim fix, and the ideal actual fix would be to actually use dma-ranges in DT. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0a0f0d8be76dcd4390ff538e7060fda34db79717 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0b1abd1fb7efafc25231c54a67c6fbb3d3127efd [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e0d072782c734d27f5af062c62266f2598f68542 Signed-off-by: Suman Anna <s-anna@ti.com>
-rw-r--r--src/cmem/module/cmemk.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/cmem/module/cmemk.c b/src/cmem/module/cmemk.c
index 2239c19..d320422 100644
--- a/src/cmem/module/cmemk.c
+++ b/src/cmem/module/cmemk.c
@@ -16,9 +16,15 @@
/*
* cmemk.c
*/
+
+#include <linux/version.h>
#include <linux/device.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
#include <linux/dma-mapping.h>
#include <linux/dma-contiguous.h>
+#else
+#include <linux/dma-map-ops.h>
+#endif
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -38,8 +44,6 @@
#include <asm/pgtable.h>
#include <asm/io.h>
-#include <linux/version.h>
-
#include <ti/cmem.h>
#include <linux/of.h>
@@ -246,6 +250,11 @@ static struct device *cmem_cma_dev_0;
#if IS_ENABLED(CONFIG_ARCH_KEYSTONE) && IS_ENABLED(CONFIG_ARM_LPAE) \
&& (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
#define KEYSTONE_DMA_PFN_OFFSET 0x780000UL
+
+/* definitions from arch/arm/mach-keystone/memory.h */
+#define KEYSTONE_LOW_PHYS_START 0x80000000ULL
+#define KEYSTONE_HIGH_PHYS_START 0x800000000ULL
+#define KEYSTONE_HIGH_PHYS_SIZE 0x400000000ULL /* 16G */
#endif
#if IS_ENABLED(CONFIG_ARCH_K3)
@@ -2735,10 +2744,17 @@ fail:
return err;
}
-static void __init cmem_dma_offset_configure(struct device *dev)
+static int __init cmem_dma_offset_configure(struct device *dev)
{
#if IS_ENABLED(CONFIG_ARCH_KEYSTONE) && IS_ENABLED(CONFIG_ARM_LPAE)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
dev->dma_pfn_offset = KEYSTONE_DMA_PFN_OFFSET;
+ return 0;
+#else
+ return dma_direct_set_offset(dev, KEYSTONE_HIGH_PHYS_START,
+ KEYSTONE_LOW_PHYS_START,
+ KEYSTONE_HIGH_PHYS_SIZE);
+#endif
#endif
}
@@ -2794,7 +2810,11 @@ int __init cmem_init(void)
NULL, "cmem");
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
cmem_cma_dev_0->coherent_dma_mask = DMA_BIT_MASK(32);
- cmem_dma_offset_configure(cmem_cma_dev_0);
+ err = cmem_dma_offset_configure(cmem_cma_dev_0);
+ if (err) {
+ __E("cmem_dma_offset_configure failed.\n");
+ goto fail_after_dma;
+ }
#endif
for (bi = 0; bi < NBLOCKS; bi++) {
if (!block_start[bi] || !block_end[bi]) {
@@ -2974,6 +2994,9 @@ fail_after_create:
}
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
+fail_after_dma:
+#endif
device_destroy(cmem_class, MKDEV(cmem_major, 0));
class_destroy(cmem_class);