octeon: use shared function for platform_copy_config()
[openwrt/staging/wigyori.git] / target / linux / bmips / patches-5.10 / 041-v5.13-mtd-rawnand-brcmnand-fix-OOB-R-W-with-Hamming-ECC.patch
1 From 095b4dabff2a929cefd330110c5c578956213188 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
3 Date: Wed, 24 Feb 2021 09:02:10 +0100
4 Subject: [PATCH] mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Hamming ECC doesn't cover the OOB data, so reading or writing OOB shall
10 always be done without ECC enabled.
11 This is a problem when adding JFFS2 cleanmarkers to erased blocks. If JFFS2
12 clenmarkers are added to the OOB with ECC enabled, OOB bytes will be changed
13 from ff ff ff to 00 00 00, reporting incorrect ECC errors.
14
15 Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
16 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
17 Acked-by: Brian Norris <computersforpeace@gmail.com>
18 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
19 Link: https://lore.kernel.org/linux-mtd/20210224080210.23686-1-noltari@gmail.com
20 ---
21 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 6 ++++++
22 1 file changed, 6 insertions(+)
23
24 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
25 +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
26 @@ -2694,6 +2694,12 @@ static int brcmnand_attach_chip(struct n
27 chip->ecc.read_oob = brcmnand_read_oob_raw;
28 }
29
30 + /* If OOB is written with ECC enabled it will cause ECC errors */
31 + if (is_hamming_ecc(host->ctrl, &host->hwcfg)) {
32 + chip->ecc.write_oob = brcmnand_write_oob_raw;
33 + chip->ecc.read_oob = brcmnand_read_oob_raw;
34 + }
35 +
36 return ret;
37 }
38