linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nand wait timeout fix
@ 2010-11-03 11:38 Matthieu CASTET
  2010-11-13 12:13 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Matthieu CASTET @ 2010-11-03 11:38 UTC (permalink / raw)
  To: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 232 bytes --]

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 <matthieu.castet@parrot.com>

[-- Attachment #2: nand_wait.diff --]
[-- Type: text/x-diff, Size: 1143 bytes --]

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 12e4b72..07289c0 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -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;
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nand wait timeout fix
  2010-11-03 11:38 [PATCH] nand wait timeout fix Matthieu CASTET
@ 2010-11-13 12:13 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2010-11-13 12:13 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: linux-mtd

Matthieu,

On Wed, 2010-11-03 at 12:38 +0100, Matthieu CASTET wrote:
> 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 <matthieu.castet@parrot.com>

could you please improve commit message so that it would explain why you
do each of the changes, which problem you solve?

...

> @@ -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?

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-13 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-03 11:38 [PATCH] nand wait timeout fix Matthieu CASTET
2010-11-13 12:13 ` Artem Bityutskiy

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