Skip to contentSkip to conversation

dmaengine: fsl-edma: merge mcf-edma into fsl-edma driver

PATCH In review Frank Li 3 participants 5 messages May 9, 2024 – May 15, 2024

Subsystems (3)
lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

PATCH 1/1 dmaengine: fsl-edma: merge mcf-edma into fsl-edma driver

MCF eDMA are almost the same as FSL eDMA driver. Previously link to two kernel modules, fsl-edma.ko and mcf-edma.ko. These are not problem because mcf-edma is for m68k ARCH and FSL eDMA is for arm/arm64 ARCH. But often build both at PPC ARCH. It also makes sense to build two drivers at the same time. It causes many build warning because share a fsl-edma-common.o. such as:

powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-common.o' being placed in section `.stubs'
powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-trace.o' being placed in section `.stubs'

Merge mcf-edma into fsl-edma driver. So use one driver (fsl-edma.ko) for MCF and FSL eDMA.

mcf-edma.ko should be replaced by fsl-edma.ko in modules, minimizing user space impact because MCF eDMA remains confined to legacy ColdFire mcf5441x production and mcf5441x has been in production for at least a decade and NXP has long ceased ColdFire development.

Update Kconfig to make MCF_EDMA as feature of FSL_EDMA and change Makefile to link mcl-edma-main.o to fsl-edma.o.

Create a common module init/exit functions, which call original's fsl-edma-init[exit]() and mcf-edma-init[exit]().

---
 drivers/dma/Kconfig           |  8 ++++----
 drivers/dma/Makefile          |  5 ++---
 drivers/dma/fsl-edma-common.c | 28 ++++++++++++++++++++++++++++
 drivers/dma/fsl-edma-common.h |  5 +++++
 drivers/dma/fsl-edma-main.c   |  6 ++----
 drivers/dma/mcf-edma-main.c   |  6 ++----
 6 files changed, 43 insertions(+), 15 deletions(-)
drivers/dma/Kconfig +4 -4
index 002a5ec806207..45110520f6e68 100644
@@ -393,14 +393,14 @@ config LS2X_APB_DMA
 	  It does not support memory to memory data transfer.
 
 config MCF_EDMA
-	tristate "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
+	bool "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
 	depends on M5441x || COMPILE_TEST
 	select DMA_ENGINE
 	select DMA_VIRTUAL_CHANNELS
 	help
-	  Support the Freescale ColdFire eDMA engine, 64-channel
-	  implementation that performs complex data transfers with
-	  minimal intervention from a host processor.
+	  Support the Freescale ColdFire eDMA engine in FSL_EDMA driver,
+	  64-channel implementation that performs complex data transfers
+	  with minimal intervention from a host processor.
 	  This module can be found on Freescale ColdFire mcf5441x SoCs.
 
 config MILBEAUT_HDMAC
drivers/dma/Makefile +2 -3
index 802ca916f05f5..0000922c7cbfe 100644
@@ -33,11 +33,10 @@ obj-$(CONFIG_DW_EDMA) += dw-edma/
 obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
 fsl-edma-trace-$(CONFIG_TRACING) := fsl-edma-trace.o
 CFLAGS_fsl-edma-trace.o := -I$(src)
+mcf-edma-main-$(CONFIG_MCF_EDMA) := mcf-edma-main.o
 obj-$(CONFIG_FSL_DMA) += fsldma.o
-fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
+fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y} ${mcf-edma-main-y}
 obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
-mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
-obj-$(CONFIG_MCF_EDMA) += mcf-edma.o
 obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o
 obj-$(CONFIG_FSL_RAID) += fsl_raid.o
 obj-$(CONFIG_HISI_DMA) += hisi_dma.o
drivers/dma/fsl-edma-common.c +28 -0
index 3af4307873157..ac04a2ce4fa1f 100644
@@ -888,4 +888,32 @@ void fsl_edma_setup_regs(struct fsl_edma_engine *edma)
 	}
 }
 
+static int __init fsl_edma_common_init(void)
+{
+	int ret;
+
+	ret = fsl_edma_init();
+	if (ret)
+		return ret;
+
+#ifdef CONFIG_MCF_EDMA
+	ret = mcf_edma_init();
+	if (ret)
+		return ret;
+#endif
+	return 0;
+}
+
+subsys_initcall(fsl_edma_common_init);
+
+static void __exit fsl_edma_common_exit(void)
+{
+	fsl_edma_exit();
+
+#ifdef CONFIG_MCF_EDMA
+	mcf_edma_exit();
+#endif
+}
+module_exit(fsl_edma_common_exit);
+
 MODULE_LICENSE("GPL v2");
