[PATCH v2 10/10] mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC

William Zhang william.zhang at broadcom.com
Wed Feb 22 02:20:30 CET 2023



On 02/11/2023 07:29 AM, Linus Walleij wrote:
> From: Álvaro Fernández Rojas <noltari at gmail.com>
> 
> 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.
> 
> Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
> Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
> Acked-by: Brian Norris <computersforpeace at gmail.com>
> Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
> Link: https://lore.kernel.org/linux-mtd/20210224080210.23686-1-noltari@gmail.com
> [Ported to U-Boot from the Linux kernel]
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
>   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 b2ebcaf7a5bf..efbf9a3120a4 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -2515,6 +2515,12 @@ static int brcmnand_init_cs(struct brcmnand_host *host, ofnode dn)
>   	ret = nand_register(0, mtd);
>   #endif /* __UBOOT__ */
>   
> +	/* 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;
>   }
>   
> 
Acked-by: William Zhang <william.zhang at broadcom.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4212 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20230221/d5103faf/attachment.bin>


More information about the U-Boot mailing list