mtd: nand: check status before reporting timeout

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Mar 24 11:59:10 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=9ebfdf5b18493f338237ef9861a555c2f79b0c17
Commit:     9ebfdf5b18493f338237ef9861a555c2f79b0c17
Parent:     3707b2c3d21f7c9f8c6aadba79ef012f0bbad10c
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Fri Mar 4 17:19:23 2016 -0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Mon Mar 7 13:51:11 2016 -0800

    mtd: nand: check status before reporting timeout
    
    In commit b70af9bef49b ("mtd: nand: increase ready wait timeout and
    report timeouts"), we increased the likelihood of scheduling during
    nand_wait(). This makes us more likely to hit the time_before(...)
    condition, since a lot of time may pass before we get scheduled again.
    
    Now, the loop was already buggy, since we don't check if the NAND is
    ready after exiting the loop; we simply print out a timeout warning. Fix
    this by doing a final status check before printing a timeout message.
    
    This isn't actually a critical bug, since the only effect is a false
    warning print. But too many prints never hurt anyone, did they? :)
    
    Side note: perhaps I'm not smart enough, but I'm not sure what the best
    policy is for this kind of loop; do we busy loop (i.e., no
    cond_resched()) to keep the lowest I/O latency (it's not great if the
    resched is delaying Richard's system ~400ms)? Or do we allow
    rescheduling, to play nice with the rest of the system (since some
    operations can take quite a while)?
    
    Reported-by: Richard Weinberger <richard at nod.at>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
    Reviewed-by: Richard Weinberger <richard at nod.at>
    Reviewed-by: Harvey Hunt <harvey.hunt at imgtec.com>
---
 drivers/mtd/nand/nand_base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index f2c8ff3..596a9b0 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -566,8 +566,8 @@ void nand_wait_ready(struct mtd_info *mtd)
 		cond_resched();
 	} while (time_before(jiffies, timeo));
 
-	pr_warn_ratelimited(
-		"timeout while waiting for chip to become ready\n");
+	if (!chip->dev_ready(mtd))
+		pr_warn_ratelimited("timeout while waiting for chip to become ready\n");
 out:
 	led_trigger_event(nand_led_trigger, LED_OFF);
 }



More information about the linux-mtd-cvs mailing list