aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorÁlvaro Fernández Rojas <noltari@gmail.com>2021-01-22 11:10:12 +0100
committerÁlvaro Fernández Rojas <noltari@gmail.com>2021-01-22 11:36:49 +0100
commit2d8422842c7b2ca91956d9629f41083f99f12eac (patch)
tree588311dbef614359b817adb18587f71fb0a6c6a9 /target/linux
parentb3eccbca7c476c967af8e56c73061df2893ded7d (diff)
downloadupstream-2d8422842c7b2ca91956d9629f41083f99f12eac.tar.gz
upstream-2d8422842c7b2ca91956d9629f41083f99f12eac.tar.bz2
upstream-2d8422842c7b2ca91956d9629f41083f99f12eac.zip
bcm63xx: nand: fix OOB R/W for non Hamming ECC
Hamming ECC devices do not cover OOB data, as opposed to BCH ECC devices. Therefore, disabling ECC for all devices is preventing BCH devices from correctly reading and writing the OOB data. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/bcm63xx/patches-5.4/434-nand-brcmnand-fix-OOB-R-W-with-Hamming-ECC.patch34
-rw-r--r--target/linux/bcm63xx/patches-5.4/434-nand-raw-use-write_oob_raw-for-MTD_OPS_AUTO_OOB-mode.patch11
2 files changed, 34 insertions, 11 deletions
diff --git a/target/linux/bcm63xx/patches-5.4/434-nand-brcmnand-fix-OOB-R-W-with-Hamming-ECC.patch b/target/linux/bcm63xx/patches-5.4/434-nand-brcmnand-fix-OOB-R-W-with-Hamming-ECC.patch
new file mode 100644
index 0000000000..c3bb1ae1e8
--- /dev/null
+++ b/target/linux/bcm63xx/patches-5.4/434-nand-brcmnand-fix-OOB-R-W-with-Hamming-ECC.patch
@@ -0,0 +1,34 @@
+From cf0d2fbaae9e962d91a321de75e0d4f9f9ccbdfe Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
+Date: Thu, 21 Jan 2021 18:17:37 +0100
+Subject: [PATCH] nand: brcmnand: fix OOB R/W with Hamming ECC
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Hamming ECC doesn't cover the OOB data, so reading or writing OOB shall
+always be done without ECC enabled.
+This is a problem when adding JFFS2 cleanmarkers to erased blocks. When JFFS2
+clenmarkers are added to the OOB with ECC enabled, OOB bytes will be changed
+from ff ff ff to 00 00 00, reporting incorrect ECC errors.
+
+Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
+---
+ drivers/mtd/nand/raw/brcmnand/brcmnand.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+@@ -2426,6 +2426,12 @@ static int brcmnand_attach_chip(struct n
+
+ ret = brcmstb_choose_ecc_layout(host);
+
++ /* If OOB is written with ECC enabled it will cause ECC errors */
++ if (is_hamming_ecc(host->ctrl, &host->hwcfg)) {
++ chip->ecc.write_oob = brcmnand_write_oob_raw;
++ chip->ecc.read_oob = brcmnand_read_oob_raw;
++ }
++
+ return ret;
+ }
+
diff --git a/target/linux/bcm63xx/patches-5.4/434-nand-raw-use-write_oob_raw-for-MTD_OPS_AUTO_OOB-mode.patch b/target/linux/bcm63xx/patches-5.4/434-nand-raw-use-write_oob_raw-for-MTD_OPS_AUTO_OOB-mode.patch
deleted file mode 100644
index cf4322f29f..0000000000
--- a/target/linux/bcm63xx/patches-5.4/434-nand-raw-use-write_oob_raw-for-MTD_OPS_AUTO_OOB-mode.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/drivers/mtd/nand/raw/nand_base.c
-+++ b/drivers/mtd/nand/raw/nand_base.c
-@@ -488,7 +488,7 @@ static int nand_do_write_oob(struct nand
-
- nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops);
-
-- if (ops->mode == MTD_OPS_RAW)
-+ if (ops->mode == MTD_OPS_AUTO_OOB || ops->mode == MTD_OPS_RAW)
- status = chip->ecc.write_oob_raw(chip, page & chip->pagemask);
- else
- status = chip->ecc.write_oob(chip, page & chip->pagemask);