Linux M68K Architecture development
 help / color / mirror / Atom feed
* [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues
@ 2026-12-01 22:40 Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 01/10] m68k: add DMA global pool config Angelo Dureghello
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello,
	Sashiko AI Review

Fix a group of Freescale ColdFire edma-related issues.

This patchset has been driven from the following error:

[ 5.520000] fsl-dspi fsl-dspi.0: DMA tx timeout
[ 5.520000] fsl-dspi fsl-dspi.0: DMA transfer failed

A sequence of issues was causing it:
- ColdFire mcf54415 dma support has been disabled since couldn't work
  properly, due to the default ACR registers setup to have a fully
  cacheable (non-coherent) DDR memory,
- as a consequence, fsl-dspi and other drivers using mcf-edma driver are
  not working anymore (error above, and other similar),
- additionally, some other issues preventing edma driver to work has
  been fixed (some reported by Sashiko, except for the last patch of the
  serie).
 
Together, some minor adjustments in the architecture (m68k) area has been
done for the proper "edma fix" purpose. 

Important note:
this patchset has been developed over (and depends from) the patch:
Greg Ungerer <gerg@linux-m68k.org>
m68k: coldfire: fix non-standard readX()/writeX() functions

Link: https://lore.kernel.org/all/20260907134037.1855408-4-gerg@linux-m68k.org/
Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
Angelo Dureghello (10):
      m68k: add DMA global pool config
      m68k: add DMA global pool setup
      m68k: mcf54415: add defines for DMA global pool
      m68k: mcf54415: add DMA global pool initialization
      m68K: mcf54415: rename mcf edma clock name
      m68k: mcf54415: align device name with clock name
      dmaengine: mcf-edma: enable edma clock
      dmaengine: mcf-edma: fix wrong BIT() usage on u64
      dmaengine: mcf-edma: fix wrong error handling
      dmaengine: fsl-edma: fix missing big-endian swap

 arch/m68k/Kconfig.cpu            | 14 +++++++++++++
 arch/m68k/coldfire/Makefile      |  2 ++
 arch/m68k/coldfire/device.c      |  2 +-
 arch/m68k/coldfire/dma.c         | 30 ++++++++++++++++++++++++++++
 arch/m68k/coldfire/head.S        |  5 +++++
 arch/m68k/coldfire/m5441x.c      | 11 ++++++++--
 arch/m68k/include/asm/m54xxacr.h | 21 ++++++++++++++++----
 arch/m68k/mm/kmap.c              |  5 +++++
 drivers/dma/fsl-edma-common.h    |  6 +++---
 drivers/dma/mcf-edma-main.c      | 43 +++++++++++++++++++++++-----------------
 10 files changed, 111 insertions(+), 28 deletions(-)
---
base-commit: 4977160ce4ad297800e5243d1fb4b1d96d66d8fc
change-id: 20261201-wip-ks-stmark2-dma-fix-24a5931bf6d2

Best regards,
--  
Angelo Dureghello <angelo@kernel-space.org>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 01/10] m68k: add DMA global pool config
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 02/10] m68k: add DMA global pool setup Angelo Dureghello
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Add DMA global pool config options.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 arch/m68k/Kconfig.cpu | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 5a58cc13229e..ac09375cadc2 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -33,6 +33,7 @@ config COLDFIRE
 	select GPIOLIB_LEGACY if SPI_COLDFIRE_QSPI
 	select HAVE_LEGACY_CLK
 	select HAVE_PAGE_SIZE_8KB if !MMU
+	select DMA_GLOBAL_POOL if MMU
 
 config SUN3
 	bool "Sun3 machine support"
@@ -304,6 +305,7 @@ config M5441x
 	select COLDFIRE_PIT_TIMER
 	select MMU_COLDFIRE if MMU
 	select HAVE_CACHE_CB
+	select DMA_COHERENT if MMU
 	help
 	  Freescale Coldfire 54410/54415/54416/54417/54418 processor support.
 
@@ -330,6 +332,18 @@ config COLDFIRE_SLTIMERS
 	bool
 	select LEGACY_TIMER_TICK
 
+config DMA_COHERENT
+        bool
+
+config DMA_GLOBAL_POOL_SIZE
+	hex "Global coherent DMA pool size"
+	depends on DMA_GLOBAL_POOL && COLDFIRE
+	default 0x1000000
+	help
+	  Size of the non-cacheable coherent DMA pool carved out from the
+	  top of SDRAM (must be a multiple of 16 MB to match ColdFire ACR
+	  granularity).
+
 endif # COLDFIRE
 
 comment "Processor Specific Options"

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 02/10] m68k: add DMA global pool setup
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 01/10] m68k: add DMA global pool config Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 03/10] m68k: mcf54415: add defines for DMA global pool Angelo Dureghello
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Add DMA global pool setup.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 arch/m68k/coldfire/Makefile |  2 ++
 arch/m68k/coldfire/dma.c    | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/arch/m68k/coldfire/Makefile b/arch/m68k/coldfire/Makefile
index c56bc0dc7f2e..00f646f1c42f 100644
--- a/arch/m68k/coldfire/Makefile
+++ b/arch/m68k/coldfire/Makefile
@@ -35,6 +35,8 @@ obj-$(CONFIG_COLDFIRE_PIT_TIMER) += pit.o
 obj-$(CONFIG_COLDFIRE_TIMERS)	 += timers.o
 obj-$(CONFIG_COLDFIRE_SLTIMERS)	 += sltimers.o
 
+obj-$(CONFIG_DMA_GLOBAL_POOL)    += dma.o
+
 obj-$(CONFIG_NETtel)	+= nettel.o
 obj-$(CONFIG_CLEOPATRA)	+= nettel.o
 obj-$(CONFIG_FIREBEE)	+= firebee.o
