linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy
@ 2019-12-10 15:03 Martin Devera
  2020-01-09 15:37 ` Miquel Raynal
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Devera @ 2019-12-10 15:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: Christophe Kerello, Marek Vasut, Richard Weinberger,
	Martin Devera, Boris Brezillon, linux-mtd, Miquel Raynal,
	jan.pohanka, Brian Norris, David Woodhouse

The used way to compute jiffies timeout brokes when
jiffie difference is 1. Simply add 1 - it has no other
side effects.
Fixes STM32MP1 FMC2 NAND controller which sometimes failed
exactly in this way.

Signed-off-by: Martin Devera <devik@eaxlabs.cz>
---
 drivers/mtd/nand/raw/nand_base.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index d527e448ce19..beab3a775cc7 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -721,7 +721,11 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
 	if (ret)
 		return ret;
 
-	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);
+	/* +1 below is necessary because if we are now in the last fraction
+	 * of jiffy and msecs_to_jiffies is 1 then we will wait only that
+	 * small jiffy fraction - possibly leading to false timeout
+	 */
+	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
 	do {
 		ret = nand_read_data_op(chip, &status, sizeof(status), true);
 		if (ret)
-- 
2.11.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy
  2019-12-10 15:03 [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy Martin Devera
@ 2020-01-09 15:37 ` Miquel Raynal
  2020-01-09 16:17   ` Martin DEVERA
  0 siblings, 1 reply; 8+ messages in thread
From: Miquel Raynal @ 2020-01-09 15:37 UTC (permalink / raw)
  To: Martin Devera
  Cc: Christophe Kerello, Marek Vasut, Richard Weinberger,
	linux-kernel, Boris Brezillon, linux-mtd, jan.pohanka,
	Brian Norris, David Woodhouse

Hi Martin,

Martin Devera <devik@eaxlabs.cz> wrote on Tue, 10 Dec 2019 16:03:18
+0100:

> The used way to compute jiffies timeout brokes when
> jiffie difference is 1. Simply add 1 - it has no other
> side effects.
> Fixes STM32MP1 FMC2 NAND controller which sometimes failed
> exactly in this way.
> 
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index d527e448ce19..beab3a775cc7 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -721,7 +721,11 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
>  	if (ret)
>  		return ret;
>  
> -	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);
> +	/* +1 below is necessary because if we are now in the last fraction
> +	 * of jiffy and msecs_to_jiffies is 1 then we will wait only that
> +	 * small jiffy fraction - possibly leading to false timeout
> +	 */
> +	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
>  	do {
>  		ret = nand_read_data_op(chip, &status, sizeof(status), true);
>  		if (ret)

I don't really what you are fixing here, I suspect the root cause to be
a wrongly calculated timeout_ms in the calling driver.

It is the responsibility of the caller to use this function with a
relevant timeout_ms parameter. Maybe Christophe can help you here?


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy
  2020-01-09 15:37 ` Miquel Raynal
@ 2020-01-09 16:17   ` Martin DEVERA
  2020-01-09 17:22     ` Miquel Raynal
  0 siblings, 1 reply; 8+ messages in thread
From: Martin DEVERA @ 2020-01-09 16:17 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Christophe Kerello, Marek Vasut, Richard Weinberger,
	linux-kernel, Boris Brezillon, linux-mtd, jan.pohanka,
	Brian Norris, David Woodhouse

