flash bbt broken due to unitialized bitflip_threshold?
Shmulik Ladkani
shmulik.ladkani at gmail.com
Wed Jun 6 05:50:13 EDT 2012
Hi Sascha,
On Wed, 6 Jun 2012 00:06:47 +0200 Sascha Hauer <s.hauer at pengutronix.de> wrote:
> Hi All,
>
> nand_scan_tail calls chip->scan_bbt which in case of a flash based bbt
> calls mtd_read. mtd_read returns -EUCLEAN when the number of errors
> exceeds bitflip_threshold. The problem is that bitflip_threshold is
> uninitialized at that time, it is initialized in add_mtd_device which is
> called after nand_scan. This is seen on the mxc_nand controller, but
> probably on other drivers aswell.
>
> Am I missing something?
Yep, you are correct.
The result is that the BBTs will always be scrubbed (re-programmed).
I think the below fix is missing, should do the job.
Mike, does it look sane to you?
It assigns a 'bitflip_threshold' for the master mtd
(defaults to ecc_strength unless previously set by the driver).
It makes page reads of the BBT area adhere to an erase-block "health"
policy, either initially set by the driver, or set by default to
ecc_strength.
Note that if multiple partitions are later registered, one can't
later override the master's bitflip_threshold via sysfs.
But I guess this isn't important as the BBT is read once, when the nand
is probed.
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 61805e7..46c7d2b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3484,6 +3484,8 @@ int nand_scan_tail(struct mtd_info *mtd)
/* propagate ecc info to mtd_info */
mtd->ecclayout = chip->ecc.layout;
mtd->ecc_strength = chip->ecc.strength;
+ if (!mtd->bitflip_threshold)
+ mtd->bitflip_threshold = mtd->ecc_strength;
/* Check, if we should skip the bad block table scan */
if (chip->options & NAND_SKIP_BBTSCAN)
More information about the linux-mtd
mailing list