diff --git a/arch/m68k/coldfire/dma.c b/arch/m68k/coldfire/dma.c
new file mode 100644
index 000000000000..7c23884d048a
--- /dev/null
+++ b/arch/m68k/coldfire/dma.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * dma.c  -- common ColdFire SoC dma support
+ *
+ * (C) Copyright 2026, Angelo Dureghello <angelo@kernel-space.org>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/dma-map-ops.h>
+#include <linux/init.h>
+#include <linux/sizes.h>
+
+#define DMA_POOL_SIZE		CONFIG_DMA_GLOBAL_POOL_SIZE
+#define DMA_POOL_PHYS_ADDR	(CONFIG_RAMBASE + \
+				 CONFIG_RAMSIZE - DMA_POOL_SIZE)
+
+static int __init coldfire_dma_init(void)
+{
+	if (WARN_ON(!IS_ALIGNED(DMA_POOL_PHYS_ADDR, SZ_16M) ||
+		    !IS_ALIGNED(DMA_POOL_SIZE, SZ_16M)))
+		return -EINVAL;
+
+	return dma_init_global_coherent(DMA_POOL_PHYS_ADDR, DMA_POOL_SIZE);
+}
+
+core_initcall(coldfire_dma_init);
+

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 03/10] m68k: mcf54415: add defines for DMA global pool
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 01/10] m68k: add DMA global pool config Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 02/10] m68k: add DMA global pool setup Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 04/10] m68k: mcf54415: add DMA global pool initialization Angelo Dureghello
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Add ACR4 register configuration to enable a non cacheable area in SDRAM,
to enable DMA global pool on that area.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 arch/m68k/include/asm/m54xxacr.h | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/include/asm/m54xxacr.h b/arch/m68k/include/asm/m54xxacr.h
index 466df7b03c6b..e5e6981d9e2b 100644
--- a/arch/m68k/include/asm/m54xxacr.h
+++ b/arch/m68k/include/asm/m54xxacr.h
@@ -90,6 +90,13 @@
 #define CACHE_INIT (CACR_DCINVA+CACR_BCINVA+CACR_ICINVA)
 
 #if defined(CONFIG_MMU)
+
+#if defined(CONFIG_CACHE_COPYBACK)
+#define ACR_CACHE_MODE	ACR_CM_CP
+#else
+#define ACR_CACHE_MODE	ACR_CM_WT
+#endif
+
 /*
  *	If running with the MMU enabled then we need to map the internal
  *	register region as non-cacheable. And then we map all our RAM as
@@ -97,13 +104,19 @@
  */
 #define ACR0_MODE	(ACR_BA(IOMEMBASE)+ACR_ADMSK(IOMEMSIZE)+ \
 			 ACR_ENABLE+ACR_SUPER+ACR_CM_OFF_PRE+ACR_SP)
-#if defined(CONFIG_CACHE_COPYBACK)
-#define ACR1_MODE	(ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
-			 ACR_ENABLE+ACR_SUPER+ACR_SP+ACR_CM_CP)
+#if defined(CONFIG_DMA_GLOBAL_POOL)
+#define RAM_CACHEABLE	(CONFIG_RAMSIZE-CONFIG_DMA_GLOBAL_POOL_SIZE)
+#define ACR1_MODE	(ACR_BA(CONFIG_RAMBASE+RAM_CACHEABLE)+ \
+			 ACR_ADMSK(CONFIG_DMA_GLOBAL_POOL_SIZE)+ \
+			 ACR_ENABLE+ACR_SUPER+ACR_CM_OFF_PRE+ACR_SP)
+			/* ACR4 (lower priority): full RAM cacheable */
+#define ACR4_MODE	(ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
+			 ACR_ENABLE+ACR_SUPER+ACR_SP+ACR_CACHE_MODE)
 #else
 #define ACR1_MODE	(ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
-			 ACR_ENABLE+ACR_SUPER+ACR_SP+ACR_CM_WT)
+			 ACR_ENABLE+ACR_SUPER+ACR_SP+ACR_CACHE_MODE)
 #endif
+
 #define ACR2_MODE	0
 #define ACR3_MODE	(ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
 			 ACR_ENABLE+ACR_SUPER+ACR_SP)

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/10] m68k: mcf54415: add DMA global pool initialization
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (2 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 03/10] m68k: mcf54415: add defines for DMA global pool Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 05/10] m68K: mcf54415: rename mcf edma clock name Angelo Dureghello
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Add DMA global pool initialization at boot stage for mcf54415, when
configured as MMU enabled.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 arch/m68k/coldfire/head.S   | 5 +++++
 arch/m68k/coldfire/m5441x.c | 7 +++++++
 arch/m68k/mm/kmap.c         | 5 +++++
 3 files changed, 17 insertions(+)

diff --git a/arch/m68k/coldfire/head.S b/arch/m68k/coldfire/head.S
index c6d7fd28c602..415b50ea7b64 100644
--- a/arch/m68k/coldfire/head.S
+++ b/arch/m68k/coldfire/head.S
@@ -197,12 +197,17 @@ _start:
 	movec	%d0,%ACR0
 	movel	#ACR1_MODE,%d0			/* anything else to cache? */
 	movec	%d0,%ACR1
+#ifdef ACR4_MODE
+	movel	#ACR4_MODE,%d0
+	movec	%d0,#0x00c			/* ACR4 */
+#endif
 #ifdef ACR2_MODE
 	movel	#ACR2_MODE,%d0
 	movec	%d0,%ACR2
 	movel	#ACR3_MODE,%d0
 	movec	%d0,%ACR3
 #endif
+
 	movel	#CACHE_MODE,%d0			/* enable cache */
 	movec	%d0,%CACR
 	nop
diff --git a/arch/m68k/coldfire/m5441x.c b/arch/m68k/coldfire/m5441x.c
index dd39ecbf8422..214c634cf057 100644
--- a/arch/m68k/coldfire/m5441x.c
+++ b/arch/m68k/coldfire/m5441x.c
@@ -7,6 +7,7 @@
 
 #include <linux/clkdev.h>
 #include <linux/kernel.h>
+#include <linux/memblock.h>
 #include <linux/param.h>
 #include <linux/init.h>
 #include <linux/io.h>
@@ -269,6 +270,12 @@ arch_initcall(m5441x_rcm_init);
 
 void __init config_BSP(char *commandp, int size)
 {
+#if defined(CONFIG_DMA_GLOBAL_POOL)
+	memblock_reserve(CONFIG_RAMBASE + CONFIG_RAMSIZE -
+			 CONFIG_DMA_GLOBAL_POOL_SIZE,
+			 CONFIG_DMA_GLOBAL_POOL_SIZE);
+#endif
+
 	m5441x_clk_init();
 	mach_sched_init = hw_timer_init;
 	m5441x_uarts_init();
diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index 6167999402b1..b11c25e3d31b 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -188,6 +188,11 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla
 #ifdef CONFIG_COLDFIRE
 	if (__cf_internalio(physaddr))
 		return (void __iomem *) physaddr;
+#ifdef CONFIG_DMA_GLOBAL_POOL
+	if (physaddr >= (CONFIG_RAMBASE + CONFIG_RAMSIZE - CONFIG_DMA_GLOBAL_POOL_SIZE) &&
+	    physaddr < (CONFIG_RAMBASE + CONFIG_RAMSIZE))
+		return (void __iomem *) physaddr;
+#endif
 #endif
 
 #ifdef DEBUG

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 05/10] m68K: mcf54415: rename mcf edma clock name
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (3 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 04/10] m68k: mcf54415: add DMA global pool initialization Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 06/10] m68k: mcf54415: align device name with " Angelo Dureghello
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Rename edma clock name to be consistent with other clock names.

This fix is done together with re-aligning clok<->device name that
follows in the next patch.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 arch/m68k/coldfire/m5441x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/coldfire/m5441x.c b/arch/m68k/coldfire/m5441x.c
index 214c634cf057..1d4296cbb162 100644
--- a/arch/m68k/coldfire/m5441x.c
+++ b/arch/m68k/coldfire/m5441x.c
@@ -25,7 +25,7 @@ DEFINE_CLK(0, "flexcan.0", 8, MCF_CLK);
 DEFINE_CLK(0, "flexcan.1", 9, MCF_CLK);
 DEFINE_CLK(0, "imx1-i2c.1", 14, MCF_CLK);
 DEFINE_CLK(0, "mcfdspi.1", 15, MCF_CLK);
-DEFINE_CLK(0, "edma", 17, MCF_CLK);
+DEFINE_CLK(0, "mcfedma.0", 17, MCF_CLK);
 DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
 DEFINE_CLK(0, "intc.1", 19, MCF_CLK);
 DEFINE_CLK(0, "intc.2", 20, MCF_CLK);
