diff options
author | Shmulik Ladkani <shmulik@jungo.com> | 2012-06-08 11:29:06 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-06-09 07:02:04 -0400 |
commit | ea3b2ea24ef0f2ef9c6795b19cff456195b6728a (patch) | |
tree | 8a1c645a82a7329631166cf6e3f63857d401da40 | |
parent | cfaf025112d3856637ff34a767ef785ef5cf2ca9 (diff) |
mtd: nand: initialize bitflip_threshold prior to BBT scanning
As of edbc454 [mtd: driver _read() returns max_bitflips; mtd_read()
returns -EUCLEAN], 'mtd->bitflip_threshold' must be set for mtd devices
having ECC, prior any 'mtd_read()' call.
Otherwise, 'mtd_read()' will falsely return -EUCLEAN.
Normally, 'mtd->bitflip_threshold' is initialized when the MTD is added.
However, this is too late for NAND MTDs, as 'scan_bbt()' is invoked
prior the existing initialization of 'mtd->bitflip_threshold'.
This is a problem since 'scan_bbt()' calls 'mtd_read()', in the case
of a flash-based bad block table.
It resulted in a falsely reported bitflips indication during BBT read,
which lead to constant scrubbing of the flash BBT blocks.
Initialize 'mtd->bitflip_threshold' to its default value (if not already
set by the driver), prior to invocation of 'scan_bbt()'.
Reported-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index d47586cf64ce..a11253a0fcab 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -3501,6 +3501,13 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
3501 | /* propagate ecc info to mtd_info */ | 3501 | /* propagate ecc info to mtd_info */ |
3502 | mtd->ecclayout = chip->ecc.layout; | 3502 | mtd->ecclayout = chip->ecc.layout; |
3503 | mtd->ecc_strength = chip->ecc.strength; | 3503 | mtd->ecc_strength = chip->ecc.strength; |
3504 | /* | ||
3505 | * Initialize bitflip_threshold to its default prior scan_bbt() call. | ||
3506 | * scan_bbt() might invoke mtd_read(), thus bitflip_threshold must be | ||
3507 | * properly set. | ||
3508 | */ | ||
3509 | if (!mtd->bitflip_threshold) | ||
3510 | mtd->bitflip_threshold = mtd->ecc_strength; | ||
3504 | 3511 | ||
3505 | /* Check, if we should skip the bad block table scan */ | 3512 | /* Check, if we should skip the bad block table scan */ |
3506 | if (chip->options & NAND_SKIP_BBTSCAN) | 3513 | if (chip->options & NAND_SKIP_BBTSCAN) |