linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID
@ 2017-09-26  3:39 Masahiro Yamada
  2017-09-26  6:43 ` Boris Brezillon
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2017-09-26  3:39 UTC (permalink / raw)
  To: linux-mtd
  Cc: Masahiro Yamada, Cyrille Pitchen, linux-kernel, Boris Brezillon,
	Marek Vasut, Brian Norris, Richard Weinberger, David Woodhouse

Read Status and Read ID require tWHR before reading the first data.
Insert a very short wait to make sure to meet the spec.

I have not seen any problem report for now, but nand_command() and
nand_command_lP() are generic hooks, so it makes sense to implement
fail-safe code here.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mtd/nand/nand_base.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index b1cf32c..55c0ba5 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -742,9 +742,12 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
 	case NAND_CMD_ERASE1:
 	case NAND_CMD_ERASE2:
 	case NAND_CMD_SEQIN:
+	case NAND_CMD_SET_FEATURES:
+		return;
+
 	case NAND_CMD_STATUS:
 	case NAND_CMD_READID:
-	case NAND_CMD_SET_FEATURES:
+		ndelay(200);	/* tWHR */
 		return;
 
 	case NAND_CMD_RESET:
@@ -871,9 +874,12 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
 	case NAND_CMD_ERASE1:
 	case NAND_CMD_ERASE2:
 	case NAND_CMD_SEQIN:
+	case NAND_CMD_SET_FEATURES:
+		return;
+
 	case NAND_CMD_STATUS:
 	case NAND_CMD_READID:
-	case NAND_CMD_SET_FEATURES:
+		ndelay(200);	/* tWHR */
 		return;
 
 	case NAND_CMD_RNDIN:
-- 
2.7.4

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

* Re: [PATCH] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID
  2017-09-26  3:39 [PATCH] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID Masahiro Yamada
@ 2017-09-26  6:43 ` Boris Brezillon
  2017-09-26  8:17   ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2017-09-26  6:43 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mtd, Cyrille Pitchen, linux-kernel, Marek Vasut,
	Brian Norris, Richard Weinberger, David Woodhouse

On Tue, 26 Sep 2017 12:39:24 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> Read Status and Read ID require tWHR before reading the first data.
> Insert a very short wait to make sure to meet the spec.
> 
> I have not seen any problem report for now, but nand_command() and
> nand_command_lP() are generic hooks, so it makes sense to implement
> fail-safe code here.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
>  drivers/mtd/nand/nand_base.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index b1cf32c..55c0ba5 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -742,9 +742,12 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
>  	case NAND_CMD_ERASE1:
>  	case NAND_CMD_ERASE2:
>  	case NAND_CMD_SEQIN:
> +	case NAND_CMD_SET_FEATURES:
> +		return;
> +
>  	case NAND_CMD_STATUS:
>  	case NAND_CMD_READID:
> -	case NAND_CMD_SET_FEATURES:
> +		ndelay(200);	/* tWHR */
>  		return;
>  
>  	case NAND_CMD_RESET:
> @@ -871,9 +874,12 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
>  	case NAND_CMD_ERASE1:
>  	case NAND_CMD_ERASE2:
>  	case NAND_CMD_SEQIN:
> +	case NAND_CMD_SET_FEATURES:
> +		return;
> +
>  	case NAND_CMD_STATUS:
>  	case NAND_CMD_READID:
> -	case NAND_CMD_SET_FEATURES:
> +		ndelay(200);	/* tWHR */

Can you do something like nand_ccs_delay() [1] instead of
unconditionally adding this 200ns delay here? I'm not worried about the
overhead introduced by this ndelay(), but I don't want to risk
introducing a regression.
 

>  		return;
>  
>  	case NAND_CMD_RNDIN:

[1]http://elixir.free-electrons.com/linux/v4.14-rc2/source/drivers/mtd/nand/nand_base.c#L793

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

* Re: [PATCH] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID
  2017-09-26  6:43 ` Boris Brezillon
@ 2017-09-26  8:17   ` Masahiro Yamada
  2017-09-26  8:23     ` Boris Brezillon
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2017-09-26  8:17 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Richard Weinberger, Linux Kernel Mailing List, Marek Vasut,
	linux-mtd, Cyrille Pitchen, Brian Norris, David Woodhouse

2017-09-26 15:43 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>:
> On Tue, 26 Sep 2017 12:39:24 +0900
> Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>
>> Read Status and Read ID require tWHR before reading the first data.
>> Insert a very short wait to make sure to meet the spec.
>>
>> I have not seen any problem report for now, but nand_command() and
>> nand_command_lP() are generic hooks, so it makes sense to implement
>> fail-safe code here.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>


OK, will do.



BTW, I see unconditional wait for tWB a few lines below,
but it gives no performance regression because we will wait
much longer in nand_wait_ready().


     /*
      * Apply this short delay always to ensure that we do wait tWB in
      * any case on any machine.
      */
     ndelay(100);

     nand_wait_ready(mtd);




-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID
  2017-09-26  8:17   ` Masahiro Yamada
@ 2017-09-26  8:23     ` Boris Brezillon
  0 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2017-09-26  8:23 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Richard Weinberger, Linux Kernel Mailing List, Marek Vasut,
	linux-mtd, Cyrille Pitchen, Brian Norris, David Woodhouse

On Tue, 26 Sep 2017 17:17:49 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> 2017-09-26 15:43 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>:
> > On Tue, 26 Sep 2017 12:39:24 +0900
> > Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> >  
> >> Read Status and Read ID require tWHR before reading the first data.
> >> Insert a very short wait to make sure to meet the spec.
> >>
> >> I have not seen any problem report for now, but nand_command() and
> >> nand_command_lP() are generic hooks, so it makes sense to implement
> >> fail-safe code here.
> >>
> >> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> >> ---  
> >  
> 
> 
> OK, will do.
> 
> 
> 
> BTW, I see unconditional wait for tWB a few lines below,
> but it gives no performance regression because we will wait
> much longer in nand_wait_ready().

Yep, but this one is here for quite some time. Normally there should be
no problem with your ndelay(200), but I don't want to take the risk
and have someone complain that his NAND controller driver is broken
because of this extra delay ;-).

> 
> 
>      /*
>       * Apply this short delay always to ensure that we do wait tWB in
>       * any case on any machine.
>       */
>      ndelay(100);
> 
>      nand_wait_ready(mtd);
> 
> 
> 
> 

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

end of thread, other threads:[~2017-09-26  8:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-26  3:39 [PATCH] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID Masahiro Yamada
2017-09-26  6:43 ` Boris Brezillon
2017-09-26  8:17   ` Masahiro Yamada
2017-09-26  8:23     ` Boris Brezillon

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).