mtd: rawnand: micron: Fix support for on-die ECC
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Tue May 8 10:59:02 PDT 2018
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=630691850131bc3b8cc13fd9b9c6eedb4eb64ad4
Commit: 630691850131bc3b8cc13fd9b9c6eedb4eb64ad4
Parent: a2ee41fd953e7c3ff6c55a3038c80354d191a318
Author: Boris Brezillon <boris.brezillon at bootlin.com>
AuthorDate: Thu May 3 09:49:08 2018 +0200
Committer: Boris Brezillon <boris.brezillon at bootlin.com>
CommitDate: Mon May 7 09:42:55 2018 +0200
mtd: rawnand: micron: Fix support for on-die ECC
It looks like the NAND_STATUS_FAIL bit is sticky after an ECC failure,
which leads all READ operations following the failing one to report
an ECC failure. Reset the chip to clear the NAND_STATUS_FAIL bit.
Note that this behavior is not document in the datasheet, but resetting
the chip is the only solution we found to fix the problem.
Fixes: 9748e1d87573 ("mtd: nand: add support for Micron on-die ECC")
Cc: <stable at vger.kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon at bootlin.com>
Cc: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
Cc: Bean Huo <beanhuo at micron.com>
Cc: Peter Pan <peterpandong at micron.com>
Reviewed-by: Miquel Raynal <miquel.raynal at bootlin.com>
---
drivers/mtd/nand/raw/nand_micron.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c
index 0af45b134c0c..a915f568f6a3 100644
--- a/drivers/mtd/nand/raw/nand_micron.c
+++ b/drivers/mtd/nand/raw/nand_micron.c
@@ -153,6 +153,23 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip,
ret = nand_read_data_op(chip, chip->oob_poi, mtd->oobsize,
false);
+ /*
+ * Looks like the NAND_STATUS_FAIL bit is sticky after an ECC failure,
+ * which leads all READ operations following the failing one to report
+ * an ECC failure.
+ * Reset the chip to clear it.
+ *
+ * Note that this behavior is not document in the datasheet, but
+ * resetting the chip is the only solution we found to clear this bit.
+ */
+ if (status & NAND_STATUS_FAIL) {
+ int cs = page >> (chip->chip_shift - chip->page_shift);
+
+ chip->select_chip(mtd, -1);
+ nand_reset(chip, cs);
+ chip->select_chip(mtd, cs);
+ }
+
out:
micron_nand_on_die_ecc_setup(chip, false);
More information about the linux-mtd-cvs
mailing list