Skip to contentSkip to conversation

nand_ecc_is_strong_enough() doesn't trigger

DISCUSSION Sascha Hauer 2 participants 2 messages Apr 11, 2024 – May 7, 2024 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi,

I am currently working with a NAND chip requiring 4 bit correction per 512 byte data while my NAND driver only supports 1 bit correction, so I would assume this to trigger:

	/* ECC sanity check: warn if it's too weak */
	if (!nand_ecc_is_strong_enough(&chip->base))
		pr_warn("WARNING: %s: the ECC used on your system (%db/%dB) is too weak compared to the one required by the NAND chip (%db/%dB)\n",
                        mtd->name, chip->ecc.strength, chip->ecc.size,
                        nanddev_get_ecc_requirements(&chip->base)->strength,
                        nanddev_get_ecc_requirements(&chip->base)->step_size);

nand_ecc_is_strong_enough() works on nand->ecc.ctx.conf.step_size, but this only ever seems to be initialized by the various ecc-sw-* algorithms.

This was changed in 8c126720fe10 ("mtd: rawnand: Use the ECC framework nand_ecc_is_strong_enough() helper"). Before this patch the initialized values in &(struct nand_chip *chip)->ecc were used (and which are still used in the warning message above).

Do you have a direction how this should be fixed?

Thanks
Sascha

Signature · 8 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer
#1 lore raw

Hi,

[email protected] wrote on Thu, 11 Apr 2024 12:06:30 +0200:

Quoted 17 lines

Hi,

I am currently working with a NAND chip requiring 4 bit correction per 512 byte data while my NAND driver only supports 1 bit correction, so I would assume this to trigger:

	/* ECC sanity check: warn if it's too weak */
	if (!nand_ecc_is_strong_enough(&chip->base))
		pr_warn("WARNING: %s: the ECC used on your system (%db/%dB) is too weak compared to the one required by the NAND chip (%db/%dB)\n",
                        mtd->name, chip->ecc.strength, chip->ecc.size,
                        nanddev_get_ecc_requirements(&chip->base)->strength,
                        nanddev_get_ecc_requirements(&chip->base)->step_size);

nand_ecc_is_strong_enough() works on nand->ecc.ctx.conf.step_size, but this only ever seems to be initialized by the various ecc-sw-* algorithms.

Quoted 6 lines

This was changed in 8c126720fe10 ("mtd: rawnand: Use the ECC framework nand_ecc_is_strong_enough() helper"). Before this patch the initialized values in &(struct nand_chip *chip)->ecc were used (and which are still used in the warning message above).

Do you have a direction how this should be fixed?

I looked into it, we need to make sure the ECC values are propagated to the upper layers. If other people are following the thread, here is the proposal:
https://lore.kernel.org/linux-mtd/[email protected]/T/#u

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/