nand wait timeout fix
Subsystems (2)
PATCH 1/1 nand wait timeout fix
nand_wait_ready timeout should not depends of HZ value. panic_nand_wait take an relative timeout, not a absolute one. warn if nand_wait exit while the nand is still busy.
Signed-off-by Matthieu CASTET <[email protected]>
drivers/mtd/nand/nand_base.c +4 -2
@@ -519,7 +519,7 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)void nand_wait_ready (struct mtd_info *mtd) {struct nand_chip *chip = mtd->priv; -unsigned long timeo = jiffies +2 ; +unsigned long timeo = jiffies + (2 *HZ ) /1000 ;/* 400ms timeout */ if (in_interrupt () || oops_in_progress)
@@ -874,7 +874,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 );if (in_interrupt () || oops_in_progress) -panic_nand_wait (mtd, chip, timeo); +panic_nand_wait (mtd, chip,400 );else {while (time_before (jiffies, timeo)) {if (chip->dev_ready) {
@@ -890,6 +890,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)led_trigger_event (nand_led_trigger,LED_OFF ); status = (int )chip->read_byte (mtd); +/* This can happen if in case of timeout or buggy dev_ready */ +WARN_ON (!(status &NAND_STATUS_READY ));return status; }
Matthieu,
Quoted 5 lines · Matthieu CASTET
nand_wait_readytimeout should not depends of HZ value.panic_nand_waittake an relative timeout, not a absolute one. warn ifnand_waitexit while the nand is still busy.Signed-off-by Matthieu CASTET <[email protected]>
could you please improve commit message so that it would explain why you do each of the changes, which problem you solve?
...
drivers/mtd/nand/nand_base.c static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) · line 880
Quoted 9 lines
drivers/mtd/nand/nand_base.c +1
-1@@ -874,7 +874,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 );if (in_interrupt () || oops_in_progress) -panic_nand_wait (mtd, chip, timeo); +panic_nand_wait (mtd, chip,400 );else {while (time_before (jiffies, timeo)) {if (chip->dev_ready) {
In this cas timeo variable and its calculation can be moved to this inner block, I suppose?
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)