All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fsi: SBE FIFO fixes
@ 2020-07-24  7:15 Joel Stanley
  2020-07-24  7:15 ` [PATCH 1/2] fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE Joel Stanley
  2020-07-24  7:15 ` [PATCH 2/2] fsi/sbefifo: Fix reset timeout Joel Stanley
  0 siblings, 2 replies; 7+ messages in thread
From: Joel Stanley @ 2020-07-24  7:15 UTC (permalink / raw)
  To: linux-fsi
  Cc: Benjamin Herrenschmidt, linux-kernel, Jeremy Kerr,
	Alistar Popple, Eddie James

Two SBE FIFO fixes by Joachim.

Joachim Fenkes (2):
  fsi/sbefifo: Clean up correct FIFO when receiving reset request from
    SBE
  fsi/sbefifo: Fix reset timeout

 drivers/fsi/fsi-sbefifo.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

-- 
2.27.0


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

* [PATCH 1/2] fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE
  2020-07-24  7:15 [PATCH 0/2] fsi: SBE FIFO fixes Joel Stanley
@ 2020-07-24  7:15 ` Joel Stanley
  2020-07-27  5:51   ` Benjamin Herrenschmidt
  2020-07-24  7:15 ` [PATCH 2/2] fsi/sbefifo: Fix reset timeout Joel Stanley
  1 sibling, 1 reply; 7+ messages in thread
From: Joel Stanley @ 2020-07-24  7:15 UTC (permalink / raw)
  To: linux-fsi
  Cc: Benjamin Herrenschmidt, Joachim Fenkes, linux-kernel,
	Jeremy Kerr, Alistar Popple, Eddie James

From: Joachim Fenkes <FENKES@de.ibm.com>

When the SBE requests a reset via the down FIFO, that is also the
FIFO we should go and reset ;)

Fixes: 9f4a8a2d7f9d ("fsi/sbefifo: Add driver for the SBE FIFO")
Signed-off-by: Joachim Fenkes <FENKES@de.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 drivers/fsi/fsi-sbefifo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
index f54df9ebc8b3..655b45c1f6ba 100644
--- a/drivers/fsi/fsi-sbefifo.c
+++ b/drivers/fsi/fsi-sbefifo.c
@@ -400,7 +400,7 @@ static int sbefifo_cleanup_hw(struct sbefifo *sbefifo)
 	/* The FIFO already contains a reset request from the SBE ? */
 	if (down_status & SBEFIFO_STS_RESET_REQ) {
 		dev_info(dev, "Cleanup: FIFO reset request set, resetting\n");
-		rc = sbefifo_regw(sbefifo, SBEFIFO_UP, SBEFIFO_PERFORM_RESET);
+		rc = sbefifo_regw(sbefifo, SBEFIFO_DOWN, SBEFIFO_PERFORM_RESET);
 		if (rc) {
 			sbefifo->broken = true;
 			dev_err(dev, "Cleanup: Reset reg write failed, rc=%d\n", rc);
-- 
2.27.0


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

* [PATCH 2/2] fsi/sbefifo: Fix reset timeout
  2020-07-24  7:15 [PATCH 0/2] fsi: SBE FIFO fixes Joel Stanley
  2020-07-24  7:15 ` [PATCH 1/2] fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE Joel Stanley
@ 2020-07-24  7:15 ` Joel Stanley
  2020-07-24 14:34   ` Guenter Roeck
  1 sibling, 1 reply; 7+ messages in thread
From: Joel Stanley @ 2020-07-24  7:15 UTC (permalink / raw)
  To: linux-fsi
  Cc: Benjamin Herrenschmidt, Joachim Fenkes, linux-kernel,
	Jeremy Kerr, Alistar Popple, Eddie James, Joachim Fenkes

From: Joachim Fenkes <FENKES@de.ibm.com>

On BMCs with lower timer resolution than 1ms, msleep(1) will take
way longer than 1ms, so looping 10k times won't wait for 10s but
significantly longer.

Fix this by using jiffies like the rest of the code.

