All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: rawnand: Make sure we wait tWB before polling the STATUS reg
@ 2018-05-04 19:24 Boris Brezillon
  2018-05-06 21:56 ` Miquel Raynal
  2018-05-07  9:35 ` Boris Brezillon
  0 siblings, 2 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-05-04 19:24 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, Miquel Raynal, linux-mtd
  Cc: David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen, stable

NAND chips require a bit of time to take the NAND operation into
account and set the BUSY bit in the STATUS reg. Make sure we don't poll
the STATUS reg too early in nand_soft_waitrdy().

Fixes: 8878b126df76 ("mtd: nand: add ->exec_op() implementation")
Cc: <stable@vger.kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
Changes in v2:
- Move the ndelay() to nand_soft_waitrdy() instead of having it in the
  FSMC driver
---
 drivers/mtd/nand/raw/nand_base.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 72f3a89da513..da94fcb4dd9b 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -706,12 +706,17 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)
  */
 int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
 {
+	const struct nand_sdr_timings *timings;
 	u8 status = 0;
 	int ret;
 
 	if (!chip->exec_op)
 		return -ENOTSUPP;
 
+	/* Wait tWB before polling the STATUS reg. */
+	timings = nand_get_sdr_timings(&chip->data_interface);
+	ndelay(PSEC_TO_NSEC(sdr->tWB_max));
+
 	ret = nand_status_op(chip, NULL);
 	if (ret)
 		return ret;
-- 
2.14.1

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

* Re: [PATCH v2] mtd: rawnand: Make sure we wait tWB before polling the STATUS reg
  2018-05-04 19:24 [PATCH v2] mtd: rawnand: Make sure we wait tWB before polling the STATUS reg Boris Brezillon
@ 2018-05-06 21:56 ` Miquel Raynal
  2018-05-07  9:35 ` Boris Brezillon
  1 sibling, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2018-05-06 21:56 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Richard Weinberger, linux-mtd, David Woodhouse, Brian Norris,
	Marek Vasut, Cyrille Pitchen, stable

Hi Boris,

On Fri,  4 May 2018 21:24:31 +0200, Boris Brezillon
<boris.brezillon@bootlin.com> wrote:

> NAND chips require a bit of time to take the NAND operation into
> account and set the BUSY bit in the STATUS reg. Make sure we don't poll
> the STATUS reg too early in nand_soft_waitrdy().
> 
> Fixes: 8878b126df76 ("mtd: nand: add ->exec_op() implementation")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

-- 
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v2] mtd: rawnand: Make sure we wait tWB before polling the STATUS reg
  2018-05-04 19:24 [PATCH v2] mtd: rawnand: Make sure we wait tWB before polling the STATUS reg Boris Brezillon
  2018-05-06 21:56 ` Miquel Raynal
@ 2018-05-07  9:35 ` Boris Brezillon
  2018-05-08 21:11   ` Boris Brezillon
  1 sibling, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2018-05-07  9:35 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, Miquel Raynal, linux-mtd
  Cc: Marek Vasut, Brian Norris, David Woodhouse, stable, Cyrille Pitchen

On Fri,  4 May 2018 21:24:31 +0200
Boris Brezillon <boris.brezillon@bootlin.com> wrote:

> NAND chips require a bit of time to take the NAND operation into
> account and set the BUSY bit in the STATUS reg. Make sure we don't poll
> the STATUS reg too early in nand_soft_waitrdy().
> 
> Fixes: 8878b126df76 ("mtd: nand: add ->exec_op() implementation")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
> Changes in v2:
> - Move the ndelay() to nand_soft_waitrdy() instead of having it in the
>   FSMC driver
> ---
>  drivers/mtd/nand/raw/nand_base.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 72f3a89da513..da94fcb4dd9b 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -706,12 +706,17 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)
>   */
>  int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
>  {
> +	const struct nand_sdr_timings *timings;
>  	u8 status = 0;
>  	int ret;
>  
>  	if (!chip->exec_op)
>  		return -ENOTSUPP;
>  
> +	/* Wait tWB before polling the STATUS reg. */
> +	timings = nand_get_sdr_timings(&chip->data_interface);
> +	ndelay(PSEC_TO_NSEC(sdr->tWB_max));

			    ^ timings->tWB_max

And for those who wonder, yes, I compiled the code, but it seems I
forgot to amend the commit after fixing the bug locally :-).

> +
>  	ret = nand_status_op(chip, NULL);
>  	if (ret)
>  		return ret;

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

* Re: [PATCH v2] mtd: rawnand: Make sure we wait tWB before polling the STATUS reg
  2018-05-07  9:35 ` Boris Brezillon
@ 2018-05-08 21:11   ` Boris Brezillon
  0 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-05-08 21:11 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, Miquel Raynal, linux-mtd
  Cc: Marek Vasut, Brian Norris, David Woodhouse, stable, Cyrille Pitchen

On Mon, 7 May 2018 11:35:22 +0200
Boris Brezillon <boris.brezillon@bootlin.com> wrote:

> On Fri,  4 May 2018 21:24:31 +0200
> Boris Brezillon <boris.brezillon@bootlin.com> wrote:
> 
> > NAND chips require a bit of time to take the NAND operation into
> > account and set the BUSY bit in the STATUS reg. Make sure we don't poll
> > the STATUS reg too early in nand_soft_waitrdy().
> > 
> > Fixes: 8878b126df76 ("mtd: nand: add ->exec_op() implementation")
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---
> > Changes in v2:
> > - Move the ndelay() to nand_soft_waitrdy() instead of having it in the
> >   FSMC driver
> > ---
> >  drivers/mtd/nand/raw/nand_base.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> > index 72f3a89da513..da94fcb4dd9b 100644
> > --- a/drivers/mtd/nand/raw/nand_base.c
> > +++ b/drivers/mtd/nand/raw/nand_base.c
> > @@ -706,12 +706,17 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)
> >   */
> >  int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
> >  {
> > +	const struct nand_sdr_timings *timings;
> >  	u8 status = 0;
> >  	int ret;
> >  
> >  	if (!chip->exec_op)
> >  		return -ENOTSUPP;
> >  
> > +	/* Wait tWB before polling the STATUS reg. */
> > +	timings = nand_get_sdr_timings(&chip->data_interface);
> > +	ndelay(PSEC_TO_NSEC(sdr->tWB_max));  
> 
> 			    ^ timings->tWB_max
> 
> And for those who wonder, yes, I compiled the code, but it seems I
> forgot to amend the commit after fixing the bug locally :-).

Queued to mtd/master after fixing the problem.

> 
> > +
> >  	ret = nand_status_op(chip, NULL);
> >  	if (ret)
> >  		return ret;  
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2018-05-08 21:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 19:24 [PATCH v2] mtd: rawnand: Make sure we wait tWB before polling the STATUS reg Boris Brezillon
2018-05-06 21:56 ` Miquel Raynal
2018-05-07  9:35 ` Boris Brezillon
2018-05-08 21:11   ` Boris Brezillon

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.