On 1/9/20 4:37 PM, Miquel Raynal wrote:
> Hi Martin,
>
> Martin Devera <devik@eaxlabs.cz> wrote on Tue, 10 Dec 2019 16:03:18
> +0100:
>
>> The used way to compute jiffies timeout brokes when
>> jiffie difference is 1. Simply add 1 - it has no other
>> side effects.
>> Fixes STM32MP1 FMC2 NAND controller which sometimes failed
>> exactly in this way.
>>
>> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
>> ---
>>   drivers/mtd/nand/raw/nand_base.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
>> index d527e448ce19..beab3a775cc7 100644
>> --- a/drivers/mtd/nand/raw/nand_base.c
>> +++ b/drivers/mtd/nand/raw/nand_base.c
>> @@ -721,7 +721,11 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
>>   	if (ret)
>>   		return ret;
>>   
>> -	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);
>> +	/* +1 below is necessary because if we are now in the last fraction
>> +	 * of jiffy and msecs_to_jiffies is 1 then we will wait only that
>> +	 * small jiffy fraction - possibly leading to false timeout
>> +	 */
>> +	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
>>   	do {
>>   		ret = nand_read_data_op(chip, &status, sizeof(status), true);
>>   		if (ret)
> I don't really what you are fixing here, I suspect the root cause to be
> a wrongly calculated timeout_ms in the calling driver.
>
> It is the responsibility of the caller to use this function with a
> relevant timeout_ms parameter. Maybe Christophe can help you here?
>
Hi Miquel,

assume that nand_soft_waitrdy is called with timeout_ms==1. I suppose it is
valid case. Jiffies are 1000 for example (assume something more like 
1000.99 -
just before incrementing to 1001).
We compute timeout_ms = 1000+msecs_to_jiffies(1) = 1001 (at least for my 
jiffies rate).
nand_read_data_op is called for the first time and returns 0. During the 
call jiffies changes
to 1001 thus "while loop" ends here (wrongly).
Notice that routine was called with expected timeout 1ms but actual 
timeout used was something
between 0...1ms (which I also measured by tracing & scope on the bus).
Or is my analysis flawed somewhere ?

Thanks,

Martin


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy
  2020-01-09 16:17   ` Martin DEVERA
@ 2020-01-09 17:22     ` Miquel Raynal
       [not found]       ` <0501ddbd-9e0f-62ec-ab57-d092502680d5@eaxlabs.cz>
  0 siblings, 1 reply; 8+ messages in thread
From: Miquel Raynal @ 2020-01-09 17:22 UTC (permalink / raw)
  To: Martin DEVERA
  Cc: Christophe Kerello, Marek Vasut, Richard Weinberger,
	linux-kernel, Boris Brezillon, linux-mtd, jan.pohanka,
	Brian Norris, David Woodhouse

Hi Martin,

Martin DEVERA <devik@eaxlabs.cz> wrote on Thu, 9 Jan 2020 17:17:30
+0100:

> On 1/9/20 4:37 PM, Miquel Raynal wrote:
> > Hi Martin,
> >
> > Martin Devera <devik@eaxlabs.cz> wrote on Tue, 10 Dec 2019 16:03:18
> > +0100:
> >  
> >> The used way to compute jiffies timeout brokes when
> >> jiffie difference is 1. Simply add 1 - it has no other
> >> side effects.
> >> Fixes STM32MP1 FMC2 NAND controller which sometimes failed
> >> exactly in this way.
> >>
> >> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> >> ---
> >>   drivers/mtd/nand/raw/nand_base.c | 6 +++++-
> >>   1 file changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> >> index d527e448ce19..beab3a775cc7 100644
> >> --- a/drivers/mtd/nand/raw/nand_base.c
> >> +++ b/drivers/mtd/nand/raw/nand_base.c
> >> @@ -721,7 +721,11 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
> >>   	if (ret)
> >>   		return ret;  
> >>   >> -	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);  
> >> +	/* +1 below is necessary because if we are now in the last fraction
> >> +	 * of jiffy and msecs_to_jiffies is 1 then we will wait only that
> >> +	 * small jiffy fraction - possibly leading to false timeout
> >> +	 */
> >> +	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
> >>   	do {
> >>   		ret = nand_read_data_op(chip, &status, sizeof(status), true);
> >>   		if (ret)  
> > I don't really what you are fixing here, I suspect the root cause to be
> > a wrongly calculated timeout_ms in the calling driver.
> >
> > It is the responsibility of the caller to use this function with a
> > relevant timeout_ms parameter. Maybe Christophe can help you here?
> >  
> Hi Miquel,
> 
> assume that nand_soft_waitrdy is called with timeout_ms==1. I suppose it is
> valid case. Jiffies are 1000 for example (assume something more like 1000.99 -
> just before incrementing to 1001).
> We compute timeout_ms = 1000+msecs_to_jiffies(1) = 1001 (at least for my jiffies rate).
> nand_read_data_op is called for the first time and returns 0. During the call jiffies changes
> to 1001 thus "while loop" ends here (wrongly).
> Notice that routine was called with expected timeout 1ms but actual timeout used was something
> between 0...1ms (which I also measured by tracing & scope on the bus).
> Or is my analysis flawed somewhere ?

I agree with your analysis. Even if nand_soft_waitrdy will no longer be
used by the stm32 driver (Christophe sent a patch for that) I am fine
applying this change.

Could you add a comment to explain the '+1' and resend?

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy
       [not found]       ` <0501ddbd-9e0f-62ec-ab57-d092502680d5@eaxlabs.cz>
@ 2020-01-09 18:02         ` Miquel Raynal
  2020-01-09 18:04           ` Miquel Raynal
  0 siblings, 1 reply; 8+ messages in thread
From: Miquel Raynal @ 2020-01-09 18:02 UTC (permalink / raw)
  To: Martin DEVERA, linux-mtd

Hi Martin,

Martin DEVERA <devik@eaxlabs.cz> wrote on Thu, 9 Jan 2020 18:43:46
+0100:

> On 1/9/20 6:22 PM, Miquel Raynal wrote:
> > Hi Martin,
> >
> > Martin DEVERA <devik@eaxlabs.cz> wrote on Thu, 9 Jan 2020 17:17:30
> > +0100:
> >  
> >> On 1/9/20 4:37 PM, Miquel Raynal wrote:  
> >>> Hi Martin,
> >>>
> >>> Martin Devera <devik@eaxlabs.cz> wrote on Tue, 10 Dec 2019 16:03:18
> >>> +0100:  
> >>>   >>>> The used way to compute jiffies timeout brokes when  
> >>>> jiffie difference is 1. Simply add 1 - it has no other
> >>>> side effects.
> >>>> Fixes STM32MP1 FMC2 NAND controller which sometimes failed
> >>>> exactly in this way.
> >>>>
> >>>> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> >>>> ---
> >>>>    drivers/mtd/nand/raw/nand_base.c | 6 +++++-
> >>>>    1 file changed, 5 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> >>>> index d527e448ce19..beab3a775cc7 100644
> >>>> --- a/drivers/mtd/nand/raw/nand_base.c
> >>>> +++ b/drivers/mtd/nand/raw/nand_base.c
> >>>> @@ -721,7 +721,11 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
> >>>>    	if (ret)
> >>>>    		return ret;  
> >>>>    >> -	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);  
> >>>> +	/* +1 below is necessary because if we are now in the last fraction
> >>>> +	 * of jiffy and msecs_to_jiffies is 1 then we will wait only that
> >>>> +	 * small jiffy fraction - possibly leading to false timeout
> >>>> +	 */
> >>>> +	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
> >>>>    	do {
> >>>>    		ret = nand_read_data_op(chip, &status, sizeof(status), true);
> >>>>    		if (ret)  
> >>> I don't really what you are fixing here, I suspect the root cause to be
> >>> a wrongly calculated timeout_ms in the calling driver.
> >>>
> >>> It is the responsibility of the caller to use this function with a
> >>> relevant timeout_ms parameter. Maybe Christophe can help you here?  
> >>>   >> Hi Miquel,  
> >>
> >> assume that nand_soft_waitrdy is called with timeout_ms==1. I suppose it is
> >> valid case. Jiffies are 1000 for example (assume something more like 1000.99 -
> >> just before incrementing to 1001).
> >> We compute timeout_ms = 1000+msecs_to_jiffies(1) = 1001 (at least for my jiffies rate).
> >> nand_read_data_op is called for the first time and returns 0. During the call jiffies changes
> >> to 1001 thus "while loop" ends here (wrongly).
> >> Notice that routine was called with expected timeout 1ms but actual timeout used was something
> >> between 0...1ms (which I also measured by tracing & scope on the bus).
> >> Or is my analysis flawed somewhere ?  
> > I agree with your analysis. Even if nand_soft_waitrdy will no longer be
> > used by the stm32 driver (Christophe sent a patch for that) I am fine
> > applying this change.
> >
> > Could you add a comment to explain the '+1' and resend?
> >  
> Can you give me some guidance please ? Where should I add more comment to
> the git commit or to the C code ? I tried to comment both commit and code, probably
> you find the comments not clear enough ?

Sorry for not explaining: Could you add the example to the commit
message? The comment is fine, besides the fact that it should start
like this:

	/*
	 * Bla bla bla

Also please change the commit title, maybe

	mtd: rawnand: Ensure nand_soft_waitrdy wait period is enough

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy
  2020-01-09 18:02         ` Miquel Raynal
@ 2020-01-09 18:04           ` Miquel Raynal
  2020-01-16 13:54             ` [PATCH] mtd: rawnand: Ensure nand_soft_waitrdy wait period is enough Martin Devera
  0 siblings, 1 reply; 8+ messages in thread
From: Miquel Raynal @ 2020-01-09 18:04 UTC (permalink / raw)
  To: Martin DEVERA, linux-mtd

Hi Martin,

I forgot to mention: please don't forget to keep everyone in copy. I
re-added the mtd-list in my previous answer.

Miquel Raynal <miquel.raynal@bootlin.com> wrote on Thu, 9 Jan 2020
19:02:40 +0100:

> Hi Martin,
> 
> Martin DEVERA <devik@eaxlabs.cz> wrote on Thu, 9 Jan 2020 18:43:46
> +0100:
> 
> > On 1/9/20 6:22 PM, Miquel Raynal wrote:  
> > > Hi Martin,
> > >
> > > Martin DEVERA <devik@eaxlabs.cz> wrote on Thu, 9 Jan 2020 17:17:30
> > > +0100:
> > >    
> > >> On 1/9/20 4:37 PM, Miquel Raynal wrote:    
> > >>> Hi Martin,
> > >>>
> > >>> Martin Devera <devik@eaxlabs.cz> wrote on Tue, 10 Dec 2019 16:03:18
> > >>> +0100:    
> > >>>   >>>> The used way to compute jiffies timeout brokes when    
> > >>>> jiffie difference is 1. Simply add 1 - it has no other
> > >>>> side effects.
> > >>>> Fixes STM32MP1 FMC2 NAND controller which sometimes failed
> > >>>> exactly in this way.
> > >>>>
> > >>>> Signed-off-by: Martin Devera <devik@eaxlabs.cz>
> > >>>> ---
> > >>>>    drivers/mtd/nand/raw/nand_base.c | 6 +++++-
> > >>>>    1 file changed, 5 insertions(+), 1 deletion(-)
> > >>>>
> > >>>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> > >>>> index d527e448ce19..beab3a775cc7 100644
> > >>>> --- a/drivers/mtd/nand/raw/nand_base.c
> > >>>> +++ b/drivers/mtd/nand/raw/nand_base.c
> > >>>> @@ -721,7 +721,11 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
> > >>>>    	if (ret)
> > >>>>    		return ret;    
> > >>>>    >> -	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);    
> > >>>> +	/* +1 below is necessary because if we are now in the last fraction
> > >>>> +	 * of jiffy and msecs_to_jiffies is 1 then we will wait only that
> > >>>> +	 * small jiffy fraction - possibly leading to false timeout
> > >>>> +	 */
> > >>>> +	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
> > >>>>    	do {
> > >>>>    		ret = nand_read_data_op(chip, &status, sizeof(status), true);
> > >>>>    		if (ret)    
> > >>> I don't really what you are fixing here, I suspect the root cause to be
> > >>> a wrongly calculated timeout_ms in the calling driver.
> > >>>
> > >>> It is the responsibility of the caller to use this function with a
> > >>> relevant timeout_ms parameter. Maybe Christophe can help you here?    
> > >>>   >> Hi Miquel,    
> > >>
> > >> assume that nand_soft_waitrdy is called with timeout_ms==1. I suppose it is
> > >> valid case. Jiffies are 1000 for example (assume something more like 1000.99 -
> > >> just before incrementing to 1001).
> > >> We compute timeout_ms = 1000+msecs_to_jiffies(1) = 1001 (at least for my jiffies rate).
> > >> nand_read_data_op is called for the first time and returns 0. During the call jiffies changes
> > >> to 1001 thus "while loop" ends here (wrongly).
> > >> Notice that routine was called with expected timeout 1ms but actual timeout used was something
> > >> between 0...1ms (which I also measured by tracing & scope on the bus).
> > >> Or is my analysis flawed somewhere ?    
> > > I agree with your analysis. Even if nand_soft_waitrdy will no longer be
> > > used by the stm32 driver (Christophe sent a patch for that) I am fine
> > > applying this change.
> > >
> > > Could you add a comment to explain the '+1' and resend?
> > >    
> > Can you give me some guidance please ? Where should I add more comment to
> > the git commit or to the C code ? I tried to comment both commit and code, probably
> > you find the comments not clear enough ?  
> 
> Sorry for not explaining: Could you add the example to the commit
> message? The comment is fine, besides the fact that it should start
> like this:
> 
> 	/*
> 	 * Bla bla bla
> 
> Also please change the commit title, maybe
> 
> 	mtd: rawnand: Ensure nand_soft_waitrdy wait period is enough
> 
> Thanks,
> Miquèl




Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH] mtd: rawnand: Ensure nand_soft_waitrdy wait period is enough
  2020-01-09 18:04           ` Miquel Raynal
@ 2020-01-16 13:54             ` Martin Devera
  2020-03-10 18:34               ` Miquel Raynal
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Devera @ 2020-01-16 13:54 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, Richard Weinberger,
	David Woodhouse, Brian Norris, Marek Vasut,
	GitAuthor: Martin Devera, linux-mtd

The used way to compute jiffies timeout brokes when
jiffie difference is 1.
Assume that nand_soft_waitrdy is called with timeout_ms==1.
Jiffies are 1000 for example (assume something more like 1000.99
- just before incrementing to 1001).
We compute timeout_ms = 1000+msecs_to_jiffies(1) = 1001.
nand_read_data_op is called for the first time and returns 0.
During the call jiffies changes to 1001 thus "while loop" ends
here (wrongly). Notice that routine was called with expected timeout
1ms but actual timeout used was something between 0...1ms.

Fixes STM32MP1 FMC2 NAND controller which sometimes failed
exactly in this way.

Signed-off-by: Martin Devera <devik@eaxlabs.cz>
---
 drivers/mtd/nand/raw/nand_base.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index d527e448ce19..9a7e09c8d8be 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -721,7 +721,12 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
 	if (ret)
 		return ret;
 
-	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);
+	/*
+	 * +1 below is necessary because if we are now in the last fraction
+	 * of jiffy and msecs_to_jiffies is 1 then we will wait only that
+	 * small jiffy fraction - possibly leading to false timeout
+	 */
+	timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
 	do {
 		ret = nand_read_data_op(chip, &status, sizeof(status), true);
 		if (ret)
-- 
2.11.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: Ensure nand_soft_waitrdy wait period is enough
  2020-01-16 13:54             ` [PATCH] mtd: rawnand: Ensure nand_soft_waitrdy wait period is enough Martin Devera
@ 2020-03-10 18:34               ` Miquel Raynal
  0 siblings, 0 replies; 8+ messages in thread
From: Miquel Raynal @ 2020-03-10 18:34 UTC (permalink / raw)
  To: Martin Devera, Boris Brezillon, Miquel Raynal,
	Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
	linux-mtd

On Thu, 2020-01-16 at 13:54:31 UTC, Martin Devera wrote:
> The used way to compute jiffies timeout brokes when
> jiffie difference is 1.
> Assume that nand_soft_waitrdy is called with timeout_ms==1.
> Jiffies are 1000 for example (assume something more like 1000.99
> - just before incrementing to 1001).
> We compute timeout_ms = 1000+msecs_to_jiffies(1) = 1001.
> nand_read_data_op is called for the first time and returns 0.
> During the call jiffies changes to 1001 thus "while loop" ends
> here (wrongly). Notice that routine was called with expected timeout
> 1ms but actual timeout used was something between 0...1ms.
> 
> Fixes STM32MP1 FMC2 NAND controller which sometimes failed
> exactly in this way.
> 
> Signed-off-by: Martin Devera <devik@eaxlabs.cz>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2020-03-10 18:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 15:03 [PATCH] mtd: rawnand: Fix unexpected timeouts in waitrdy Martin Devera
2020-01-09 15:37 ` Miquel Raynal
2020-01-09 16:17   ` Martin DEVERA
2020-01-09 17:22     ` Miquel Raynal
     [not found]       ` <0501ddbd-9e0f-62ec-ab57-d092502680d5@eaxlabs.cz>
2020-01-09 18:02         ` Miquel Raynal
2020-01-09 18:04           ` Miquel Raynal
2020-01-16 13:54             ` [PATCH] mtd: rawnand: Ensure nand_soft_waitrdy wait period is enough Martin Devera
2020-03-10 18:34               ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).