@@ -88,7 +88,7 @@ static struct clk_lookup m5411x_clk_lookup[] = {
 	CLKDEV_INIT("mcfcan.1", NULL, &__clk_0_9),
 	CLKDEV_INIT("imx1-i2c.1", NULL, &__clk_0_14),
 	CLKDEV_INIT("mcfdspi.1", NULL, &__clk_0_15),
-	CLKDEV_INIT("edma", NULL, &__clk_0_17),
+	CLKDEV_INIT("mcfedma.0", NULL, &__clk_0_17),
 	CLKDEV_INIT("intc.0", NULL, &__clk_0_18),
 	CLKDEV_INIT("intc.1", NULL, &__clk_0_19),
 	CLKDEV_INIT("intc.2", NULL, &__clk_0_20),

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 06/10] m68k: mcf54415: align device name with clock name
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (4 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 05/10] m68K: mcf54415: rename mcf edma clock name Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-01 22:40 ` [PATCH 07/10] dmaengine: mcf-edma: enable edma clock Angelo Dureghello
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Align device name with clock name.

To get the clk from the driver probe, device and clock name shall be
aligned.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 arch/m68k/coldfire/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
index f0963d53976c..80ecb5de62dd 100644
--- a/arch/m68k/coldfire/device.c
+++ b/arch/m68k/coldfire/device.c
@@ -542,7 +542,7 @@ static struct resource mcf_edma_resources[] = {
 static u64 mcf_edma_dmamask = DMA_BIT_MASK(32);
 
 static struct platform_device mcf_edma = {
-	.name			= "mcf-edma",
+	.name			= "mcfedma",
 	.id			= 0,
 	.num_resources		= ARRAY_SIZE(mcf_edma_resources),
 	.resource		= mcf_edma_resources,

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 07/10] dmaengine: mcf-edma: enable edma clock
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (5 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 06/10] m68k: mcf54415: align device name with " Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-02 16:54   ` Frank Li
  2026-12-01 22:40 ` [PATCH 08/10] dmaengine: mcf-edma: fix wrong BIT() usage on u64 Angelo Dureghello
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Enable edma clock on probe for ColdFire (mcf) edma.

Actually, the edma clock was default-enable from the ColdFire arch init.
To be sure that module clock is always enabled, whatever defaults are and
could be in the future, enabling it.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 drivers/dma/mcf-edma-main.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
index 4ed0ce644e37..4e46110a2a98 100644
--- a/drivers/dma/mcf-edma-main.c
+++ b/drivers/dma/mcf-edma-main.c
@@ -3,6 +3,7 @@
 // Copyright (c) 2013-2014 Freescale Semiconductor, Inc
 // Copyright (c) 2017 Sysam, Angelo Dureghello  <angelo@sysam.it>
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/dmaengine.h>
@@ -145,7 +146,7 @@ static void mcf_edma_irq_free(struct platform_device *pdev,
 }
 
 static struct fsl_edma_drvdata mcf_data = {
-	.flags = FSL_EDMA_DRV_EDMA64,
+	.flags = FSL_EDMA_DRV_EDMA64 | FSL_EDMA_DRV_HAS_DMACLK,
 	.setup_irq = mcf_edma_irq_init,
 };
 
@@ -186,6 +187,14 @@ static int mcf_edma_probe(struct platform_device *pdev)
 	if (IS_ERR(mcf_edma->membase))
 		return PTR_ERR(mcf_edma->membase);
 
+	if (mcf_edma->drvdata->flags & FSL_EDMA_DRV_HAS_DMACLK) {
+		mcf_edma->dmaclk = devm_clk_get_enabled(&pdev->dev, "edma");
+		if (IS_ERR(mcf_edma->dmaclk))
+			return dev_err_probe(&pdev->dev,
+					     PTR_ERR(mcf_edma->dmaclk),
+					     "Missing DMA block clock.\n");
+	}
+
 	fsl_edma_setup_regs(mcf_edma);
 	regs = &mcf_edma->regs;
 
@@ -262,12 +271,19 @@ static void mcf_edma_remove(struct platform_device *pdev)
 	dma_async_device_unregister(&mcf_edma->dma_dev);
 }
 
+static const struct platform_device_id mcf_edma_ids[] = {
+	{ .name = "mcfedma" },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, mcf_edma_ids);
+
 static struct platform_driver mcf_edma_driver = {
 	.driver		= {
 		.name	= "mcf-edma",
 	},
 	.probe		= mcf_edma_probe,
 	.remove		= mcf_edma_remove,
+	.id_table	= mcf_edma_ids,
 };
 
 bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 08/10] dmaengine: mcf-edma: fix wrong BIT() usage on u64
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (6 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 07/10] dmaengine: mcf-edma: enable edma clock Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-02 16:46   ` Frank Li
  2026-12-01 22:40 ` [PATCH 09/10] dmaengine: mcf-edma: fix wrong error handling Angelo Dureghello
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello,
	Sashiko AI Review

Fix wrong BIT() macro usage on u64.

Reported-by: Sashiko AI Review <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260907134037.1855408-4-gerg@linux-m68k.org?part=1
Fixes: e7a3ff92eaf1 ("dmaengine: fsl-edma: add ColdFire mcf5441x edma support")
Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 drivers/dma/mcf-edma-main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
index 4e46110a2a98..281919f59612 100644
--- a/drivers/dma/mcf-edma-main.c
+++ b/drivers/dma/mcf-edma-main.c
@@ -29,7 +29,7 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
 		return IRQ_NONE;
 
 	for (ch = 0; ch < mcf_edma->n_chans; ch++) {
-		if (intmap & BIT(ch)) {
+		if (intmap & BIT_U64(ch)) {
 			iowrite8(EDMA_MASK_CH(ch), regs->cint);
 			fsl_edma_tx_chan_handler(&mcf_edma->chans[ch]);
 		}

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 09/10] dmaengine: mcf-edma: fix wrong error handling
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (7 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 08/10] dmaengine: mcf-edma: fix wrong BIT() usage on u64 Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-02 16:51   ` Frank Li
  2026-12-01 22:40 ` [PATCH 10/10] dmaengine: fsl-edma: fix missing big-endian swap Angelo Dureghello
  2026-12-02  9:26 ` [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Jean-Michel Hautbois
  10 siblings, 1 reply; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello,
	Sashiko AI Review

Fix wrong error handling on error interrupt.

Reported-by: Sashiko AI Review <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260907134037.1855408-4-gerg@linux-m68k.org?part=1
Fixes: e7a3ff92eaf1 ("dmaengine: fsl-edma: add ColdFire mcf5441x edma support")
Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 drivers/dma/mcf-edma-main.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
index 281919f59612..60940c891409 100644
--- a/drivers/dma/mcf-edma-main.c
+++ b/drivers/dma/mcf-edma-main.c
@@ -42,29 +42,20 @@ static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
 {
 	struct fsl_edma_engine *mcf_edma = dev_id;
 	struct edma_regs *regs = &mcf_edma->regs;
-	unsigned int err, ch;
-
-	err = ioread32be(regs->errl);
-	if (!err)
-		return IRQ_NONE;
-
-	for (ch = 0; ch < (EDMA_CHANNELS / 2); ch++) {
-		if (err & BIT(ch)) {
-			fsl_edma_disable_request(&mcf_edma->chans[ch]);
-			iowrite8(EDMA_CERR_CERR(ch), regs->cerr);
-			fsl_edma_err_chan_handler(&mcf_edma->chans[ch]);
-		}
-	}
+	unsigned int ch;
+	u64 err;
 
 	err = ioread32be(regs->errh);
+	err <<= 32;
+	err |= ioread32be(regs->errl);
 	if (!err)
 		return IRQ_NONE;
 
-	for (ch = (EDMA_CHANNELS / 2); ch < EDMA_CHANNELS; ch++) {
-		if (err & (BIT(ch - (EDMA_CHANNELS / 2)))) {
+	for (ch = 0; ch < EDMA_CHANNELS; ch++) {
+		if (err & BIT_U64(ch)) {
 			fsl_edma_disable_request(&mcf_edma->chans[ch]);
 			iowrite8(EDMA_CERR_CERR(ch), regs->cerr);
-			mcf_edma->chans[ch].status = DMA_ERROR;
+			fsl_edma_err_chan_handler(&mcf_edma->chans[ch]);
 		}
 	}
 

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 10/10] dmaengine: fsl-edma: fix missing big-endian swap
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (8 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 09/10] dmaengine: mcf-edma: fix wrong error handling Angelo Dureghello
@ 2026-12-01 22:40 ` Angelo Dureghello
  2026-12-02 17:05   ` Frank Li
  2026-12-02  9:26 ` [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Jean-Michel Hautbois
  10 siblings, 1 reply; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-01 22:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li
  Cc: linux-m68k, linux-kernel, dmaengine, imx, Angelo Dureghello

Fix missing little-endian to big-endian byte swap for BE CPUs as ColdFire.

Writing CPU iomem hw registers for native BE CPU must happen with bytes
already ordered as big-endian.

Fixes: 3f2282931f00 ("dmaengine: fsl-edma: use _Generic to handle difference type")
Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 drivers/dma/fsl-edma-common.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h
index cbb077e98f55..7e82b0aabc6d 100644
--- a/drivers/dma/fsl-edma-common.h
+++ b/drivers/dma/fsl-edma-common.h
@@ -296,9 +296,9 @@ _Generic(((_tcd)->__name),						\
 
 #define edma_write_tcdreg_c(chan, _tcd, _val, __name)					\
 _Generic((_tcd->__name),								\
-	__iomem __le64 : edma_writeq(chan->edma, (u64 __force)(_val), &_tcd->__name),	\
-	__iomem __le32 : edma_writel(chan->edma, (u32 __force)(_val), &_tcd->__name),	\
-	__iomem __le16 : edma_writew(chan->edma, (u16 __force)(_val), &_tcd->__name),	\
+	__iomem __le64 : edma_writeq(chan->edma, le64_to_cpu(_val), &_tcd->__name),	\
+	__iomem __le32 : edma_writel(chan->edma, le32_to_cpu(_val), &_tcd->__name),	\
+	__iomem __le16 : edma_writew(chan->edma, le16_to_cpu(_val), &_tcd->__name),	\
 	__iomem u8 : edma_writeb(chan->edma, _val, &_tcd->__name)			\
 	)
 

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues
  2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
                   ` (9 preceding siblings ...)
  2026-12-01 22:40 ` [PATCH 10/10] dmaengine: fsl-edma: fix missing big-endian swap Angelo Dureghello
@ 2026-12-02  9:26 ` Jean-Michel Hautbois
  2026-12-02 12:12   ` Angelo Dureghello
  10 siblings, 1 reply; 18+ messages in thread
From: Jean-Michel Hautbois @ 2026-12-02  9:26 UTC (permalink / raw)
  To: Angelo Dureghello
  Cc: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li, Frank Li,
	linux-m68k, linux-kernel, dmaengine, imx

Hi Angelo,

Thanks for picking this up, and sorry for leaving your September question on my global pool thread[1] unanswered.

Part of this series overlaps with work I posted earlier, so here are the links for reviewers.

Patches 1 to 4 follow what Christoph suggested on that thread: DMA_GLOBAL_POOL filled with dma_init_global_coherent(), rather than arch dma_map_ops. The ACR window that keeps the pool out of the cache is the part I never got right, and I am glad to see it.

Patches 8 and 9 fix the same bugs as 3/5 and 4/5 of my dmaengine v3[2], which Frank reviewed in June. I never sent the v4, my fault again.

On patch 9, one detail differs. The loop still clears the error with EDMA_CERR_CERR(ch), which masks with GENMASK(4, 0). EDMA_CERR takes a 6-bit channel number (MCF54418RM, Table 19-13), so for channels 32 to 63 the write clears the flag of channel (ch & 31) and leaves the real one set. My 4/5 used EDMA_MASK_CH(ch) for that reason.

How would you like to proceed? I can rebase my 3/5 and 4/5 on top of Greg's readX()/writeX() patch and send them as v4, or you can carry them in your series with their tags, whichever is simpler for you and Vinod.

[1] https://lore.kernel.org/all/20250121-coldfire-global-pool-v1-0-382a7235c2aa@yoseli.org
[2] https://lore.kernel.org/all/20260625-b4-edma-dmaengine-v3-0-44be00ace37d@yoseli.org

Thanks,
JM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues
  2026-12-02  9:26 ` [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Jean-Michel Hautbois
@ 2026-12-02 12:12   ` Angelo Dureghello
  2026-12-02 12:53     ` Jean-Michel Hautbois
  0 siblings, 1 reply; 18+ messages in thread
From: Angelo Dureghello @ 2026-12-02 12:12 UTC (permalink / raw)
  To: Jean-Michel Hautbois, Greg Ungerer, Frank Li
  Cc: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li, Frank Li,
	linux-m68k, linux-kernel, dmaengine, imx

Hi Jean-Michel,

regarding dma pool, i contacted you 2 times, personally (june 2026) and on
the m68k list, with no answers, was not clear if you wanted to go on with
this. I was anyway blocked so had someway to go on to fix edma and dspi,
depending on global pool.

Just to be clear, DMA pool and all that is in this patchset is
written from scratch, not looking on your job at all.
I did it from scratch to understand this global pool area and being able to
fix edma, i can keep it locally.

About edma, i missed there was something ongoiung on edma too from your
side, sorry for that.

I have no much time now a day except late evening for some development
so cannot guarantee any collaboration. Also losing some enthusiasm to be
honest.

@Frank Li,
edma driver is actually broken due mainly to the issue i pointed in patch 
10/10. Please have a look, an endian swap was missing there. 
Please disregard all the rest since there are some overlappings with Jean
patches that i missed.
You can keep patch 10/10 if you want.

To Greg: please disregard the patchset fully, don't want to overlap on any
Jean-Micheal job. Just know that your readX/writeX is ok for me, fix you
did on dspi and edma are working,
but the fix in 10/10 is needed in edma, unless i missed any recent fix
(not rebased from some days). 

Regards,
angelo 


On 12/2/26 10:26, Jean-Michel Hautbois wrote:
> Hi Angelo,
> 
> Thanks for picking this up, and sorry for leaving your September question on my global pool thread[1] unanswered.
> 
> Part of this series overlaps with work I posted earlier, so here are the links for reviewers.
> 
> Patches 1 to 4 follow what Christoph suggested on that thread: DMA_GLOBAL_POOL filled with dma_init_global_coherent(), rather than arch dma_map_ops. The ACR window that keeps the pool out of the cache is the part I never got right, and I am glad to see it.
> 
> Patches 8 and 9 fix the same bugs as 3/5 and 4/5 of my dmaengine v3[2], which Frank reviewed in June. I never sent the v4, my fault again.
> 
> On patch 9, one detail differs. The loop still clears the error with EDMA_CERR_CERR(ch), which masks with GENMASK(4, 0). EDMA_CERR takes a 6-bit channel number (MCF54418RM, Table 19-13), so for channels 32 to 63 the write clears the flag of channel (ch & 31) and leaves the real one set. My 4/5 used EDMA_MASK_CH(ch) for that reason.
> 
> How would you like to proceed? I can rebase my 3/5 and 4/5 on top of Greg's readX()/writeX() patch and send them as v4, or you can carry them in your series with their tags, whichever is simpler for you and Vinod.
> 
> [1] https://lore.kernel.org/all/20250121-coldfire-global-pool-v1-0-382a7235c2aa@yoseli.org
> [2] https://lore.kernel.org/all/20260625-b4-edma-dmaengine-v3-0-44be00ace37d@yoseli.org
> 
> Thanks,
> JM

-- Angelo


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues
  2026-12-02 12:12   ` Angelo Dureghello
@ 2026-12-02 12:53     ` Jean-Michel Hautbois
  0 siblings, 0 replies; 18+ messages in thread
From: Jean-Michel Hautbois @ 2026-12-02 12:53 UTC (permalink / raw)
  To: Angelo Dureghello, Greg Ungerer, Frank Li
  Cc: Geert Uytterhoeven, Vinod Koul, Frank Li, linux-m68k,
	linux-kernel, dmaengine, imx

Hi Angelo,

Le 02/12/2026 à 13:12, Angelo Dureghello a écrit :
> Hi Jean-Michel,
> 
> regarding dma pool, i contacted you 2 times, personally (june 2026) and on
> the m68k list, with no answers, was not clear if you wanted to go on with
> this. I was anyway blocked so had someway to go on to fix edma and dspi,
> depending on global pool.

You are right, and I owe you a proper apology. You asked twice and I 
never answered. I simply did not have the time, which does not excuse 
leaving you without a word.

> 
> Just to be clear, DMA pool and all that is in this patchset is
> written from scratch, not looking on your job at all.
> I did it from scratch to understand this global pool area and being able to
> fix edma, i can keep it locally.

I never doubted it, and I am sorry my previous mail read as a claim on 
your work. The links were only there for the history. Your ACR window is 
precisely the piece my attempt was missing.

<snip>


> To Greg: please disregard the patchset fully, don't want to overlap on any
> Jean-Micheal job. Just know that your readX/writeX is ok for me, fix you
> did on dspi and edma are working,
> but the fix in 10/10 is needed in edma, unless i missed any recent fix
> (not rebased from some days).


Please don't withdraw it on my account. You have the hardware, and DMA 
on ColdFire stays broken upstream until something like your series goes in.

Greg, I would rather see Angelo's series move forward than mine.

For patches 8 and 9, keep them with EDMA_MASK_CH() in 9. I will drop my 
v3 so that reviewers only have one version to look at, and once your 
series is in, I will rebase what is left of it on top.

Thanks for all the work on ColdFire,
JM


> Regards,
> angelo
> 
> 
> On 12/2/26 10:26, Jean-Michel Hautbois wrote:
>> Hi Angelo,
>>
>> Thanks for picking this up, and sorry for leaving your September question on my global pool thread[1] unanswered.
>>
>> Part of this series overlaps with work I posted earlier, so here are the links for reviewers.
>>
>> Patches 1 to 4 follow what Christoph suggested on that thread: DMA_GLOBAL_POOL filled with dma_init_global_coherent(), rather than arch dma_map_ops. The ACR window that keeps the pool out of the cache is the part I never got right, and I am glad to see it.
>>
>> Patches 8 and 9 fix the same bugs as 3/5 and 4/5 of my dmaengine v3[2], which Frank reviewed in June. I never sent the v4, my fault again.
>>
>> On patch 9, one detail differs. The loop still clears the error with EDMA_CERR_CERR(ch), which masks with GENMASK(4, 0). EDMA_CERR takes a 6-bit channel number (MCF54418RM, Table 19-13), so for channels 32 to 63 the write clears the flag of channel (ch & 31) and leaves the real one set. My 4/5 used EDMA_MASK_CH(ch) for that reason.
>>
>> How would you like to proceed? I can rebase my 3/5 and 4/5 on top of Greg's readX()/writeX() patch and send them as v4, or you can carry them in your series with their tags, whichever is simpler for you and Vinod.
>>
>> [1] https://lore.kernel.org/all/20250121-coldfire-global-pool-v1-0-382a7235c2aa@yoseli.org
>> [2] https://lore.kernel.org/all/20260625-b4-edma-dmaengine-v3-0-44be00ace37d@yoseli.org
>>
>> Thanks,
>> JM
> 
> -- Angelo
> 


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 08/10] dmaengine: mcf-edma: fix wrong BIT() usage on u64
  2026-12-01 22:40 ` [PATCH 08/10] dmaengine: mcf-edma: fix wrong BIT() usage on u64 Angelo Dureghello
@ 2026-12-02 16:46   ` Frank Li
  0 siblings, 0 replies; 18+ messages in thread
From: Frank Li @ 2026-12-02 16:46 UTC (permalink / raw)
  To: Angelo Dureghello
  Cc: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li, linux-m68k, linux-kernel, dmaengine,
	imx, Sashiko AI Review

On Tue, Dec 01, 2026 at 11:40:19PM +0100, Angelo Dureghello wrote:
> [You don't often get email from angelo@kernel-space.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Fix wrong BIT() macro usage on u64.
>
> Reported-by: Sashiko AI Review <sashiko-bot@kernel.org>
> Link: https://sashiko.dev/#/patchset/20260907134037.1855408-4-gerg@linux-m68k.org?part=1
> Fixes: e7a3ff92eaf1 ("dmaengine: fsl-edma: add ColdFire mcf5441x edma support")
> Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/mcf-edma-main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
> index 4e46110a2a98..281919f59612 100644
> --- a/drivers/dma/mcf-edma-main.c
> +++ b/drivers/dma/mcf-edma-main.c
> @@ -29,7 +29,7 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
>                 return IRQ_NONE;
>
>         for (ch = 0; ch < mcf_edma->n_chans; ch++) {
> -               if (intmap & BIT(ch)) {
> +               if (intmap & BIT_U64(ch)) {
>                         iowrite8(EDMA_MASK_CH(ch), regs->cint);
>                         fsl_edma_tx_chan_handler(&mcf_edma->chans[ch]);
>                 }
>
> --
> 2.56.1
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/10] dmaengine: mcf-edma: fix wrong error handling
  2026-12-01 22:40 ` [PATCH 09/10] dmaengine: mcf-edma: fix wrong error handling Angelo Dureghello
@ 2026-12-02 16:51   ` Frank Li
  0 siblings, 0 replies; 18+ messages in thread
From: Frank Li @ 2026-12-02 16:51 UTC (permalink / raw)
  To: Angelo Dureghello
  Cc: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li, linux-m68k, linux-kernel, dmaengine,
	imx, Sashiko AI Review

On Tue, Dec 01, 2026 at 11:40:20PM +0100, Angelo Dureghello wrote:
> [You don't often get email from angelo@kernel-space.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Fix wrong error handling on error interrupt.

can you talk a little more detail. such as previous code miss check high
32 bit channel. Fix it by add check errh beside errl.

Frank


>
> Reported-by: Sashiko AI Review <sashiko-bot@kernel.org>
> Link: https://sashiko.dev/#/patchset/20260907134037.1855408-4-gerg@linux-m68k.org?part=1
> Fixes: e7a3ff92eaf1 ("dmaengine: fsl-edma: add ColdFire mcf5441x edma support")
> Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
> ---
>  drivers/dma/mcf-edma-main.c | 23 +++++++----------------
>  1 file changed, 7 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
> index 281919f59612..60940c891409 100644
> --- a/drivers/dma/mcf-edma-main.c
> +++ b/drivers/dma/mcf-edma-main.c
> @@ -42,29 +42,20 @@ static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
>  {
>         struct fsl_edma_engine *mcf_edma = dev_id;
>         struct edma_regs *regs = &mcf_edma->regs;
> -       unsigned int err, ch;
> -
> -       err = ioread32be(regs->errl);
> -       if (!err)
> -               return IRQ_NONE;
> -
> -       for (ch = 0; ch < (EDMA_CHANNELS / 2); ch++) {
> -               if (err & BIT(ch)) {
> -                       fsl_edma_disable_request(&mcf_edma->chans[ch]);
> -                       iowrite8(EDMA_CERR_CERR(ch), regs->cerr);
> -                       fsl_edma_err_chan_handler(&mcf_edma->chans[ch]);
> -               }
> -       }
> +       unsigned int ch;
> +       u64 err;
>
>         err = ioread32be(regs->errh);
> +       err <<= 32;
> +       err |= ioread32be(regs->errl);
>         if (!err)
>                 return IRQ_NONE;
>
> -       for (ch = (EDMA_CHANNELS / 2); ch < EDMA_CHANNELS; ch++) {
> -               if (err & (BIT(ch - (EDMA_CHANNELS / 2)))) {
> +       for (ch = 0; ch < EDMA_CHANNELS; ch++) {
> +               if (err & BIT_U64(ch)) {
>                         fsl_edma_disable_request(&mcf_edma->chans[ch]);
>                         iowrite8(EDMA_CERR_CERR(ch), regs->cerr);
> -                       mcf_edma->chans[ch].status = DMA_ERROR;
> +                       fsl_edma_err_chan_handler(&mcf_edma->chans[ch]);
>                 }
>         }
>
>
> --
> 2.56.1
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 07/10] dmaengine: mcf-edma: enable edma clock
  2026-12-01 22:40 ` [PATCH 07/10] dmaengine: mcf-edma: enable edma clock Angelo Dureghello
@ 2026-12-02 16:54   ` Frank Li
  0 siblings, 0 replies; 18+ messages in thread
From: Frank Li @ 2026-12-02 16:54 UTC (permalink / raw)
  To: Angelo Dureghello
  Cc: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li, linux-m68k, linux-kernel, dmaengine,
	imx

On Tue, Dec 01, 2026 at 11:40:18PM +0100, Angelo Dureghello wrote:
> [You don't often get email from angelo@kernel-space.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Enable edma clock on probe for ColdFire (mcf) edma.
>
> Actually, the edma clock was default-enable from the ColdFire arch init.
> To be sure that module clock is always enabled, whatever defaults are and
> could be in the future, enabling it.
>
> Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
> ---
>  drivers/dma/mcf-edma-main.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
> index 4ed0ce644e37..4e46110a2a98 100644
> --- a/drivers/dma/mcf-edma-main.c
> +++ b/drivers/dma/mcf-edma-main.c
> @@ -3,6 +3,7 @@
>  // Copyright (c) 2013-2014 Freescale Semiconductor, Inc
>  // Copyright (c) 2017 Sysam, Angelo Dureghello  <angelo@sysam.it>
>
> +#include <linux/clk.h>
>  #include <linux/module.h>
>  #include <linux/interrupt.h>
>  #include <linux/dmaengine.h>
> @@ -145,7 +146,7 @@ static void mcf_edma_irq_free(struct platform_device *pdev,
>  }
>
>  static struct fsl_edma_drvdata mcf_data = {
> -       .flags = FSL_EDMA_DRV_EDMA64,
> +       .flags = FSL_EDMA_DRV_EDMA64 | FSL_EDMA_DRV_HAS_DMACLK,
>         .setup_irq = mcf_edma_irq_init,
>  };
>
> @@ -186,6 +187,14 @@ static int mcf_edma_probe(struct platform_device *pdev)
>         if (IS_ERR(mcf_edma->membase))
>                 return PTR_ERR(mcf_edma->membase);
>
> +       if (mcf_edma->drvdata->flags & FSL_EDMA_DRV_HAS_DMACLK) {
> +               mcf_edma->dmaclk = devm_clk_get_enabled(&pdev->dev, "edma");

now prefer use devm_clk_get_optional_enable() without check flag
FSL_EDMA_DRV_HAS_DMACLK

> +               if (IS_ERR(mcf_edma->dmaclk))
> +                       return dev_err_probe(&pdev->dev,
> +                                            PTR_ERR(mcf_edma->dmaclk),
> +                                            "Missing DMA block clock.\n");
> +       }
> +
>         fsl_edma_setup_regs(mcf_edma);
>         regs = &mcf_edma->regs;
>
> @@ -262,12 +271,19 @@ static void mcf_edma_remove(struct platform_device *pdev)
>         dma_async_device_unregister(&mcf_edma->dma_dev);
>  }
>
> +static const struct platform_device_id mcf_edma_ids[] = {
> +       { .name = "mcfedma" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(platform, mcf_edma_ids);
> +

this part use seperate patch to fix it.

Frank
>  static struct platform_driver mcf_edma_driver = {
>         .driver         = {
>                 .name   = "mcf-edma",
>         },
>         .probe          = mcf_edma_probe,
>         .remove         = mcf_edma_remove,
> +       .id_table       = mcf_edma_ids,
>  };
>
>  bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
>
> --
> 2.56.1
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 10/10] dmaengine: fsl-edma: fix missing big-endian swap
  2026-12-01 22:40 ` [PATCH 10/10] dmaengine: fsl-edma: fix missing big-endian swap Angelo Dureghello
@ 2026-12-02 17:05   ` Frank Li
  0 siblings, 0 replies; 18+ messages in thread
From: Frank Li @ 2026-12-02 17:05 UTC (permalink / raw)
  To: Angelo Dureghello
  Cc: Geert Uytterhoeven, Greg Ungerer, Vinod Koul, Frank Li,
	Angelo Dureghello, Frank Li, linux-m68k, linux-kernel, dmaengine,
	imx

On Tue, Dec 01, 2026 at 11:40:21PM +0100, Angelo Dureghello wrote:
> [You don't often get email from angelo@kernel-space.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Fix missing little-endian to big-endian byte swap for BE CPUs as ColdFire.
>
> Writing CPU iomem hw registers for native BE CPU must happen with bytes
> already ordered as big-endian.
>
> Fixes: 3f2282931f00 ("dmaengine: fsl-edma: use _Generic to handle difference type")
> Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/fsl-edma-common.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h
> index cbb077e98f55..7e82b0aabc6d 100644
> --- a/drivers/dma/fsl-edma-common.h
> +++ b/drivers/dma/fsl-edma-common.h
> @@ -296,9 +296,9 @@ _Generic(((_tcd)->__name),                                          \
>
>  #define edma_write_tcdreg_c(chan, _tcd, _val, __name)                                  \
>  _Generic((_tcd->__name),                                                               \
> -       __iomem __le64 : edma_writeq(chan->edma, (u64 __force)(_val), &_tcd->__name),   \
> -       __iomem __le32 : edma_writel(chan->edma, (u32 __force)(_val), &_tcd->__name),   \
> -       __iomem __le16 : edma_writew(chan->edma, (u16 __force)(_val), &_tcd->__name),   \
> +       __iomem __le64 : edma_writeq(chan->edma, le64_to_cpu(_val), &_tcd->__name),     \
> +       __iomem __le32 : edma_writel(chan->edma, le32_to_cpu(_val), &_tcd->__name),     \
> +       __iomem __le16 : edma_writew(chan->edma, le16_to_cpu(_val), &_tcd->__name),     \
>         __iomem u8 : edma_writeb(chan->edma, _val, &_tcd->__name)                       \
>         )
>
>
> --
> 2.56.1
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-12-02 17:05 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 22:40 [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Angelo Dureghello
2026-12-01 22:40 ` [PATCH 01/10] m68k: add DMA global pool config Angelo Dureghello
2026-12-01 22:40 ` [PATCH 02/10] m68k: add DMA global pool setup Angelo Dureghello
2026-12-01 22:40 ` [PATCH 03/10] m68k: mcf54415: add defines for DMA global pool Angelo Dureghello
2026-12-01 22:40 ` [PATCH 04/10] m68k: mcf54415: add DMA global pool initialization Angelo Dureghello
2026-12-01 22:40 ` [PATCH 05/10] m68K: mcf54415: rename mcf edma clock name Angelo Dureghello
2026-12-01 22:40 ` [PATCH 06/10] m68k: mcf54415: align device name with " Angelo Dureghello
2026-12-01 22:40 ` [PATCH 07/10] dmaengine: mcf-edma: enable edma clock Angelo Dureghello
2026-12-02 16:54   ` Frank Li
2026-12-01 22:40 ` [PATCH 08/10] dmaengine: mcf-edma: fix wrong BIT() usage on u64 Angelo Dureghello
2026-12-02 16:46   ` Frank Li
2026-12-01 22:40 ` [PATCH 09/10] dmaengine: mcf-edma: fix wrong error handling Angelo Dureghello
2026-12-02 16:51   ` Frank Li
2026-12-01 22:40 ` [PATCH 10/10] dmaengine: fsl-edma: fix missing big-endian swap Angelo Dureghello
2026-12-02 17:05   ` Frank Li
2026-12-02  9:26 ` [PATCH 00/10] m68k: mcf54415: fix ColdFire edma-related issues Jean-Michel Hautbois
2026-12-02 12:12   ` Angelo Dureghello
2026-12-02 12:53     ` Jean-Michel Hautbois

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox