[PATCH] m68k: fix dma allocation for ColdFire with mmu

From: Angelo Dureghello

Date: Mon May 25 2026 - 00:05:27 EST


From: Angelo Dureghello <adureghello@xxxxxxxxxxxx>

This patch fixes the following issue on mcf54415:

[ 2.270000] fsl-dspi fsl-dspi.0: Not able to get desc for DMA xfer
[ 2.280000] fsl-dspi fsl-dspi.0: DMA transfer failed
[ 2.280000] spi_master spi0: failed to transfer one message from queue
[ 2.290000] spi_master spi0: noqueue transfer failed
[ 2.290000] spi-nor spi0.1: probe with driver spi-nor failed with error -5

related to mcf-edma and spi-fsl-dspi drivers (dspi is using edma), visible
after the commit listed below.

The mmu available on some evoluted ColdFire SoCs as mcf54415 allows to
have a coherent dma allocation, so modify code accordingly.

Fixes: 7a360df941a4 ("m68k: don't provide arch_dma_alloc for nommu/coldfire")
Signed-off-by: Angelo Dureghello <adureghello@xxxxxxxxxxxx>
---
arch/m68k/Kconfig | 4 ++--
arch/m68k/kernel/dma.c | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 11835eb59d94..edbf6bc9c55a 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -7,7 +7,7 @@ config M68K
select ARCH_HAS_CPU_CACHE_ALIASING
select ARCH_HAS_CPU_FINALIZE_INIT if MMU
select ARCH_HAS_CURRENT_STACK_POINTER
- select ARCH_HAS_DMA_PREP_COHERENT if M68K_NONCOHERENT_DMA && !COLDFIRE
+ select ARCH_HAS_DMA_PREP_COHERENT if M68K_NONCOHERENT_DMA && (!COLDFIRE || MMU)
select ARCH_HAS_SYNC_DMA_FOR_DEVICE if M68K_NONCOHERENT_DMA
select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
@@ -15,7 +15,7 @@ config M68K
select ARCH_USE_MEMTEST if MMU_MOTOROLA
select ARCH_WANT_IPC_PARSE_VERSION
select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
- select DMA_DIRECT_REMAP if M68K_NONCOHERENT_DMA && !COLDFIRE
+ select DMA_DIRECT_REMAP if M68K_NONCOHERENT_DMA && (!COLDFIRE || MMU)
select GENERIC_ATOMIC64
select GENERIC_CPU_DEVICES
select GENERIC_IOMAP if HAS_IOPORT && MMU && !COLDFIRE
diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
index 16063783aa80..59233ebe3a63 100644
--- a/arch/m68k/kernel/dma.c
+++ b/arch/m68k/kernel/dma.c
@@ -8,12 +8,14 @@
#include <linux/kernel.h>
#include <asm/cacheflush.h>

-#ifndef CONFIG_COLDFIRE
+#ifdef CONFIG_MMU
void arch_dma_prep_coherent(struct page *page, size_t size)
{
cache_push(page_to_phys(page), size);
}
+#endif

+#ifndef CONFIG_COLDFIRE
pgprot_t pgprot_dmacoherent(pgprot_t prot)
{
if (CPU_IS_040_OR_060) {
@@ -24,7 +26,7 @@ pgprot_t pgprot_dmacoherent(pgprot_t prot)
}
return prot;
}
-#endif /* CONFIG_MMU && !CONFIG_COLDFIRE */
+#endif /* !CONFIG_COLDFIRE */

void arch_sync_dma_for_device(phys_addr_t handle, size_t size,
enum dma_data_direction dir)

---
base-commit: cf72ff0dc9ecc711965604b4241314454d1f9ff3
change-id: 20260525-wip-bl-mcf-edma-7b402ae2f3f8

Best regards,
--
Angelo Dureghello <adureghello@xxxxxxxxxxxx>