mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] spi: mvebu: move timekeeping out of hot path
@ 2025-09-10  5:42 Steffen Trumtrar
  0 siblings, 0 replies; only message in thread
From: Steffen Trumtrar @ 2025-09-10  5:42 UTC (permalink / raw)
  To: barebox, Sascha Hauer; +Cc: Steffen Trumtrar

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.trumtrar@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.trumtrar@pengutronix.de>




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-10  5:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-10  5:42 [PATCH] spi: mvebu: move timekeeping out of hot path Steffen Trumtrar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox