Skip to contentSkip to conversation

mtd: rawnand: fsmc: Make sure we wait tWB before polling the STATUS reg

PATCH Superseded Boris Brezillon 2 participants 3 messages May 3, 2018 – May 4, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: fsmc: Make sure we wait tWB before polling the STATUS reg

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()")
---
 drivers/mtd/nand/raw/fsmc_nand.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mtd/nand/raw/fsmc_nand.c +8 -0
index 28c48dcc514e..0960665858b7 100644
@@ -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;
Signature · 1 line
2.14.1
maintainer
#1 lore raw

Hi Boris,

Quoted 26 lines · Boris Brezillon

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()")
---
 drivers/mtd/nand/raw/fsmc_nand.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mtd/nand/raw/fsmc_nand.c +1 -0
index 28c48dcc514e..0960665858b7 100644
@@ -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);
 

drivers/mtd/nand/raw/fsmc_nand.c static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op, · line 708

Quoted 10 lines
drivers/mtd/nand/raw/fsmc_nand.c +7 -0
+			/*
+			 * 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

Signature · 3 lines
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw
Quoted 31 lines · On Fri, 4 May 2018 11:45:10 +0200 Miquel Raynal <[email protected]>…

Hi Boris,

Quoted 26 lines · Boris Brezillon

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()")
---
 drivers/mtd/nand/raw/fsmc_nand.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mtd/nand/raw/fsmc_nand.c +1 -0
index 28c48dcc514e..0960665858b7 100644
@@ -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);
 
Quoted 15 lines

drivers/mtd/nand/raw/fsmc_nand.c static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op, · line 708

Quoted 10 lines
drivers/mtd/nand/raw/fsmc_nand.c +7 -0
+			/*
+			 * 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