Skip to contentSkip to conversation

ata: pata_ep93xx: add missing "cc" and "memory" clobbers to inline asm

PATCH Superseded Rosen Penev 1 participant 1 message Jul 23 libata

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ata: pata_ep93xx: add missing "cc" and "memory" clobbers to inline asm

The inline assembly in ep93xx_pata_delay() uses a "subs" instruction which modifies the ARM condition code flags. Add a "cc" clobber so the compiler knows the flags are altered. Without it, the compiler may reorder flag-dependent instructions across the asm block when the function is inlined, potentially causing incorrect control flow.

Additionally, add a "memory" clobber to prevent the compiler from reordering I/O accesses across this delay loop. On older ARM architectures like ARMv4T used in EP93xx, __iormb()/__iowmb() may evaluate to empty when CONFIG_ARM_DMA_MEM_BUFFERABLE is not set, leaving writel()/readl() without a compiler memory barrier. Without a "memory" clobber here, the compiler optimizer might reorder independent I/O accesses across the delay, violating ATA PIO timing requirements. This also brings the ARM path in line with the non-ARM fallback which uses cpu_relax() (a compiler barrier).

Fixes 2fff27512600 ("PATA host controller driver for ep93xx")
Assisted-by Opencode:Big-Pickle

---
v2: add memory barrier

 drivers/ata/pata_ep93xx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ata/pata_ep93xx.c +1 -0
index be8a314654e6..085f1e8e5343 100644
@@ -211,6 +211,7 @@ static void ep93xx_pata_delay(unsigned long count)
 		"bge 0b\n"
 		: "=r" (count)
 		: "0" (count)
+		: "cc", "memory"
 	);
 #else
 	while (count--)
Signature · 1 line
2.55.0