From ebb6e582d6bd8a8a2c660c230fa7db1abb48a71c Mon Sep 17 00:00:00 2001 From: Md Sadre Alam Date: Wed, 5 Apr 2023 10:56:43 +0530 Subject: [PATCH 187/281] mtd: rawnand: qcom: Fix ECC error for 4-bit ECC serial NAND This change will fix the ECC error for 4-bit ECC serial nand devices. The default ECC set by dts and currently its 8-bit ECC, since mostly all raw nand devices will support minimum 8-bit ECC. But for serial nand, which is having 4-bit ECC support, then read form device will be fail. error: [ 34.776865] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.1.19 #0 [ 34.786742] Hardware name: Qualcomm Technologies, Inc. IPQ5332 MI01.2 (DT) [ 34.794381] Call trace: [ 34.801058] dump_backtrace.part.0+0xb8/0xc4 [ 34.803404] show_stack+0x14/0x20 [ 34.807917] dump_stack_lvl+0x68/0x80 [ 34.811130] dump_stack+0x14/0x2c [ 34.814775] ubi_io_read+0x11c/0x310 [ 34.818074] ubi_io_read_ec_hdr+0x4c/0x1e4 [ 34.821721] ubi_attach+0x3dc/0x12d0 [ 34.825626] ubi_attach_mtd_dev+0x47c/0xaf0 [ 34.829359] ubi_init+0x134/0x31c [ 34.833264] do_one_initcall+0x4c/0x1c0 [ 34.836737] kernel_init_freeable+0x204/0x268 [ 34.840384] kernel_init+0x20/0x120 [ 34.844897] ret_from_fork+0x10/0x20 [ 34.849066] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 241:0, read only 64 bytes, retry [ 34.852574] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 241:0, read only 64 bytes, retry [ 34.863791] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 241:0, read only 64 bytes, retry [ 34.875079] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 241:0, read 64 bytes [ 34.885806] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.1.19 #0 Change-Id: Iab2798cd76f26eedb618bdbc621308f5ef556fde Signed-off-by: Md Sadre Alam --- drivers/mtd/nand/raw/qcom_nandc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index 5466452fe21b..f2696d1ac125 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -2937,6 +2937,8 @@ static int qcom_nand_attach_chip(struct nand_chip *chip) return ret; } + ecc->strength = mtd->oobsize >= 128 ? 8 : 4; + if (ecc->strength >= 8) { /* 8 bit ECC defaults to BCH ECC on all platforms */ host->bch_enabled = true; -- 2.17.1