mtd: nand_base: do not cache pages with uncorrectable ECC errors

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Oct 24 20:59:06 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=c1194c793240330ce59500d67737e3f28b4bde40
Commit:     c1194c793240330ce59500d67737e3f28b4bde40
Parent:     bc49c28962de0e3758ac2cdc7821d506b827f219
Author:     Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
AuthorDate: Fri Sep 3 22:01:16 2010 +0300
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Oct 25 00:13:34 2010 +0100

    mtd: nand_base: do not cache pages with uncorrectable ECC errors
    
    Currently MTD caches the last read NAND page, even if there was an uncorrectable ECC
    error. This patch prevents caching in case of uncorrectable ECC errors. The reason
    is that we want to allow the user to re-read the NAND page several times. In case of
    unstable bits re-trying may help.
    
    Moreover, current behavior is wrong because the first read returns -EBADMSG (correctly)
    but the second read succeeds and incorrectly returns 0 (because we read from the cache).
    
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/nand_base.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 922b890..0b70c17 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1505,7 +1505,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 			/* Transfer not aligned data */
 			if (!aligned) {
-				if (!NAND_SUBPAGE_READ(chip) && !oob)
+				if (!NAND_SUBPAGE_READ(chip) && !oob &&
+				    !(mtd->ecc_stats.failed - stats.failed))
 					chip->pagebuf = realpage;
 				memcpy(buf, chip->buffers->databuf + col, bytes);
 			}



More information about the linux-mtd-cvs mailing list