Skip to contentSkip to conversation

cfi: prevent kernel panic with cfi flash

PATCH In review Jan Pedersen 2 participants 2 messages Sep 27, 2005 – Sep 30, 2005 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cfi: prevent kernel panic with cfi flash

When using the cfi (common flash interface) driver, every word written to the flash chips is followed by a operation complete poll. This poll is intended to have a timeout of 1 ms. However this timeout is calculated by HZ/1000, which happends to be 0 because HZ < 1000. The result of this is that there will be just one poll for operation complete. If this single poll fails, the kernel panics. This patch increases this timeout to HZ (1 second). This is far more than needed, but is preferred over a panic. This fix is well tested and completely avoids the panic.

---
diff -Naur linux-2.4.31.org/drivers/mtd/chips/cfi_cmdset_0002.c linux-2.4.31/drivers/mtd/chips/cfi_cmdset_0002.c
--- linux-2.4.31.org/drivers/mtd/chips/cfi_cmdset_0002.c 2004-11-17
06:54:21.000000000 -0500
+++ linux-2.4.31/drivers/mtd/chips/cfi_cmdset_0002.c 2005-08-22
12:14:17.000000000 -0400
@@ -510,7 +510,7 @@
or tells us why it failed. */
dq6 = CMD(1<<6);
dq5 = CMD(1<<5);
- timeo = jiffies + (HZ/1000); /* setting timeout to 1ms for now */
+ timeo = jiffies + (HZ); /* setting timeout to 1s for now */

oldstatus = cfi_read(map, adr);
status = cfi_read(map, adr);

#1 lore raw
Quoted 10 lines · Jan Pedersen

When using the cfi (common flash interface) driver, every word written to the flash chips is followed by a operation complete poll. This poll is intended to have a timeout of 1 ms. However this timeout is calculated by HZ/1000, which happends to be 0 because HZ < 1000. The result of this is that there will be just one poll for operation complete. If this single poll fails, the kernel panics. This patch increases this timeout to HZ (1 second). This is far more than needed, but is preferred over a panic. This fix is well tested and completely avoids the panic.

Patch looks good to me - but this code isn't maintained by linux-mips.org, so you may want to resend your patches here:

MEMORY TECHNOLOGY DEVICES

P:      David Woodhouse
M:      [email protected]
W:      http://www.linux-mtd.infradead.org/
L:      [email protected]
S:      Maintained

Thanks anyway,

Ralf