linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nand: brcmnand: fix OOB R/W with Hamming ECC
@ 2021-02-22 20:16 Álvaro Fernández Rojas
  2021-02-24  3:46 ` Florian Fainelli
  2021-02-24  8:02 ` [PATCH v2] " Álvaro Fernández Rojas
  0 siblings, 2 replies; 10+ messages in thread
From: Álvaro Fernández Rojas @ 2021-02-22 20:16 UTC (permalink / raw)
  To: Brian Norris, Kamal Dasu, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, linux-mtd, bcm-kernel-feedback-list,
	linux-kernel
  Cc: Álvaro Fernández Rojas

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. If 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(+)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 659eaa6f0980..5ff4291380c5 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -2688,6 +2688,12 @@ static int brcmnand_attach_chip(struct nand_chip *chip)
 
 	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;
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-03-02 19:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 20:16 [PATCH] nand: brcmnand: fix OOB R/W with Hamming ECC Álvaro Fernández Rojas
2021-02-24  3:46 ` Florian Fainelli
2021-02-24  7:16   ` Álvaro Fernández Rojas
2021-02-24  7:38     ` Miquel Raynal
2021-02-24  8:02 ` [PATCH v2] " Álvaro Fernández Rojas
2021-02-24 21:01   ` Brian Norris
2021-02-25  7:48     ` Miquel Raynal
2021-02-25  7:54       ` Álvaro Fernández Rojas
2021-02-25  8:12         ` Miquel Raynal
2021-03-02 16:32   ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).