drivers/dma/fsl-edma-common.h +5 -0
index ac66222c16040..dfbdcc922ceea 100644
@@ -488,4 +488,9 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan);
 void fsl_edma_cleanup_vchan(struct dma_device *dmadev);
 void fsl_edma_setup_regs(struct fsl_edma_engine *edma);
 
+int __init fsl_edma_init(void);
+void __exit fsl_edma_exit(void);
+int __init mcf_edma_init(void);
+void __exit mcf_edma_exit(void);
+
 #endif /* _FSL_EDMA_COMMON_H_ */
drivers/dma/fsl-edma-main.c +2 -4
index 391e4f13dfeb0..a1c3c4ed869c5 100644
@@ -724,17 +724,15 @@ static struct platform_driver fsl_edma_driver = {
 	.remove_new	= fsl_edma_remove,
 };
 
-static int __init fsl_edma_init(void)
+int __init fsl_edma_init(void)
 {
 	return platform_driver_register(&fsl_edma_driver);
 }
-subsys_initcall(fsl_edma_init);
 
-static void __exit fsl_edma_exit(void)
+void __exit fsl_edma_exit(void)
 {
 	platform_driver_unregister(&fsl_edma_driver);
 }
-module_exit(fsl_edma_exit);
 
 MODULE_ALIAS("platform:fsl-edma");
 MODULE_DESCRIPTION("Freescale eDMA engine driver");
drivers/dma/mcf-edma-main.c +2 -4
index 78c606f6d0026..d97991a1e9518 100644
@@ -284,17 +284,15 @@ bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
 }
 EXPORT_SYMBOL(mcf_edma_filter_fn);
 
-static int __init mcf_edma_init(void)
+int __init mcf_edma_init(void)
 {
 	return platform_driver_register(&mcf_edma_driver);
 }
-subsys_initcall(mcf_edma_init);
 
-static void __exit mcf_edma_exit(void)
+void __exit mcf_edma_exit(void)
 {
 	platform_driver_unregister(&mcf_edma_driver);
 }
-module_exit(mcf_edma_exit);
 
 MODULE_ALIAS("platform:mcf-edma");
 MODULE_DESCRIPTION("Freescale eDMA engine driver, ColdFire family");
Signature · 1 line
2.34.1
#1 lore raw

CC coldfire

Quoted 178 lines · Frank Li

MCF eDMA are almost the same as FSL eDMA driver. Previously link to two kernel modules, fsl-edma.ko and mcf-edma.ko. These are not problem because mcf-edma is for m68k ARCH and FSL eDMA is for arm/arm64 ARCH. But often build both at PPC ARCH. It also makes sense to build two drivers at the same time. It causes many build warning because share a fsl-edma-common.o. such as:

powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-common.o' being placed in section `.stubs'
powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-trace.o' being placed in section `.stubs'

Merge mcf-edma into fsl-edma driver. So use one driver (fsl-edma.ko) for MCF and FSL eDMA.

mcf-edma.ko should be replaced by fsl-edma.ko in modules, minimizing user space impact because MCF eDMA remains confined to legacy ColdFire mcf5441x production and mcf5441x has been in production for at least a decade and NXP has long ceased ColdFire development.

Update Kconfig to make MCF_EDMA as feature of FSL_EDMA and change Makefile to link mcl-edma-main.o to fsl-edma.o.

Create a common module init/exit functions, which call original's fsl-edma-init[exit]() and mcf-edma-init[exit]().

---
 drivers/dma/Kconfig           |  8 ++++----
 drivers/dma/Makefile          |  5 ++---
 drivers/dma/fsl-edma-common.c | 28 ++++++++++++++++++++++++++++
 drivers/dma/fsl-edma-common.h |  5 +++++
 drivers/dma/fsl-edma-main.c   |  6 ++----
 drivers/dma/mcf-edma-main.c   |  6 ++----
 6 files changed, 43 insertions(+), 15 deletions(-)
drivers/dma/Kconfig +4 -4
index 002a5ec806207..45110520f6e68 100644
@@ -393,14 +393,14 @@ config LS2X_APB_DMA
          It does not support memory to memory data transfer.
 
 config MCF_EDMA
-       tristate "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
+       bool "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
        depends on M5441x || COMPILE_TEST
        select DMA_ENGINE
        select DMA_VIRTUAL_CHANNELS
        help
