mtd: add ECC error accounting for each read request
authorMichał Kępień <kernel@kempniu.pl>
Wed, 29 Jun 2022 12:57:36 +0000 (14:57 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 21 Sep 2022 08:38:09 +0000 (10:38 +0200)
commit7bea6056927727f98f4efdd338f112f7517f05b5
tree748a4b19804e10df78486b563488c07ce2c84f54
parent745df17906029cc683b8b5ac8bcb08f82860baff
mtd: add ECC error accounting for each read request

Extend struct mtd_req_stats with two new fields holding the number of
corrected bitflips and uncorrectable errors detected during a read
operation.  This is a prerequisite for ultimately passing those counters
to user space, where they can be useful to applications for making
better-informed choices about moving data around.

Unlike 'max_bitflips' (which is set - in a common code path - to the
return value of a function called while the MTD device's mutex is held),
these counters have to be maintained in each MTD driver which defines
the '_read_oob' callback because the statistics need to be calculated
while the MTD device's mutex is held.

Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220629125737.14418-4-kernel@kempniu.pl
drivers/mtd/devices/docg3.c
drivers/mtd/nand/onenand/onenand_base.c
drivers/mtd/nand/raw/nand_base.c
drivers/mtd/nand/spi/core.c
include/linux/mtd/mtd.h