The wait_on_timeout uses get_time_ns for timekeeping. It seems that this
considerably decreases transfer speeds, because the wait_on_timeout loop
gets throttled by the timekeeping.
Moving the timekeeping after the hot path results in ~3x transfer speed.
Keep the wait_on_timeout after the hot path to be sure, that the code
nevertheless waits long enough once.

Signed-off-by: Steffen Trumtrar <s.trumt...@pengutronix.de>
---
 drivers/spi/mvebu_spi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/mvebu_spi.c b/drivers/spi/mvebu_spi.c
index 
e220d1f9eeafedd9b2073638ee4fb94e29ff292a..554b73a0936aa0c5fee766714ed8510ba64808ae
 100644
--- a/drivers/spi/mvebu_spi.c
+++ b/drivers/spi/mvebu_spi.c
@@ -238,11 +238,15 @@ static int mvebu_spi_setup(struct spi_device *spi)
 
 static inline int mvebu_spi_wait_for_read_ready(struct mvebu_spi *p)
 {
-       int ret;
+       int timeout = 10000;
 
-       ret = wait_on_timeout(100 * USECOND,
-                             readl(p->base + SPI_IF_CTRL) & IF_READ_READY);
-       return ret;
+       while (!(readl(p->base + SPI_IF_CTRL) & IF_READ_READY) && timeout--)
+               ;
+       if (timeout)
+               return 0;
+
+       return wait_on_timeout(100 * USECOND,
+                               readl(p->base + SPI_IF_CTRL) & IF_READ_READY);
 }
 
 static int mvebu_spi_do_transfer(struct spi_device *spi,

---
base-commit: 4d59215c346398971f1b09824aed6505b771df99
change-id: 20250910-v2025-08-0-topic-mvebu-spi-7a1270d501a8

Best regards,
-- 
Steffen Trumtrar <s.trumt...@pengutronix.de>


Reply via email to