Skip to content

Commit ded6da2

Browse files
fschrempfgregkh
authored andcommitted
mtd: spinand: Fix incorrect parameters for on-die ECC
The new generic NAND ECC framework stores the configuration and requirements in separate places since commit 93ef92f ("mtd: nand: Use the new generic ECC object"). In 5.10.x The SPI NAND layer still uses only the requirements to track the ECC properties. This mismatch leads to values of zero being used for ECC strength and step_size in the SPI NAND layer wherever nanddev_get_ecc_conf() is used and therefore breaks the SPI NAND on-die ECC support in 5.10.x. By using nanddev_get_ecc_requirements() instead of nanddev_get_ecc_conf() for SPI NAND, we make sure that the correct parameters for the detected chip are used. In later versions (5.11.x) this is fixed anyway with the implementation of the SPI NAND on-die ECC engine. Cc: stable@vger.kernel.org # 5.10.x Reported-by: voice INTER connect GmbH <developer@voiceinterconnect.de> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3b2018f commit ded6da2

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/mtd/nand/spi/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static int spinand_check_ecc_status(struct spinand_device *spinand, u8 status)
419419
* fixed, so let's return the maximum possible value so that
420420
* wear-leveling layers move the data immediately.
421421
*/
422-
return nanddev_get_ecc_conf(nand)->strength;
422+
return nanddev_get_ecc_requirements(nand)->strength;
423423

424424
case STATUS_ECC_UNCOR_ERROR:
425425
return -EBADMSG;
@@ -1090,8 +1090,8 @@ static int spinand_init(struct spinand_device *spinand)
10901090
mtd->oobavail = ret;
10911091

10921092
/* Propagate ECC information to mtd_info */
1093-
mtd->ecc_strength = nanddev_get_ecc_conf(nand)->strength;
1094-
mtd->ecc_step_size = nanddev_get_ecc_conf(nand)->step_size;
1093+
mtd->ecc_strength = nanddev_get_ecc_requirements(nand)->strength;
1094+
mtd->ecc_step_size = nanddev_get_ecc_requirements(nand)->step_size;
10951095

10961096
return 0;
10971097

drivers/mtd/nand/spi/macronix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
8484
* data around if it's not necessary.
8585
*/
8686
if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
87-
return nanddev_get_ecc_conf(nand)->strength;
87+
return nanddev_get_ecc_requirements(nand)->strength;
8888

89-
if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
89+
if (WARN_ON(eccsr > nanddev_get_ecc_requirements(nand)->strength ||
9090
!eccsr))
91-
return nanddev_get_ecc_conf(nand)->strength;
91+
return nanddev_get_ecc_requirements(nand)->strength;
9292

9393
return eccsr;
9494

drivers/mtd/nand/spi/toshiba.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ static int tx58cxgxsxraix_ecc_get_status(struct spinand_device *spinand,
9090
* data around if it's not necessary.
9191
*/
9292
if (spi_mem_exec_op(spinand->spimem, &op))
93-
return nanddev_get_ecc_conf(nand)->strength;
93+
return nanddev_get_ecc_requirements(nand)->strength;
9494

9595
mbf >>= 4;
9696

97-
if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
98-
return nanddev_get_ecc_conf(nand)->strength;
97+
if (WARN_ON(mbf > nanddev_get_ecc_requirements(nand)->strength || !mbf))
98+
return nanddev_get_ecc_requirements(nand)->strength;
9999

100100
return mbf;
101101

0 commit comments

Comments
 (0)