-         Support the Freescale ColdFire eDMA engine, 64-channel
-         implementation that performs complex data transfers with
-         minimal intervention from a host processor.
+         Support the Freescale ColdFire eDMA engine in FSL_EDMA driver,
+         64-channel implementation that performs complex data transfers
+         with minimal intervention from a host processor.
          This module can be found on Freescale ColdFire mcf5441x SoCs.
 
 config MILBEAUT_HDMAC
drivers/dma/Makefile +2 -3
index 802ca916f05f5..0000922c7cbfe 100644
@@ -33,11 +33,10 @@ obj-$(CONFIG_DW_EDMA) += dw-edma/
 obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
 fsl-edma-trace-$(CONFIG_TRACING) := fsl-edma-trace.o
 CFLAGS_fsl-edma-trace.o := -I$(src)
+mcf-edma-main-$(CONFIG_MCF_EDMA) := mcf-edma-main.o
 obj-$(CONFIG_FSL_DMA) += fsldma.o
-fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
+fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y} ${mcf-edma-main-y}
 obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
-mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
-obj-$(CONFIG_MCF_EDMA) += mcf-edma.o
 obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o
 obj-$(CONFIG_FSL_RAID) += fsl_raid.o
 obj-$(CONFIG_HISI_DMA) += hisi_dma.o
drivers/dma/fsl-edma-common.c +28 -0
index 3af4307873157..ac04a2ce4fa1f 100644
@@ -888,4 +888,32 @@ void fsl_edma_setup_regs(struct fsl_edma_engine *edma)
        }
 }
 
+static int __init fsl_edma_common_init(void)
+{
+       int ret;
+
+       ret = fsl_edma_init();
+       if (ret)
+               return ret;
+
+#ifdef CONFIG_MCF_EDMA
+       ret = mcf_edma_init();
+       if (ret)
+               return ret;
+#endif
+       return 0;
+}
+
+subsys_initcall(fsl_edma_common_init);
+
+static void __exit fsl_edma_common_exit(void)
+{
+       fsl_edma_exit();
+
+#ifdef CONFIG_MCF_EDMA
+       mcf_edma_exit();
+#endif
+}
+module_exit(fsl_edma_common_exit);
+
 MODULE_LICENSE("GPL v2");
drivers/dma/fsl-edma-common.h +5 -0
index ac66222c16040..dfbdcc922ceea 100644
@@ -488,4 +488,9 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan);
 void fsl_edma_cleanup_vchan(struct dma_device *dmadev);
 void fsl_edma_setup_regs(struct fsl_edma_engine *edma);
 
+int __init fsl_edma_init(void);
+void __exit fsl_edma_exit(void);
+int __init mcf_edma_init(void);
+void __exit mcf_edma_exit(void);
+
 #endif /* _FSL_EDMA_COMMON_H_ */
drivers/dma/fsl-edma-main.c +2 -4
index 391e4f13dfeb0..a1c3c4ed869c5 100644
@@ -724,17 +724,15 @@ static struct platform_driver fsl_edma_driver = {
        .remove_new     = fsl_edma_remove,
 };
 
-static int __init fsl_edma_init(void)
+int __init fsl_edma_init(void)
 {
        return platform_driver_register(&fsl_edma_driver);
 }
-subsys_initcall(fsl_edma_init);
 
-static void __exit fsl_edma_exit(void)
+void __exit fsl_edma_exit(void)
 {
        platform_driver_unregister(&fsl_edma_driver);
 }
-module_exit(fsl_edma_exit);
 
 MODULE_ALIAS("platform:fsl-edma");
 MODULE_DESCRIPTION("Freescale eDMA engine driver");
drivers/dma/mcf-edma-main.c +2 -5
index 78c606f6d0026..d97991a1e9518 100644
@@ -284,17 +284,15 @@ bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
 }
 EXPORT_SYMBOL(mcf_edma_filter_fn);
 
-static int __init mcf_edma_init(void)
+int __init mcf_edma_init(void)
 {
        return platform_driver_register(&mcf_edma_driver);
 }
-subsys_initcall(mcf_edma_init);
 
-static void __exit mcf_edma_exit(void)
+void __exit mcf_edma_exit(void)
 {
        platform_driver_unregister(&mcf_edma_driver);
 }
-module_exit(mcf_edma_exit);
 
 MODULE_ALIAS("platform:mcf-edma");
 MODULE_DESCRIPTION("Freescale eDMA engine driver, ColdFire family");
