Skip to contentSkip to conversation

nand wait timeout fix

PATCH In review Matthieu CASTET 2 participants 2 messages Nov 3, 2010 – Nov 13, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

drivers/mtd/nand/nand_base.c +4 -2
index 12e4b72..07289c0 100644
@@ -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;
 }
 
#1 lore raw

Matthieu,

Quoted 5 lines · Matthieu CASTET

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.

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 (Артём Битюцкий)