Skip to contentSkip to conversation

drivers: cadence_qspi_apb: Add 1us delays in polling loops

PATCH In review Boon Khai Ng 2 participants 3 messages Mar 12 – Apr 15 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: cadence_qspi_apb: Add 1us delays in polling loops

Add 1us delays in busy-wait polling loops to reduce CPU usage, minimize bus traffic, and prevent watchdog timeout during QSPI operations.

Three tight polling loops continuously check hardware status without any delay, consuming excessive CPU cycles and potentially triggering watchdog timeout on long operations. Adding small delays allows the hardware time to respond and reduces unnecessary register reads.

The udelay() function includes WATCHDOG_RESET()/schedule() calls that service the watchdog, preventing system reset during extended QSPI transfers.

---
 drivers/spi/cadence_qspi_apb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/cadence_qspi_apb.c +3 -0
index 0d4bc685f5d..ef03b263e14 100644
@@ -157,6 +157,7 @@ static unsigned int cadence_qspi_wait_idle(void *reg_base)
 
 	start = get_timer(0);
 	for ( ; get_timer(start) < timeout ; ) {
+		udelay(1);
 		if (CQSPI_REG_IS_IDLE(reg_base))
 			count++;
 		else
@@ -728,6 +729,7 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_priv *priv,
 			rxbuf += bytes_to_read;
 			remaining -= bytes_to_read;
 			bytes_to_read = cadence_qspi_get_rd_sram_level(priv);
+			udelay(1);
 		}
 	}
 
@@ -898,6 +900,7 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv,
 
 		bb_txbuf += write_bytes;
 		remaining -= write_bytes;
+		udelay(1);
 	}
 
 	/* Check indirect done status */
Signature · 1 line
2.43.7
#1 lore raw
Quoted 8 lines · Boon Khai Ng

Add 1us delays in busy-wait polling loops to reduce CPU usage, minimize bus traffic, and prevent watchdog timeout during QSPI operations.

Three tight polling loops continuously check hardware status without any delay, consuming excessive CPU cycles and potentially triggering watchdog timeout on long operations. Adding small delays allows the hardware time to respond and reduces unnecessary register reads.

Quoted 8 lines

The udelay() function includes WATCHDOG_RESET()/schedule() calls that service the watchdog, preventing system reset during extended QSPI transfers.

---
 drivers/spi/cadence_qspi_apb.c | 3 +++
 1 file changed, 3 insertions(+)

This introduces a failure to build on socfpga_vining_fpga

Signature · 1 line
Tom
#2 lore raw
In reply to Boon Khai Ng
Quoted 8 lines · Boon Khai Ng

Add 1us delays in busy-wait polling loops to reduce CPU usage, minimize bus traffic, and prevent watchdog timeout during QSPI operations.

Three tight polling loops continuously check hardware status without any delay, consuming excessive CPU cycles and potentially triggering watchdog timeout on long operations. Adding small delays allows the hardware time to respond and reduces unnecessary register reads.

Quoted 8 lines

The udelay() function includes WATCHDOG_RESET()/schedule() calls that service the watchdog, preventing system reset during extended QSPI transfers.

---
 drivers/spi/cadence_qspi_apb.c | 3 +++
 1 file changed, 3 insertions(+)

So, this is fine, BUT it pushes socfpga_vining_fpga over the size limit. And I see SoCFPGA isn't enabling LTO at all. Can you please get that tested on at least some SoCFPGA platforms and then enable it for all? Then we can continue down this path, thanks!

Signature · 1 line
Tom