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

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