All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] drivers/spi: fsl_qspi: fix controller busy check
@ 2019-06-26  8:44 Thomas Schaefer
  2019-06-26  8:44 ` [U-Boot] [PATCH 1/2] " Thomas Schaefer
  2019-06-26  8:44 ` [U-Boot] [PATCH 2/2] " Thomas Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Schaefer @ 2019-06-26  8:44 UTC (permalink / raw)
  To: u-boot


> On Mon, Jun 24, 2019 at 10:34 PM Fabio Estevam <festevam@gmail.com> wrote:
> >
> > From: Thomas Schaefer <thomas.schaefer@kontron.com>
> >
> > During QSPI reads, current is_busy_controller function sporadically 
> > fails with -ETIMEDOUT due to fixed number of 5 test loops. This 
> > patch fixes this by using the readl_poll_timeout function with
> > 1000 us timeout.
> 
> This sounds like two different functionalities into one patch. better create a timeout fix in one patch and another patch to migrate read_poll.

I have split the patch into a series of 2 to differentiate functionality, as follows

Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 1/2] drivers/spi: fsl_qspi: fix controller busy check
  2019-06-26  8:44 [U-Boot] [PATCH] drivers/spi: fsl_qspi: fix controller busy check Thomas Schaefer
@ 2019-06-26  8:44 ` Thomas Schaefer
  2019-07-01 13:20   ` Fabio Estevam
  2019-06-26  8:44 ` [U-Boot] [PATCH 2/2] " Thomas Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Schaefer @ 2019-06-26  8:44 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: fix controller busy check
  2019-06-26  8:44 [U-Boot] [PATCH] drivers/spi: fsl_qspi: fix controller busy check Thomas Schaefer
  2019-06-26  8:44 ` [U-Boot] [PATCH 1/2] " Thomas Schaefer
@ 2019-06-26  8:44 ` Thomas Schaefer
  2019-08-14  6:52   ` Prabhakar Kushwaha
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Schaefer @ 2019-06-26  8:44 UTC (permalink / raw)
  To: u-boot

Use readl_poll_timeout instead of explicit calculation.

Signed-off-by: Thomas Schaefer <thomas.schaefer@kontron.com>
---
 drivers/spi/fsl_qspi.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index 2c5937509f..41abe1996f 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -10,6 +10,7 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <linux/sizes.h>
+#include <linux/iopoll.h>
 #include <dm.h>
 #include <errno.h>
 #include <watchdog.h>
@@ -150,19 +151,13 @@ static void qspi_write32(u32 flags, u32 *addr, u32 val)
 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 long timeout = timer_get_us() + 1000;
+	u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
+		   QSPI_SR_IP_ACC_MASK;
 
-	do {
-		val = qspi_read32(priv->flags, &priv->regs->sr);
+	if (priv->flags & QSPI_FLAG_REGMAP_ENDIAN_BIG)
+		mask = (u32)cpu_to_be32(mask);
 
-		if ((~val & mask) == mask)
-			return 0;
-
-		if (timer_get_us() > timeout )
-			return -ETIMEDOUT;
-	} while (1);
+	return readl_poll_timeout(&priv->regs->sr, val, !(val & mask), 1000);
 }
 
 /* QSPI support swapping the flash read/write data
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 1/2] drivers/spi: fsl_qspi: fix controller busy check
  2019-06-26  8:44 ` [U-Boot] [PATCH 1/2] " Thomas Schaefer
@ 2019-07-01 13:20   ` Fabio Estevam
  0 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2019-07-01 13:20 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On Wed, Jun 26, 2019 at 5:45 AM Thomas Schaefer
<thomas.schaefer@kontron.com> wrote:
>
> 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>

Your patch series submission did not go well.

It seems you used the same original thread to submit the two patches.
They ended up with the same Subject:

https://lists.denx.de/pipermail/u-boot/2019-June/374188.html

and

https://lists.denx.de/pipermail/u-boot/2019-June/374189.html

Please resend, preferably via git send-email.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: fix controller busy check
  2019-06-26  8:44 ` [U-Boot] [PATCH 2/2] " Thomas Schaefer
@ 2019-08-14  6:52   ` Prabhakar Kushwaha
  2019-08-14 10:04     ` Thomas Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Prabhakar Kushwaha @ 2019-08-14  6:52 UTC (permalink / raw)
  To: u-boot

Dear Thomas,


> -----Original Message-----
> From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of Thomas
> Schaefer
> Sent: Wednesday, June 26, 2019 2:15 PM
> To: jagan at amarulasolutions.com; festevam at gmail.com
> Cc: trini at konsulko.com; Thomas Schäfer <thomas.schaefer@kontron.com>;
> u-boot at lists.denx.de
> Subject: [U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: fix controller busy check
> 
> Use readl_poll_timeout instead of explicit calculation.
> 
> Signed-off-by: Thomas Schaefer <thomas.schaefer@kontron.com>
> ---

Both of your patch has same subject. Please fix it.

Delegating Jagan for future review.

--pk

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: fix controller busy check
  2019-08-14  6:52   ` Prabhakar Kushwaha
@ 2019-08-14 10:04     ` Thomas Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Schaefer @ 2019-08-14 10:04 UTC (permalink / raw)
  To: u-boot

Hi Prabhakar,

I have already reworked this with different subjects and Jagan has applied patches to u-boot-spi/master on July, 1st.

See

c6d0c5eb30b5d677a6eeca5079a4e9a27630b530

and

733391e84bd9d67582b2ecd719b35585b70fe74c

Best regards,
Thomas

-----Ursprüngliche Nachricht-----
Von: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> 
Gesendet: Mittwoch, 14. August 2019 08:53
An: Thomas Schaefer <Thomas.Schaefer@kontron.com>; jagan at amarulasolutions.com; festevam at gmail.com
Cc: trini at konsulko.com; Thomas Schaefer <Thomas.Schaefer@kontron.com>; u-boot at lists.denx.de
Betreff: RE: [U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: fix controller busy check

Dear Thomas,


> -----Original Message-----
> From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of Thomas 
> Schaefer
> Sent: Wednesday, June 26, 2019 2:15 PM
> To: jagan at amarulasolutions.com; festevam at gmail.com
> Cc: trini at konsulko.com; Thomas Schäfer <thomas.schaefer@kontron.com>; 
> u-boot at lists.denx.de
> Subject: [U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: fix controller 
> busy check
> 
> Use readl_poll_timeout instead of explicit calculation.
> 
> Signed-off-by: Thomas Schaefer <thomas.schaefer@kontron.com>
> ---

Both of your patch has same subject. Please fix it.

Delegating Jagan for future review.

--pk

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-14 10:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26  8:44 [U-Boot] [PATCH] drivers/spi: fsl_qspi: fix controller busy check Thomas Schaefer
2019-06-26  8:44 ` [U-Boot] [PATCH 1/2] " Thomas Schaefer
2019-07-01 13:20   ` Fabio Estevam
2019-06-26  8:44 ` [U-Boot] [PATCH 2/2] " Thomas Schaefer
2019-08-14  6:52   ` Prabhakar Kushwaha
2019-08-14 10:04     ` Thomas Schaefer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.