--

2.34.1

#2 lore raw

Hi,

Quoted 20 lines · Geert Uytterhoeven

CC coldfire

Quoted 17 lines · Frank Li

MCF eDMA are almost the same as FSL eDMA driver. Previously link to two kernel modules, fsl-edma.ko and mcf-edma.ko. These are not problem because mcf-edma is for m68k ARCH and FSL eDMA is for arm/arm64 ARCH. But often build both at PPC ARCH. It also makes sense to build two drivers at the same time. It causes many build warning because share a fsl-edma-common.o. such as:

powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-common.o' being placed in section `.stubs'
powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-trace.o' being placed in section `.stubs'

Merge mcf-edma into fsl-edma driver. So use one driver (fsl-edma.ko) for MCF and FSL eDMA.

mcf-edma.ko should be replaced by fsl-edma.ko in modules, minimizing user space impact because MCF eDMA remains confined to legacy ColdFire mcf5441x production and mcf5441x has been in production for at least a decade and NXP has long ceased ColdFire development.

when i developed mcf-edma, i tried to modify fsl-edma first. Modules are similar but there are various edma IP versions, and i remember minimal differences in the CF version too, some register bits and, of course, endianness.

If a merge is possible, welcome, i have here mcf5441x, can give a try to this patch as soon as i can.

Quoted 156 lines
Quoted 156 lines

Update Kconfig to make MCF_EDMA as feature of FSL_EDMA and change Makefile to link mcl-edma-main.o to fsl-edma.o.

Create a common module init/exit functions, which call original's fsl-edma-init[exit]() and mcf-edma-init[exit]().

---
  drivers/dma/Kconfig           |  8 ++++----
  drivers/dma/Makefile          |  5 ++---
  drivers/dma/fsl-edma-common.c | 28 ++++++++++++++++++++++++++++
  drivers/dma/fsl-edma-common.h |  5 +++++
  drivers/dma/fsl-edma-main.c   |  6 ++----
  drivers/dma/mcf-edma-main.c   |  6 ++----
  6 files changed, 43 insertions(+), 15 deletions(-)
drivers/dma/Kconfig +4 -4
index 002a5ec806207..45110520f6e68 100644
@@ -393,14 +393,14 @@ config LS2X_APB_DMA
           It does not support memory to memory data transfer.
 
  config MCF_EDMA
-       tristate "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
+       bool "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
         depends on M5441x || COMPILE_TEST
         select DMA_ENGINE
         select DMA_VIRTUAL_CHANNELS
         help
-         Support the Freescale ColdFire eDMA engine, 64-channel
-         implementation that performs complex data transfers with
-         minimal intervention from a host processor.
+         Support the Freescale ColdFire eDMA engine in FSL_EDMA driver,
+         64-channel implementation that performs complex data transfers
+         with minimal intervention from a host processor.
           This module can be found on Freescale ColdFire mcf5441x SoCs.
 
  config MILBEAUT_HDMAC
drivers/dma/Makefile +2 -3
index 802ca916f05f5..0000922c7cbfe 100644
@@ -33,11 +33,10 @@ obj-$(CONFIG_DW_EDMA) += dw-edma/
  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
  fsl-edma-trace-$(CONFIG_TRACING) := fsl-edma-trace.o
  CFLAGS_fsl-edma-trace.o := -I$(src)
+mcf-edma-main-$(CONFIG_MCF_EDMA) := mcf-edma-main.o
  obj-$(CONFIG_FSL_DMA) += fsldma.o
-fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
+fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y} ${mcf-edma-main-y}
  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
-mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
-obj-$(CONFIG_MCF_EDMA) += mcf-edma.o
  obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o
  obj-$(CONFIG_FSL_RAID) += fsl_raid.o
  obj-$(CONFIG_HISI_DMA) += hisi_dma.o
drivers/dma/fsl-edma-common.c +28 -0
index 3af4307873157..ac04a2ce4fa1f 100644
@@ -888,4 +888,32 @@ void fsl_edma_setup_regs(struct fsl_edma_engine *edma)
         }
  }
 
+static int __init fsl_edma_common_init(void)
+{
+       int ret;
+
+       ret = fsl_edma_init();
+       if (ret)
+               return ret;
+
+#ifdef CONFIG_MCF_EDMA
+       ret = mcf_edma_init();
+       if (ret)
+               return ret;
+#endif
+       return 0;
+}
+
+subsys_initcall(fsl_edma_common_init);
+
+static void __exit fsl_edma_common_exit(void)
+{
+       fsl_edma_exit();
+
+#ifdef CONFIG_MCF_EDMA
+       mcf_edma_exit();
+#endif
+}
+module_exit(fsl_edma_common_exit);
+
  MODULE_LICENSE("GPL v2");
drivers/dma/fsl-edma-common.h +5 -0
index ac66222c16040..dfbdcc922ceea 100644
@@ -488,4 +488,9 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan);
  void fsl_edma_cleanup_vchan(struct dma_device *dmadev);
  void fsl_edma_setup_regs(struct fsl_edma_engine *edma);
 
+int __init fsl_edma_init(void);
+void __exit fsl_edma_exit(void);
+int __init mcf_edma_init(void);
+void __exit mcf_edma_exit(void);
+
  #endif /* _FSL_EDMA_COMMON_H_ */
drivers/dma/fsl-edma-main.c +2 -4
index 391e4f13dfeb0..a1c3c4ed869c5 100644
@@ -724,17 +724,15 @@ static struct platform_driver fsl_edma_driver = {
         .remove_new     = fsl_edma_remove,
  };
 
-static int __init fsl_edma_init(void)
+int __init fsl_edma_init(void)
  {
         return platform_driver_register(&fsl_edma_driver);
  }
-subsys_initcall(fsl_edma_init);
 
-static void __exit fsl_edma_exit(void)
+void __exit fsl_edma_exit(void)
  {
         platform_driver_unregister(&fsl_edma_driver);
  }
-module_exit(fsl_edma_exit);
 
  MODULE_ALIAS("platform:fsl-edma");
  MODULE_DESCRIPTION("Freescale eDMA engine driver");
drivers/dma/mcf-edma-main.c +2 -4
index 78c606f6d0026..d97991a1e9518 100644
@@ -284,17 +284,15 @@ bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
  }
  EXPORT_SYMBOL(mcf_edma_filter_fn);
 
-static int __init mcf_edma_init(void)
+int __init mcf_edma_init(void)
  {
         return platform_driver_register(&mcf_edma_driver);
  }
-subsys_initcall(mcf_edma_init);
 
-static void __exit mcf_edma_exit(void)
+void __exit mcf_edma_exit(void)
  {
         platform_driver_unregister(&mcf_edma_driver);
  }
-module_exit(mcf_edma_exit);
 
Quoted 4 lines
Quoted 4 lines
drivers/dma/mcf-edma-main.c +0 -1
  MODULE_ALIAS("platform:mcf-edma");
  MODULE_DESCRIPTION("Freescale eDMA engine driver, ColdFire family");
--

2.34.1

Regards,
angelo

author maintainer
#3 lore raw
Quoted 24 lines · Angelo Dureghello

Hi,

Quoted 20 lines · Geert Uytterhoeven

CC coldfire

Quoted 17 lines · Frank Li

MCF eDMA are almost the same as FSL eDMA driver. Previously link to two kernel modules, fsl-edma.ko and mcf-edma.ko. These are not problem because mcf-edma is for m68k ARCH and FSL eDMA is for arm/arm64 ARCH. But often build both at PPC ARCH. It also makes sense to build two drivers at the same time. It causes many build warning because share a fsl-edma-common.o. such as:

powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-common.o' being placed in section `.stubs'
powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-trace.o' being placed in section `.stubs'

Merge mcf-edma into fsl-edma driver. So use one driver (fsl-edma.ko) for MCF and FSL eDMA.

mcf-edma.ko should be replaced by fsl-edma.ko in modules, minimizing user space impact because MCF eDMA remains confined to legacy ColdFire mcf5441x production and mcf5441x has been in production for at least a decade and NXP has long ceased ColdFire development.

Quoted 7 lines

when i developed mcf-edma, i tried to modify fsl-edma first. Modules are similar but there are various edma IP versions, and i remember minimal differences in the CF version too, some register bits and, of course, endianness.

If a merge is possible, welcome, i have here mcf5441x, can give a try to this patch as soon as i can.

Thanks. I am not sure if recent eDMAv3 and eDMAv5 patch impact mcf5441. eDMAv3 is quite big change. If you can test on mcf5441x, can I send to you a futher clean up for mcf5441x? This patch are just simple glue two driver together to avoid a build warning.

Quoted 167 lines
Quoted 158 lines
Quoted 158 lines

Update Kconfig to make MCF_EDMA as feature of FSL_EDMA and change Makefile to link mcl-edma-main.o to fsl-edma.o.

Create a common module init/exit functions, which call original's fsl-edma-init[exit]() and mcf-edma-init[exit]().

---
  drivers/dma/Kconfig           |  8 ++++----
  drivers/dma/Makefile          |  5 ++---
  drivers/dma/fsl-edma-common.c | 28 ++++++++++++++++++++++++++++
  drivers/dma/fsl-edma-common.h |  5 +++++
  drivers/dma/fsl-edma-main.c   |  6 ++----
  drivers/dma/mcf-edma-main.c   |  6 ++----
  6 files changed, 43 insertions(+), 15 deletions(-)
drivers/dma/Kconfig +4 -4
index 002a5ec806207..45110520f6e68 100644
@@ -393,14 +393,14 @@ config LS2X_APB_DMA
           It does not support memory to memory data transfer.
 
  config MCF_EDMA
-       tristate "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
+       bool "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
         depends on M5441x || COMPILE_TEST
         select DMA_ENGINE
         select DMA_VIRTUAL_CHANNELS
         help
-         Support the Freescale ColdFire eDMA engine, 64-channel
-         implementation that performs complex data transfers with
-         minimal intervention from a host processor.
+         Support the Freescale ColdFire eDMA engine in FSL_EDMA driver,
+         64-channel implementation that performs complex data transfers
+         with minimal intervention from a host processor.
           This module can be found on Freescale ColdFire mcf5441x SoCs.
 
  config MILBEAUT_HDMAC
drivers/dma/Makefile +2 -3
index 802ca916f05f5..0000922c7cbfe 100644
@@ -33,11 +33,10 @@ obj-$(CONFIG_DW_EDMA) += dw-edma/
  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
  fsl-edma-trace-$(CONFIG_TRACING) := fsl-edma-trace.o
  CFLAGS_fsl-edma-trace.o := -I$(src)
+mcf-edma-main-$(CONFIG_MCF_EDMA) := mcf-edma-main.o
  obj-$(CONFIG_FSL_DMA) += fsldma.o
-fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
+fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y} ${mcf-edma-main-y}
  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
-mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
-obj-$(CONFIG_MCF_EDMA) += mcf-edma.o
  obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o
  obj-$(CONFIG_FSL_RAID) += fsl_raid.o
  obj-$(CONFIG_HISI_DMA) += hisi_dma.o
drivers/dma/fsl-edma-common.c +28 -0
index 3af4307873157..ac04a2ce4fa1f 100644
@@ -888,4 +888,32 @@ void fsl_edma_setup_regs(struct fsl_edma_engine *edma)
         }
  }
 
+static int __init fsl_edma_common_init(void)
+{
+       int ret;
+
+       ret = fsl_edma_init();
+       if (ret)
+               return ret;
+
+#ifdef CONFIG_MCF_EDMA
+       ret = mcf_edma_init();
+       if (ret)
+               return ret;
+#endif
+       return 0;
+}
+
+subsys_initcall(fsl_edma_common_init);
+
+static void __exit fsl_edma_common_exit(void)
+{
+       fsl_edma_exit();
+
+#ifdef CONFIG_MCF_EDMA
+       mcf_edma_exit();
+#endif
+}
+module_exit(fsl_edma_common_exit);
+
  MODULE_LICENSE("GPL v2");
drivers/dma/fsl-edma-common.h +5 -0
index ac66222c16040..dfbdcc922ceea 100644
@@ -488,4 +488,9 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan);
  void fsl_edma_cleanup_vchan(struct dma_device *dmadev);
  void fsl_edma_setup_regs(struct fsl_edma_engine *edma);
 
+int __init fsl_edma_init(void);
+void __exit fsl_edma_exit(void);
+int __init mcf_edma_init(void);
+void __exit mcf_edma_exit(void);
+
  #endif /* _FSL_EDMA_COMMON_H_ */
drivers/dma/fsl-edma-main.c +2 -4
index 391e4f13dfeb0..a1c3c4ed869c5 100644
@@ -724,17 +724,15 @@ static struct platform_driver fsl_edma_driver = {
         .remove_new     = fsl_edma_remove,
  };
 
-static int __init fsl_edma_init(void)
+int __init fsl_edma_init(void)
  {
         return platform_driver_register(&fsl_edma_driver);
  }
-subsys_initcall(fsl_edma_init);
 
-static void __exit fsl_edma_exit(void)
+void __exit fsl_edma_exit(void)
  {
         platform_driver_unregister(&fsl_edma_driver);
  }
-module_exit(fsl_edma_exit);
 
  MODULE_ALIAS("platform:fsl-edma");
  MODULE_DESCRIPTION("Freescale eDMA engine driver");
drivers/dma/mcf-edma-main.c +2 -4
index 78c606f6d0026..d97991a1e9518 100644
@@ -284,17 +284,15 @@ bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
  }
  EXPORT_SYMBOL(mcf_edma_filter_fn);
 
-static int __init mcf_edma_init(void)
+int __init mcf_edma_init(void)
  {
         return platform_driver_register(&mcf_edma_driver);
  }
-subsys_initcall(mcf_edma_init);
 
-static void __exit mcf_edma_exit(void)
+void __exit mcf_edma_exit(void)
  {
         platform_driver_unregister(&mcf_edma_driver);
  }
-module_exit(mcf_edma_exit);
 
Quoted 4 lines
Quoted 4 lines
drivers/dma/mcf-edma-main.c +0 -1
  MODULE_ALIAS("platform:mcf-edma");
  MODULE_DESCRIPTION("Freescale eDMA engine driver, ColdFire family");
--

2.34.1

Regards,
angelo

#4 lore raw

Hi,

Quoted 29 lines · Frank Li
Quoted 28 lines · Angelo Dureghello

Hi,

Quoted 20 lines · Geert Uytterhoeven

CC coldfire

Quoted 17 lines · Frank Li

MCF eDMA are almost the same as FSL eDMA driver. Previously link to two kernel modules, fsl-edma.ko and mcf-edma.ko. These are not problem because mcf-edma is for m68k ARCH and FSL eDMA is for arm/arm64 ARCH. But often build both at PPC ARCH. It also makes sense to build two drivers at the same time. It causes many build warning because share a fsl-edma-common.o. such as:

powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-common.o' being placed in section `.stubs'
powerpc64le-linux-ld: warning: orphan section .stubs' from drivers/dma/fsl-edma-trace.o' being placed in section `.stubs'

Merge mcf-edma into fsl-edma driver. So use one driver (fsl-edma.ko) for MCF and FSL eDMA.

mcf-edma.ko should be replaced by fsl-edma.ko in modules, minimizing user space impact because MCF eDMA remains confined to legacy ColdFire mcf5441x production and mcf5441x has been in production for at least a decade and NXP has long ceased ColdFire development.

when i developed mcf-edma, i tried to modify fsl-edma first. Modules are similar but there are various edma IP versions, and i remember minimal differences in the CF version too, some register bits and, of course, endianness.

Quoted 5 lines
Quoted 2 lines

If a merge is possible, welcome, i have here mcf5441x, can give a try to this patch as soon as i can.

Thanks. I am not sure if recent eDMAv3 and eDMAv5 patch impact mcf5441. eDMAv3 is quite big change. If you can test on mcf5441x, can I send to you a futher clean up for mcf5441x?

sure

Quoted 169 lines

This patch are just simple glue two
driver together to avoid a build warning.

Quoted 164 lines
Quoted 157 lines
Quoted 157 lines

Update Kconfig to make MCF_EDMA as feature of FSL_EDMA and change Makefile to link mcl-edma-main.o to fsl-edma.o.

Create a common module init/exit functions, which call original's fsl-edma-init[exit]() and mcf-edma-init[exit]().

---
   drivers/dma/Kconfig           |  8 ++++----
   drivers/dma/Makefile          |  5 ++---
   drivers/dma/fsl-edma-common.c | 28 ++++++++++++++++++++++++++++
   drivers/dma/fsl-edma-common.h |  5 +++++
   drivers/dma/fsl-edma-main.c   |  6 ++----
   drivers/dma/mcf-edma-main.c   |  6 ++----
   6 files changed, 43 insertions(+), 15 deletions(-)
drivers/dma/Kconfig +4 -4
index 002a5ec806207..45110520f6e68 100644
@@ -393,14 +393,14 @@ config LS2X_APB_DMA
            It does not support memory to memory data transfer.
 
   config MCF_EDMA
-       tristate "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
+       bool "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
          depends on M5441x || COMPILE_TEST
          select DMA_ENGINE
          select DMA_VIRTUAL_CHANNELS
          help
-         Support the Freescale ColdFire eDMA engine, 64-channel
-         implementation that performs complex data transfers with
-         minimal intervention from a host processor.
+         Support the Freescale ColdFire eDMA engine in FSL_EDMA driver,
+         64-channel implementation that performs complex data transfers
+         with minimal intervention from a host processor.
            This module can be found on Freescale ColdFire mcf5441x SoCs.
 
   config MILBEAUT_HDMAC
drivers/dma/Makefile +2 -3
index 802ca916f05f5..0000922c7cbfe 100644
@@ -33,11 +33,10 @@ obj-$(CONFIG_DW_EDMA) += dw-edma/
   obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
   fsl-edma-trace-$(CONFIG_TRACING) := fsl-edma-trace.o
   CFLAGS_fsl-edma-trace.o := -I$(src)
+mcf-edma-main-$(CONFIG_MCF_EDMA) := mcf-edma-main.o
   obj-$(CONFIG_FSL_DMA) += fsldma.o
-fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
+fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y} ${mcf-edma-main-y}
   obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
-mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y}
-obj-$(CONFIG_MCF_EDMA) += mcf-edma.o
   obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o
   obj-$(CONFIG_FSL_RAID) += fsl_raid.o
   obj-$(CONFIG_HISI_DMA) += hisi_dma.o
drivers/dma/fsl-edma-common.c +28 -0
index 3af4307873157..ac04a2ce4fa1f 100644
@@ -888,4 +888,32 @@ void fsl_edma_setup_regs(struct fsl_edma_engine *edma)
          }
   }
 
+static int __init fsl_edma_common_init(void)
+{
+       int ret;
+
+       ret = fsl_edma_init();
+       if (ret)
+               return ret;
+
+#ifdef CONFIG_MCF_EDMA
+       ret = mcf_edma_init();
+       if (ret)
+               return ret;
+#endif
+       return 0;
+}
+
+subsys_initcall(fsl_edma_common_init);
+
+static void __exit fsl_edma_common_exit(void)
+{
+       fsl_edma_exit();
+
+#ifdef CONFIG_MCF_EDMA
+       mcf_edma_exit();
+#endif
+}
+module_exit(fsl_edma_common_exit);
+
   MODULE_LICENSE("GPL v2");
drivers/dma/fsl-edma-common.h +5 -0
index ac66222c16040..dfbdcc922ceea 100644
@@ -488,4 +488,9 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan);
   void fsl_edma_cleanup_vchan(struct dma_device *dmadev);
   void fsl_edma_setup_regs(struct fsl_edma_engine *edma);
 
+int __init fsl_edma_init(void);
+void __exit fsl_edma_exit(void);
+int __init mcf_edma_init(void);
+void __exit mcf_edma_exit(void);
+
   #endif /* _FSL_EDMA_COMMON_H_ */
drivers/dma/fsl-edma-main.c +2 -4
index 391e4f13dfeb0..a1c3c4ed869c5 100644
@@ -724,17 +724,15 @@ static struct platform_driver fsl_edma_driver = {
          .remove_new     = fsl_edma_remove,
   };
 
-static int __init fsl_edma_init(void)
+int __init fsl_edma_init(void)
   {
          return platform_driver_register(&fsl_edma_driver);
   }
-subsys_initcall(fsl_edma_init);
 
-static void __exit fsl_edma_exit(void)
+void __exit fsl_edma_exit(void)
   {
          platform_driver_unregister(&fsl_edma_driver);
   }
-module_exit(fsl_edma_exit);
 
   MODULE_ALIAS("platform:fsl-edma");
   MODULE_DESCRIPTION("Freescale eDMA engine driver");
drivers/dma/mcf-edma-main.c +2 -4
index 78c606f6d0026..d97991a1e9518 100644
@@ -284,17 +284,15 @@ bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
   }
   EXPORT_SYMBOL(mcf_edma_filter_fn);
 
-static int __init mcf_edma_init(void)
+int __init mcf_edma_init(void)
   {
          return platform_driver_register(&mcf_edma_driver);
   }
-subsys_initcall(mcf_edma_init);
 
-static void __exit mcf_edma_exit(void)
+void __exit mcf_edma_exit(void)
   {
          platform_driver_unregister(&mcf_edma_driver);
   }
-module_exit(mcf_edma_exit);
 
Quoted 4 lines
Quoted 4 lines
drivers/dma/mcf-edma-main.c +0 -1
   MODULE_ALIAS("platform:mcf-edma");
   MODULE_DESCRIPTION("Freescale eDMA engine driver, ColdFire family");
--

2.34.1

Regards,
angelo

Regards,
angelo