* [PATCH] mtd: rawnand: fsmc: Make sure we wait tWB before polling the STATUS reg
@ 2018-05-03 7:45 Boris Brezillon
2018-05-04 9:45 ` Miquel Raynal
0 siblings, 1 reply; 3+ messages in thread
From: Boris Brezillon @ 2018-05-03 7:45 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, Miquel Raynal, linux-mtd
Cc: David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen
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.
Fixes: 4da712e70294 ("mtd: nand: fsmc: use ->exec_op()")
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
drivers/mtd/nand/raw/fsmc_nand.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index 28c48dcc514e..0960665858b7 100644
--- a/drivers/mtd/nand/raw/fsmc_nand.c
+++ b/drivers/mtd/nand/raw/fsmc_nand.c
@@ -18,6 +18,7 @@
#include <linux/clk.h>
#include <linux/completion.h>
+#include <linux/delay.h>
#include <linux/dmaengine.h>
#include <linux/dma-direction.h>
#include <linux/dma-mapping.h>
@@ -695,6 +696,13 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,
pr_debug(" ->WAITRDY [max %d ms]\n",
instr->ctx.waitrdy.timeout_ms);
+ /*
+ * Make sure we wait tWB before polling the STATUS
+ * register.
+ */
+ if (op_id && op->instrs[op_id - 1].delay_ns)
+ ndelay(op->instrs[op_id - 1].delay_ns);
+
ret = nand_soft_waitrdy(chip,
instr->ctx.waitrdy.timeout_ms);
break;
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: rawnand: fsmc: Make sure we wait tWB before polling the STATUS reg
2018-05-03 7:45 [PATCH] mtd: rawnand: fsmc: Make sure we wait tWB before polling the STATUS reg Boris Brezillon
@ 2018-05-04 9:45 ` Miquel Raynal
2018-05-04 9:48 ` Boris Brezillon
0 siblings, 1 reply; 3+ messages in thread
From: Miquel Raynal @ 2018-05-04 9:45 UTC (permalink / raw)
To: Boris Brezillon
Cc: Richard Weinberger, linux-mtd, David Woodhouse, Brian Norris,
Marek Vasut, Cyrille Pitchen
Hi Boris,
On Thu, 3 May 2018 09:45:44 +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.
>
> Fixes: 4da712e70294 ("mtd: nand: fsmc: use ->exec_op()")
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
> drivers/mtd/nand/raw/fsmc_nand.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
> index 28c48dcc514e..0960665858b7 100644
> --- a/drivers/mtd/nand/raw/fsmc_nand.c
> +++ b/drivers/mtd/nand/raw/fsmc_nand.c
> @@ -18,6 +18,7 @@
>
> #include <linux/clk.h>
> #include <linux/completion.h>
> +#include <linux/delay.h>
> #include <linux/dmaengine.h>
> #include <linux/dma-direction.h>
> #include <linux/dma-mapping.h>
> @@ -695,6 +696,13 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,
> pr_debug(" ->WAITRDY [max %d ms]\n",
> instr->ctx.waitrdy.timeout_ms);
>
> + /*
> + * Make sure we wait tWB before polling the STATUS
> + * register.
> + */
> + if (op_id && op->instrs[op_id - 1].delay_ns)
> + ndelay(op->instrs[op_id - 1].delay_ns);
> +
> ret = nand_soft_waitrdy(chip,
> instr->ctx.waitrdy.timeout_ms);
> break;
I'm afraid that we encounter this exact same issue with all the drivers
using nand_soft_waitrdy() whenever the controller does not already
wait for tWB. Could we force a tWB_max delay directly inside
nand_soft_waitrdy()?
Thanks,
Miquèl
--
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: rawnand: fsmc: Make sure we wait tWB before polling the STATUS reg
2018-05-04 9:45 ` Miquel Raynal
@ 2018-05-04 9:48 ` Boris Brezillon
0 siblings, 0 replies; 3+ messages in thread
From: Boris Brezillon @ 2018-05-04 9:48 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, linux-mtd, David Woodhouse, Brian Norris,
Marek Vasut, Cyrille Pitchen
On Fri, 4 May 2018 11:45:10 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> Hi Boris,
>
> On Thu, 3 May 2018 09:45:44 +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.
> >
> > Fixes: 4da712e70294 ("mtd: nand: fsmc: use ->exec_op()")
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---
> > drivers/mtd/nand/raw/fsmc_nand.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
> > index 28c48dcc514e..0960665858b7 100644
> > --- a/drivers/mtd/nand/raw/fsmc_nand.c
> > +++ b/drivers/mtd/nand/raw/fsmc_nand.c
> > @@ -18,6 +18,7 @@
> >
> > #include <linux/clk.h>
> > #include <linux/completion.h>
> > +#include <linux/delay.h>
> > #include <linux/dmaengine.h>
> > #include <linux/dma-direction.h>
> > #include <linux/dma-mapping.h>
> > @@ -695,6 +696,13 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,
> > pr_debug(" ->WAITRDY [max %d ms]\n",
> > instr->ctx.waitrdy.timeout_ms);
> >
> > + /*
> > + * Make sure we wait tWB before polling the STATUS
> > + * register.
> > + */
> > + if (op_id && op->instrs[op_id - 1].delay_ns)
> > + ndelay(op->instrs[op_id - 1].delay_ns);
> > +
> > ret = nand_soft_waitrdy(chip,
> > instr->ctx.waitrdy.timeout_ms);
> > break;
>
> I'm afraid that we encounter this exact same issue with all the drivers
> using nand_soft_waitrdy() whenever the controller does not already
> wait for tWB. Could we force a tWB_max delay directly inside
> nand_soft_waitrdy()?
Yep, I agree. I'll send a new version doing that.
Thanks,
Boris
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-04 9:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 7:45 [PATCH] mtd: rawnand: fsmc: Make sure we wait tWB before polling the STATUS reg Boris Brezillon
2018-05-04 9:45 ` Miquel Raynal
2018-05-04 9:48 ` 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.