Re: [PATCH v2] mtd: nand: brcmnand: fix mtd corrected bits stat

David Regan
2025-06-26T16:28:08Z

Hi Miquèl,

On Wed, Jun 18, 2025 at 2:07 AM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> Hello David,
>
...
> Here however there is something wrong. We do expect a read failure,
> instead of returning wrong data. There is still a problem, I do not know
> if this problem was there before though, but this must be fixed.

This was user error as I picked the wrong partition to test. There's a
hardware limitation in which the first ECC chunk in page zero of block
zero is ECC protected however the hardware flag to signify an ECC
problem does not trigger (as can be seen by the result.) This
limitation only affects page 0 of block 0 where it is typically a
bootloader raw partition that is not under the management of the Linux
file system, and in addition we have extra checksum/signature
verification and loader redundancies to account for this limitation.

Here is the result of the nandbiterrs test using a different partition:

# insmod mtd_nandbiterrs.ko dev=2
[ 30.670312]
[ 30.671853] ==================================================
[ 30.677713] mtd_nandbiterrs: MTD device: 2
[ 30.681818] mtd_nandbiterrs: MTD device size 8388608,
eraseblock=262144, page=4096, oob=216
[ 30.690175] mtd_nandbiterrs: Device uses 1 subpages of 4096 bytes
[ 30.696273] mtd_nandbiterrs: Using page=0, offset=0, eraseblock=0
[ 30.703951] mtd_nandbiterrs: incremental biterrors test
[ 30.709242] mtd_nandbiterrs: write_page
[ 30.713851] mtd_nandbiterrs: rewrite page
[ 30.718562] mtd_nandbiterrs: read_page
[ 30.722708] mtd_nandbiterrs: verify_page
[ 30.726711] mtd_nandbiterrs: Successfully corrected 0 bit errors per subpage
[ 30.733764] mtd_nandbiterrs: Inserted biterror @ 0/5
[ 30.738733] mtd_nandbiterrs: rewrite page
[ 30.743443] mtd_nandbiterrs: read_page
[ 30.747588] mtd_nandbiterrs: Read reported 1 corrected bit errors
[ 30.753686] mtd_nandbiterrs: verify_page
[ 30.757688] mtd_nandbiterrs: Successfully corrected 1 bit errors per subpage
[ 30.764741] mtd_nandbiterrs: Inserted biterror @ 0/2
[ 30.769710] mtd_nandbiterrs: rewrite page
[ 30.774475] mtd_nandbiterrs: read_page
[ 30.778620] mtd_nandbiterrs: Read reported 2 corrected bit errors
[ 30.784718] mtd_nandbiterrs: verify_page
[ 30.788721] mtd_nandbiterrs: Successfully corrected 2 bit errors per subpage
[ 30.795773] mtd_nandbiterrs: Inserted biterror @ 0/0
[ 30.800743] mtd_nandbiterrs: rewrite page
[ 30.805502] mtd_nandbiterrs: read_page
[ 30.809647] mtd_nandbiterrs: Read reported 3 corrected bit errors
[ 30.815745] mtd_nandbiterrs: verify_page
[ 30.819748] mtd_nandbiterrs: Successfully corrected 3 bit errors per subpage
[ 30.826801] mtd_nandbiterrs: Inserted biterror @ 1/7
[ 30.831770] mtd_nandbiterrs: rewrite page
[ 30.836480] mtd_nandbiterrs: read_page
[ 30.840625] mtd_nandbiterrs: Read reported 4 corrected bit errors
[ 30.846723] mtd_nandbiterrs: verify_page
[ 30.850725] mtd_nandbiterrs: Successfully corrected 4 bit errors per subpage
[ 30.857777] mtd_nandbiterrs: Inserted biterror @ 1/5
[ 30.862746] mtd_nandbiterrs: rewrite page
[ 30.867457] mtd_nandbiterrs: read_page
[ 30.871602] mtd_nandbiterrs: Read reported 5 corrected bit errors
[ 30.877700] mtd_nandbiterrs: verify_page
[ 30.881702] mtd_nandbiterrs: Successfully corrected 5 bit errors per subpage
[ 30.888754] mtd_nandbiterrs: Inserted biterror @ 1/2
[ 30.893722] mtd_nandbiterrs: rewrite page
[ 30.898433] mtd_nandbiterrs: read_page
[ 30.902581] mtd_nandbiterrs: Read reported 6 corrected bit errors
[ 30.908679] mtd_nandbiterrs: verify_page
[ 30.912681] mtd_nandbiterrs: Successfully corrected 6 bit errors per subpage
[ 30.919734] mtd_nandbiterrs: Inserted biterror @ 1/0
[ 30.924704] mtd_nandbiterrs: rewrite page
[ 30.929412] mtd_nandbiterrs: read_page
[ 30.929808] mtd_nandbiterrs: Read reported 7 corrected bit errors
[ 30.929810] mtd_nandbiterrs: verify_page
[ 30.929887] mtd_nandbiterrs: Successfully corrected 7 bit errors per subpage
[ 30.929889] mtd_nandbiterrs: Inserted biterror @ 2/6
[ 30.929891] mtd_nandbiterrs: rewrite page
[ 30.960226] mtd_nandbiterrs: read_page
[ 30.964374] mtd_nandbiterrs: Read reported 8 corrected bit errors
[ 30.970476] mtd_nandbiterrs: verify_page
[ 30.974480] mtd_nandbiterrs: Successfully corrected 8 bit errors per subpage
[ 30.981533] mtd_nandbiterrs: Inserted biterror @ 2/5
[ 30.986528] mtd_nandbiterrs: rewrite page
[ 30.991289] mtd_nandbiterrs: read_page
[ 30.996228] bcmbca_nand ff801800.nand-controller: uncorrectable
error at 0x1f700000
[ 31.003892] mtd_nandbiterrs: error: read failed at 0x0
[ 31.009035] mtd_nandbiterrs: After 9 biterrors per subpage, read
reported error -74
[ 31.018263] mtd_nandbiterrs: finished successfully.
[ 31.023146] ==================================================
[ 31.051035]
[ 31.052530] ==================================================
[ 31.058369] mtd_nandbiterrs: MTD device: 2
[ 31.062475] mtd_nandbiterrs: MTD device size 8388608,
eraseblock=262144, page=4096, oob=216
[ 31.070832] mtd_nandbiterrs: Device uses 1 subpages of 4096 bytes
[ 31.076931] mtd_nandbiterrs: Using page=0, offset=0, eraseblock=0
[ 31.083751] mtd_nandbiterrs: incremental biterrors test
[ 31.089041] mtd_nandbiterrs: write_page
[ 31.093643] mtd_nandbiterrs: rewrite page
[ 31.098354] mtd_nandbiterrs: read_page
[ 31.102496] mtd_nandbiterrs: verify_page
[ 31.106498] mtd_nandbiterrs: Successfully corrected 0 bit errors per subpage
[ 31.113549] mtd_nandbiterrs: Inserted biterror @ 0/5
[ 31.113552] mtd_nandbiterrs: rewrite page
[ 31.114250] mtd_nandbiterrs: read_page
[ 31.127333] mtd_nandbiterrs: Read reported 1 corrected bit errors
[ 31.133431] mtd_nandbiterrs: verify_page
[ 31.137435] mtd_nandbiterrs: Successfully corrected 1 bit errors per subpage
[ 31.144509] mtd_nandbiterrs: Inserted biterror @ 0/2
[ 31.149480] mtd_nandbiterrs: rewrite page
[ 31.154240] mtd_nandbiterrs: read_page
[ 31.158385] mtd_nandbiterrs: Read reported 2 corrected bit errors
[ 31.164483] mtd_nandbiterrs: verify_page
[ 31.168486] mtd_nandbiterrs: Successfully corrected 2 bit errors per subpage
[ 31.175552] mtd_nandbiterrs: Inserted biterror @ 0/0
[ 31.180522] mtd_nandbiterrs: rewrite page
[ 31.185282] mtd_nandbiterrs: read_page
[ 31.189428] mtd_nandbiterrs: Read reported 3 corrected bit errors
[ 31.195524] mtd_nandbiterrs: verify_page
[ 31.195602] mtd_nandbiterrs: Successfully corrected 3 bit errors per subpage
[ 31.195604] mtd_nandbiterrs: Inserted biterror @ 1/7
[ 31.195606] mtd_nandbiterrs: rewrite page
[ 31.196304] mtd_nandbiterrs: read_page
[ 31.196696] mtd_nandbiterrs: Read reported 4 corrected bit errors
[ 31.196698] mtd_nandbiterrs: verify_page
[ 31.196776] mtd_nandbiterrs: Successfully corrected 4 bit errors per subpage
[ 31.196778] mtd_nandbiterrs: Inserted biterror @ 1/5
[ 31.196780] mtd_nandbiterrs: rewrite page
[ 31.197477] mtd_nandbiterrs: read_page
[ 31.197869] mtd_nandbiterrs: Read reported 5 corrected bit errors
[ 31.197871] mtd_nandbiterrs: verify_page
[ 31.197948] mtd_nandbiterrs: Successfully corrected 5 bit errors per subpage
[ 31.197950] mtd_nandbiterrs: Inserted biterror @ 1/2
[ 31.197952] mtd_nandbiterrs: rewrite page
[ 31.278059] mtd_nandbiterrs: read_page
[ 31.282207] mtd_nandbiterrs: Read reported 6 corrected bit errors
[ 31.288323] mtd_nandbiterrs: verify_page
[ 31.292327] mtd_nandbiterrs: Successfully corrected 6 bit errors per subpage
[ 31.299380] mtd_nandbiterrs: Inserted biterror @ 1/0
[ 31.304349] mtd_nandbiterrs: rewrite page
[ 31.309059] mtd_nandbiterrs: read_page
[ 31.313207] mtd_nandbiterrs: Read reported 7 corrected bit errors
[ 31.319306] mtd_nandbiterrs: verify_page
[ 31.323308] mtd_nandbiterrs: Successfully corrected 7 bit errors per subpage
[ 31.330360] mtd_nandbiterrs: Inserted biterror @ 2/6
[ 31.335335] mtd_nandbiterrs: rewrite page
[ 31.340045] mtd_nandbiterrs: read_page
[ 31.344194] mtd_nandbiterrs: Read reported 8 corrected bit errors
[ 31.350291] mtd_nandbiterrs: verify_page
[ 31.354294] mtd_nandbiterrs: Successfully corrected 8 bit errors per subpage
[ 31.361347] mtd_nandbiterrs: Inserted biterror @ 2/5
[ 31.366316] mtd_nandbiterrs: rewrite page
[ 31.371076] mtd_nandbiterrs: read_page
[ 31.376011] bcmbca_nand ff801800.nand-controller: uncorrectable
error at 0x1f700000
[ 31.383674] mtd_nandbiterrs: error: read failed at 0x0
[ 31.388818] mtd_nandbiterrs: After 9 biterrors per subpage, read
reported error -74
[ 31.398046] mtd_nandbiterrs: finished successfully.
[ 31.402928] ==================================================

> Cheers,
> Miquèl

Thanks!

-Dave