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

Miquel Raynal miquel.raynal at bootlin.com
Mon Jun 9 02:20:09 PDT 2025


On 06/06/2025 at 09:57:03 -07, David Regan <dregan at broadcom.com> wrote:

> Currently we attempt to get the amount of flipped bits from a hardware
> location which is reset on every subpage. Instead obtain total flipped
> bits stat from hardware accumulator. In addition identify the correct
> maximum subpage corrected bits.
>
> Signed-off-by: David Regan <dregan at broadcom.com>
> Reviewed-by: William Zhang <william.zhang at broadcom.com>
> ---

Hello,

Can you please give the output of nandbiterrs -i /dev/mtdX?

>  v2: Add >= v4 NAND controller support as requested by Jonas.
>      mtd->ecc_stats.corrected accumulates instead of set to total.
>      Remove DMA specific flipped bits count.

The changelog does not mention the fact that you return the maximum
number of corrected bitflips as I requested, and the diff does not show
a straightforward implementation of that. It is very important to get
this right.

If we take the following example of a page with 4 ECC steps, if we get
respectively: 0, 2, 3, 0 bitflips per step, the returned value shall be
3.

To be very certain that this is correct, you can use the nandflipbit
tool from the mtd-utils test suite. You can manually insert bitflips in
various areas of a page and then read the page again with ECC enabled
and see how many bit errors are reported.

Thanks,
Miquèl



More information about the linux-mtd mailing list