From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org, Sascha Hauer <s.hauer@pengutronix.de>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: [PATCH] spi: mvebu: move timekeeping out of hot path
Date: Wed, 10 Sep 2025 07:42:25 +0200 [thread overview]
Message-ID: <20250910-v2025-08-0-topic-mvebu-spi-v1-1-c3e57dbb7503@pengutronix.de> (raw)
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>
reply other threads:[~2025-09-10 5:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250910-v2025-08-0-topic-mvebu-spi-v1-1-c3e57dbb7503@pengutronix.de \
--to=s.trumtrar@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox