arm64: mm: Treat all devices as dma-coherent when CLIDR_EL1.LoC == 0
authorWill Deacon <will@kernel.org>
Thu, 23 Jul 2026 13:03:21 +0000 (14:03 +0100)
committerWill Deacon <will@kernel.org>
Sun, 2 Aug 2026 09:16:39 +0000 (09:16 +0000)
On systems where CLIDR_EL1.LoC == 0, no cache maintenance is required
when cleaning or invalidating to the Point of Coherency and therefore
all DMA agents can be treated as coherent.

Extend arch_setup_dma_ops() to take CLIDR_EL1.LoC into account when
setting the DMA ops for a device, emitting a warning message if the
firmware advertises a non-coherent device on a fully coherent system.

Cc: Steffen Eiden <seiden@linux.ibm.com>
Cc: Andreas Grapentin <gra@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/mm/dma-mapping.c

index 994b7b3..7f6f2f4 100644 (file)
@@ -42,6 +42,11 @@ void arch_setup_dma_ops(struct device *dev, bool coherent)
 {
        int cls = cache_line_size_of_cpu();
 
+       if (!coherent && !CLIDR_LOC(read_sysreg(clidr_el1))) {
+               dev_warn(dev, "CLIDR_EL1.LoC == 0, treating as coherent\n");
+               coherent = true;
+       }
+
        WARN_TAINT(!coherent && cls > ARCH_DMA_MINALIGN,
                   TAINT_CPU_OUT_OF_SPEC,
                   "%s %s: ARCH_DMA_MINALIGN smaller than CTR_EL0.CWG (%d < %d)",