Fixes: 9f4a8a2d7f9d ("fsi/sbefifo: Add driver for the SBE FIFO")
Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 drivers/fsi/fsi-sbefifo.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
index 655b45c1f6ba..3ad9510ad4a4 100644
--- a/drivers/fsi/fsi-sbefifo.c
+++ b/drivers/fsi/fsi-sbefifo.c
@@ -325,6 +325,7 @@ static int sbefifo_up_write(struct sbefifo *sbefifo, __be32 word)
 static int sbefifo_request_reset(struct sbefifo *sbefifo)
 {
 	struct device *dev = &sbefifo->fsi_dev->dev;
+	unsigned long end_time;
 	u32 status, timeout;
 	int rc;
 
@@ -341,7 +342,8 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
 	}
 
 	/* Wait for it to complete */
-	for (timeout = 0; timeout < SBEFIFO_RESET_TIMEOUT; timeout++) {
+	end_time = jiffies + msecs_to_jiffies(SBEFIFO_RESET_TIMEOUT);
+	while (!time_after(jiffies, end_time)) {
 		rc = sbefifo_regr(sbefifo, SBEFIFO_UP | SBEFIFO_STS, &status);
 		if (rc) {
 			dev_err(dev, "Failed to read UP fifo status during reset"
@@ -355,7 +357,7 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
 			return 0;
 		}
 
-		msleep(1);
+		cond_resched();
 	}
 	dev_err(dev, "FIFO reset timed out\n");
 
-- 
2.27.0


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

* Re: [PATCH 2/2] fsi/sbefifo: Fix reset timeout
  2020-07-24  7:15 ` [PATCH 2/2] fsi/sbefifo: Fix reset timeout Joel Stanley
@ 2020-07-24 14:34   ` Guenter Roeck
  2020-09-10  3:08     ` Joel Stanley
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2020-07-24 14:34 UTC (permalink / raw)
  To: Joel Stanley, linux-fsi; +Cc: Joachim Fenkes, linux-kernel, Alistar Popple

On 7/24/20 12:15 AM, Joel Stanley wrote:
> From: Joachim Fenkes <FENKES@de.ibm.com>
> 
> On BMCs with lower timer resolution than 1ms, msleep(1) will take
> way longer than 1ms, so looping 10k times won't wait for 10s but
> significantly longer.
> 
> Fix this by using jiffies like the rest of the code.
> 
> Fixes: 9f4a8a2d7f9d ("fsi/sbefifo: Add driver for the SBE FIFO")
> Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  drivers/fsi/fsi-sbefifo.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> index 655b45c1f6ba..3ad9510ad4a4 100644
> --- a/drivers/fsi/fsi-sbefifo.c
> +++ b/drivers/fsi/fsi-sbefifo.c
> @@ -325,6 +325,7 @@ static int sbefifo_up_write(struct sbefifo *sbefifo, __be32 word)
>  static int sbefifo_request_reset(struct sbefifo *sbefifo)
>  {
>  	struct device *dev = &sbefifo->fsi_dev->dev;
> +	unsigned long end_time;
>  	u32 status, timeout;
>  	int rc;
>  
> @@ -341,7 +342,8 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
>  	}
>  
>  	/* Wait for it to complete */
> -	for (timeout = 0; timeout < SBEFIFO_RESET_TIMEOUT; timeout++) {
> +	end_time = jiffies + msecs_to_jiffies(SBEFIFO_RESET_TIMEOUT);
> +	while (!time_after(jiffies, end_time)) {
>  		rc = sbefifo_regr(sbefifo, SBEFIFO_UP | SBEFIFO_STS, &status);
>  		if (rc) {
>  			dev_err(dev, "Failed to read UP fifo status during reset"
> @@ -355,7 +357,7 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
>  			return 0;
>  		}
>  
> -		msleep(1);
> +		cond_resched();

A hot loop ? Are you sure ? usleep_range() might make more sense here.

Thanks,
Guenter

>  	}
>  	dev_err(dev, "FIFO reset timed out\n");
>  
> 


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

* Re: [PATCH 1/2] fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE
  2020-07-24  7:15 ` [PATCH 1/2] fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE Joel Stanley
@ 2020-07-27  5:51   ` Benjamin Herrenschmidt
  2020-09-10  3:08     ` Joel Stanley
  0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2020-07-27  5:51 UTC (permalink / raw)
  To: Joel Stanley, linux-fsi
  Cc: Joachim Fenkes, linux-kernel, Jeremy Kerr, Alistar Popple, Eddie James

On Fri, 2020-07-24 at 16:45 +0930, Joel Stanley wrote:
> From: Joachim Fenkes <FENKES@de.ibm.com>
> 
> When the SBE requests a reset via the down FIFO, that is also the
> FIFO we should go and reset ;)

Is it ?

I no longer work for IBM and dont have access to any of the
documentation here but I had vague memories that we would get a reset
request in the down fifo in order to reset the up one since we control
the up one and the host controls the down one, no ?

Cheers,
Ben.

> Fixes: 9f4a8a2d7f9d ("fsi/sbefifo: Add driver for the SBE FIFO")
> Signed-off-by: Joachim Fenkes <FENKES@de.ibm.com>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  drivers/fsi/fsi-sbefifo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> index f54df9ebc8b3..655b45c1f6ba 100644
> --- a/drivers/fsi/fsi-sbefifo.c
> +++ b/drivers/fsi/fsi-sbefifo.c
> @@ -400,7 +400,7 @@ static int sbefifo_cleanup_hw(struct sbefifo
> *sbefifo)
>  	/* The FIFO already contains a reset request from the SBE ? */
>  	if (down_status & SBEFIFO_STS_RESET_REQ) {
>  		dev_info(dev, "Cleanup: FIFO reset request set,
> resetting\n");
> -		rc = sbefifo_regw(sbefifo, SBEFIFO_UP,
> SBEFIFO_PERFORM_RESET);
> +		rc = sbefifo_regw(sbefifo, SBEFIFO_DOWN,
> SBEFIFO_PERFORM_RESET);
>  		if (rc) {
>  			sbefifo->broken = true;
>  			dev_err(dev, "Cleanup: Reset reg write failed,
> rc=%d\n", rc);


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

* Re: [PATCH 2/2] fsi/sbefifo: Fix reset timeout
  2020-07-24 14:34   ` Guenter Roeck
@ 2020-09-10  3:08     ` Joel Stanley
  0 siblings, 0 replies; 7+ messages in thread
From: Joel Stanley @ 2020-09-10  3:08 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-fsi, Joachim Fenkes, Linux Kernel Mailing List, Alistar Popple

On Fri, 24 Jul 2020 at 14:34, Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 7/24/20 12:15 AM, Joel Stanley wrote:
> > From: Joachim Fenkes <FENKES@de.ibm.com>
> >
> > On BMCs with lower timer resolution than 1ms, msleep(1) will take
> > way longer than 1ms, so looping 10k times won't wait for 10s but
> > significantly longer.
> >
> > Fix this by using jiffies like the rest of the code.
> >
> > Fixes: 9f4a8a2d7f9d ("fsi/sbefifo: Add driver for the SBE FIFO")
> > Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
> > Signed-off-by: Joel Stanley <joel@jms.id.au>
> > ---
> >  drivers/fsi/fsi-sbefifo.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> > index 655b45c1f6ba..3ad9510ad4a4 100644
> > --- a/drivers/fsi/fsi-sbefifo.c
> > +++ b/drivers/fsi/fsi-sbefifo.c
> > @@ -325,6 +325,7 @@ static int sbefifo_up_write(struct sbefifo *sbefifo, __be32 word)
> >  static int sbefifo_request_reset(struct sbefifo *sbefifo)
> >  {
> >       struct device *dev = &sbefifo->fsi_dev->dev;
> > +     unsigned long end_time;
> >       u32 status, timeout;
> >       int rc;
> >
> > @@ -341,7 +342,8 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
> >       }
> >
> >       /* Wait for it to complete */
> > -     for (timeout = 0; timeout < SBEFIFO_RESET_TIMEOUT; timeout++) {
> > +     end_time = jiffies + msecs_to_jiffies(SBEFIFO_RESET_TIMEOUT);
> > +     while (!time_after(jiffies, end_time)) {
> >               rc = sbefifo_regr(sbefifo, SBEFIFO_UP | SBEFIFO_STS, &status);
> >               if (rc) {
> >                       dev_err(dev, "Failed to read UP fifo status during reset"
> > @@ -355,7 +357,7 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
> >                       return 0;
> >               }
> >
> > -             msleep(1);
> > +             cond_resched();
>
> A hot loop ? Are you sure ? usleep_range() might make more sense here.

Thanks for the review.

Joachim, I can fix this up for you.

Do you have a suggestion for how long to wait? What's the best case
completion time for a sbe reset?

We also have a hot loop in sbefifo_wait. I'm open to suggestions for
how long that should delay for.

Cheers,

Joel

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

* Re: [PATCH 1/2] fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE
  2020-07-27  5:51   ` Benjamin Herrenschmidt
@ 2020-09-10  3:08     ` Joel Stanley
  0 siblings, 0 replies; 7+ messages in thread
From: Joel Stanley @ 2020-09-10  3:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linux-fsi, Joachim Fenkes, Linux Kernel Mailing List,
	Jeremy Kerr, Alistar Popple, Eddie James

On Mon, 27 Jul 2020 at 05:51, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
>
> On Fri, 2020-07-24 at 16:45 +0930, Joel Stanley wrote:
> > From: Joachim Fenkes <FENKES@de.ibm.com>
> >
> > When the SBE requests a reset via the down FIFO, that is also the
> > FIFO we should go and reset ;)
>
> Is it ?
>
> I no longer work for IBM and dont have access to any of the
> documentation here but I had vague memories that we would get a reset
> request in the down fifo in order to reset the up one since we control
> the up one and the host controls the down one, no ?

Joachim, can you clarify the situation here?

>
> > Fixes: 9f4a8a2d7f9d ("fsi/sbefifo: Add driver for the SBE FIFO")
> > Signed-off-by: Joachim Fenkes <FENKES@de.ibm.com>
> > Signed-off-by: Joel Stanley <joel@jms.id.au>
> > ---
> >  drivers/fsi/fsi-sbefifo.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> > index f54df9ebc8b3..655b45c1f6ba 100644
> > --- a/drivers/fsi/fsi-sbefifo.c
> > +++ b/drivers/fsi/fsi-sbefifo.c
> > @@ -400,7 +400,7 @@ static int sbefifo_cleanup_hw(struct sbefifo
> > *sbefifo)
> >       /* The FIFO already contains a reset request from the SBE ? */
> >       if (down_status & SBEFIFO_STS_RESET_REQ) {
> >               dev_info(dev, "Cleanup: FIFO reset request set,
> > resetting\n");
> > -             rc = sbefifo_regw(sbefifo, SBEFIFO_UP,
> > SBEFIFO_PERFORM_RESET);
> > +             rc = sbefifo_regw(sbefifo, SBEFIFO_DOWN,
> > SBEFIFO_PERFORM_RESET);
> >               if (rc) {
> >                       sbefifo->broken = true;
> >                       dev_err(dev, "Cleanup: Reset reg write failed,
> > rc=%d\n", rc);
>

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

end of thread, other threads:[~2020-09-10  3:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24  7:15 [PATCH 0/2] fsi: SBE FIFO fixes Joel Stanley
2020-07-24  7:15 ` [PATCH 1/2] fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE Joel Stanley
2020-07-27  5:51   ` Benjamin Herrenschmidt
2020-09-10  3:08     ` Joel Stanley
2020-07-24  7:15 ` [PATCH 2/2] fsi/sbefifo: Fix reset timeout Joel Stanley
2020-07-24 14:34   ` Guenter Roeck
2020-09-10  3:08     ` Joel Stanley

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.