Skip to contentSkip to conversation

Allow for controller errors when reading

PATCH New Adrian Hunter 1 participant 1 message Apr 14, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow for controller errors when reading

A power loss while writing can result in a page becoming unreadable. When the device is mounted again, reading that page gives controller errors. Upper level software like JFFS2 treat -EIO as fatal, refusing to mount at all. That means it is necessary to treat the error as an ECC error to allow recovery. Note that typically in this case, the eraseblock can still be erased and rewritten i.e. it has not become a bad block.

---
drivers/mtd/onenand/onenand_base.c | 15 +++++++++++++++

1 files changed, 15 insertions(+), 0 deletions(-)
drivers/mtd/onenand/onenand_base.c +0 -0
index 15a62db..4171635 100644
@@ -329,6 +329,21 @@ static int onenand_wait(struct mtd_info *mtd, int state)
		printk(KERN_ERR "onenand_wait: controller error = 0x%04x\n", ctrl);
		if (ctrl & ONENAND_CTRL_LOCK)
			printk(KERN_ERR "onenand_wait: it's locked error.\n");

+ if (state == FL_READING) {
+ /*
+ * A power loss while writing can result in a page
+ * becoming unreadable. When the device is mounted
+ * again, reading that page gives controller errors.
+ * Upper level software like JFFS2 treat -EIO as fatal,
+ * refusing to mount at all. That means it is necessary
+ * to treat the error as an ECC error to allow recovery.
+ * Note that typically in this case, the eraseblock can
+ * still be erased and rewritten i.e. it has not become
+ * a bad block.
+ */
+ mtd->ecc_stats.failed++;
+ return -EBADMSG;
+ }

		return -EIO;
	}
Signature · 1 line
1.5.2.5