Skip to content

Commit 811db83

Browse files
miquelraynalgregkh
authored andcommitted
mtd: rawnand: Ensure ECC configuration is propagated to upper layers
commit 3a1b777 upstream. Until recently the "upper layer" was MTD. But following incremental reworks to bring spi-nand support and more recently generic ECC support, there is now an intermediate "generic NAND" layer that also needs to get access to some values. When using "converted" ECC engines, like the software ones, these values are already propagated correctly. But otherwise when using good old raw NAND controller drivers, we need to manually set these values ourselves at the end of the "scan" operation, once these values have been negotiated. Without this propagation, later (generic) checks like the one warning users that the ECC strength is not high enough might simply no longer work. Fixes: 8c12672 ("mtd: rawnand: Use the ECC framework nand_ecc_is_strong_enough() helper") Cc: stable@vger.kernel.org Reported-by: Sascha Hauer <s.hauer@pengutronix.de> Closes: https://lore.kernel.org/all/Zhe2JtvvN1M4Ompw@pengutronix.de/ Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.kernel.org/linux-mtd/20240507085842.108844-1-miquel.raynal@bootlin.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b6d2239 commit 811db83

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/mtd/nand/raw/nand_base.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6301,6 +6301,7 @@ static const struct nand_ops rawnand_ops = {
63016301
static int nand_scan_tail(struct nand_chip *chip)
63026302
{
63036303
struct mtd_info *mtd = nand_to_mtd(chip);
6304+
struct nand_device *base = &chip->base;
63046305
struct nand_ecc_ctrl *ecc = &chip->ecc;
63056306
int ret, i;
63066307

@@ -6445,16 +6446,22 @@ static int nand_scan_tail(struct nand_chip *chip)
64456446
if (!ecc->write_oob_raw)
64466447
ecc->write_oob_raw = ecc->write_oob;
64476448

6448-
/* propagate ecc info to mtd_info */
6449+
/* Propagate ECC info to the generic NAND and MTD layers */
64496450
mtd->ecc_strength = ecc->strength;
6451+
if (!base->ecc.ctx.conf.strength)
6452+
base->ecc.ctx.conf.strength = ecc->strength;
64506453
mtd->ecc_step_size = ecc->size;
6454+
if (!base->ecc.ctx.conf.step_size)
6455+
base->ecc.ctx.conf.step_size = ecc->size;
64516456

64526457
/*
64536458
* Set the number of read / write steps for one page depending on ECC
64546459
* mode.
64556460
*/
64566461
if (!ecc->steps)
64576462
ecc->steps = mtd->writesize / ecc->size;
6463+
if (!base->ecc.ctx.nsteps)
6464+
base->ecc.ctx.nsteps = ecc->steps;
64586465
if (ecc->steps * ecc->size != mtd->writesize) {
64596466
WARN(1, "Invalid ECC parameters\n");
64606467
ret = -EINVAL;

0 commit comments

Comments
 (0)