linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [MTD] [OneNAND] Allow for controller errors when reading
@ 2008-04-14  6:39 Adrian Hunter
  0 siblings, 0 replies; only message in thread
From: Adrian Hunter @ 2008-04-14  6:39 UTC (permalink / raw)
  To: ext Kyungmin Park; +Cc: linux-mtd@lists.infradead.org

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.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
---
 drivers/mtd/onenand/onenand_base.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 15a62db..4171635 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -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;
 	}
 
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-14  6:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-14  6:39 [PATCH] [MTD] [OneNAND] Allow for controller errors when reading Adrian Hunter

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