Skip to contentSkip to conversation

arm64: mm: Treat all devices as dma-coherent when CLIDR_EL1.LoC == 0

PATCH Applied Will Deacon 1 participant 2 messages Jul 23 – Aug 2 arm64

lore
Share & tools
lore

Will Deacon

author maintainer
#0 lore raw

PATCH 1/1 arm64: mm: Treat all devices as dma-coherent when CLIDR_EL1.LoC == 0

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 <[email protected]>
Cc Andreas Grapentin <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/mm/dma-mapping.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/mm/dma-mapping.c +5 -0
index 994b7b36e2b9..7f6f2f40dba2 100644
@@ -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)",
Signature · 1 line
2.55.0.229.g6434b31f56-goog
author maintainer Applied
#1 lore raw
Quoted 9 lines · Will Deacon

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.

[...]

Applied to arm64 (for-next/mm), thanks!

[1/1] arm64: mm: Treat all devices as dma-coherent when CLIDR_EL1.LoC == 0

      https://git.kernel.org/arm64/c/233b5554e07b

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev