mtd: mxc_nand: fix OOB corruption when page size > 2KiB
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Mar 11 10:59:07 EST 2011
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=2c1c5f199482356c00f70b6f2f368c3455d1230c
Commit: 2c1c5f199482356c00f70b6f2f368c3455d1230c
Parent: f43272c482661bc88347bba237976eecfc1dbf5b
Author: Baruch Siach <baruch at tkos.co.il>
AuthorDate: Wed Mar 9 16:12:20 2011 +0200
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Mar 11 14:23:48 2011 +0000
mtd: mxc_nand: fix OOB corruption when page size > 2KiB
When page size is 4KiB, ecc.total is set to 8*9, and this causes
nand_write_page_hwecc() to read past the initialized part of the eccpos array,
which corrupts chip->oob_poi with bogus values from ecc_calc.
Fix this by creating a proper nand_ecclayout for 4KiB flashes.
Signed-off-by: Baruch Siach <baruch at tkos.co.il>
Acked-by: Sascha Hauer <s.hauer at pengutronix.de>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/nand/mxc_nand.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 6cd78ed..b7d5a5b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -211,6 +211,31 @@ static struct nand_ecclayout nandv2_hw_eccoob_largepage = {
}
};
+/* OOB description for 4096 byte pages with 128 byte OOB */
+static struct nand_ecclayout nandv2_hw_eccoob_4k = {
+ .eccbytes = 8 * 9,
+ .eccpos = {
+ 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 119, 120, 121, 122, 123, 124, 125, 126, 127,
+ },
+ .oobfree = {
+ {.offset = 2, .length = 4},
+ {.offset = 16, .length = 7},
+ {.offset = 32, .length = 7},
+ {.offset = 48, .length = 7},
+ {.offset = 64, .length = 7},
+ {.offset = 80, .length = 7},
+ {.offset = 96, .length = 7},
+ {.offset = 112, .length = 7},
+ }
+};
+
#ifdef CONFIG_MTD_PARTITIONS
static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
#endif
@@ -1186,6 +1211,8 @@ static int __init mxcnd_probe(struct platform_device *pdev)
if (mtd->writesize == 2048)
this->ecc.layout = oob_largepage;
+ if (nfc_is_v21() && mtd->writesize == 4096)
+ this->ecc.layout = &nandv2_hw_eccoob_4k;
/* second phase scan */
if (nand_scan_tail(mtd)) {
More information about the linux-mtd-cvs
mailing list