[MTD] [OneNAND] Allow for controller errors when reading

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Apr 22 16:59:01 EDT 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=67e5a28b35254bbbcd5bfce61ef646709e059bbf
Commit:     67e5a28b35254bbbcd5bfce61ef646709e059bbf
Parent:     f1ebe4eba40e0ee862767893277d1b1a1e4cc85f
Author:     Adrian Hunter <ext-adrian.hunter at nokia.com>
AuthorDate: Mon Apr 14 09:39:39 2008 +0300
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Tue Apr 22 21:26:16 2008 +0100

    [MTD] [OneNAND] 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.
    
    Signed-off-by: Adrian Hunter <ext-adrian.hunter at nokia.com>
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 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 56255c8..5d7965f 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;
 	}
 



More information about the linux-mtd-cvs mailing list