From: Thomas Schaefer <thomas.schaefer@kontron.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] drivers/spi: fsl_qspi: fix read timeout
Date: Mon, 1 Jul 2019 17:37:34 +0200 [thread overview]
Message-ID: <20190701153735.170-2-thomas.schaefer@kontron.com> (raw)
In-Reply-To: <20190701153735.170-1-thomas.schaefer@kontron.com>
During QSPI reads, current is_controller_busy function sporadically
fails with -ETIMEDOUT due to fixed number of 5 test loops. Using
timer functions to wait 1000 us instead will fix this.
Signed-off-by: Thomas Schaefer <thomas.schaefer@kontron.com>
---
drivers/spi/fsl_qspi.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index 1598c4f698..2c5937509f 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -152,7 +152,7 @@ static inline int is_controller_busy(const struct fsl_qspi_priv *priv)
u32 val;
const u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
QSPI_SR_IP_ACC_MASK;
- unsigned int retry = 5;
+ unsigned long timeout = timer_get_us() + 1000;
do {
val = qspi_read32(priv->flags, &priv->regs->sr);
@@ -160,10 +160,9 @@ static inline int is_controller_busy(const struct fsl_qspi_priv *priv)
if ((~val & mask) == mask)
return 0;
- udelay(1);
- } while (--retry);
-
- return -ETIMEDOUT;
+ if (timer_get_us() > timeout )
+ return -ETIMEDOUT;
+ } while (1);
}
/* QSPI support swapping the flash read/write data
--
2.11.0
next prev parent reply other threads:[~2019-07-01 15:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 15:37 [U-Boot] Fix read error in fsl_qspi driver Thomas Schaefer
2019-07-01 15:37 ` Thomas Schaefer [this message]
2019-07-01 15:40 ` [U-Boot] [PATCH 1/2] drivers/spi: fsl_qspi: fix read timeout Fabio Estevam
2019-07-02 11:01 ` Jagan Teki
2019-07-01 15:37 ` [U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: improve timeout calculation Thomas Schaefer
2019-07-01 15:41 ` Fabio Estevam
2019-07-02 11:11 ` Jagan Teki
2019-07-02 11:43 ` Thomas Schaefer
2019-07-03 8:40 ` Jagan Teki
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=20190701153735.170-2-thomas.schaefer@kontron.com \
--to=thomas.schaefer@kontron.com \
--cc=u-boot@lists.denx.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