fixups for OOB ECC problems
Subsystems (2)
cover fixups for OOB ECC problems
Hello,
Now that we have added the possibility that mtd->read_oob returns -EUCLEAN or -EBADMSG for corrected bitflips and for uncorrectable errors, respectively, there are more pieces of code that need to take this into account. These patches should address some of these by ignoring bitflips when bit accuracy is not needed or by ignoring corrected errors when scrubbing would be unnecessary.
There are still other cases to address, for example, some flash-based BBT code.
This applies on top of l2-mtd-2.6.git. Patch 3 is an amendment to commit abf386c475beab813dc9b3366e592e00255e987a, ("mtd: nand: handle ECC errors in OOB"), so it can be squashed in if you want. Let me know if you want me to do this and do a resend.
Brian
Brian Norris (3):
mtd: nand: ignore ECC errors for simple BBM scans
mtd: tests: ignore corrected bitflips in OOB on mtd_readtest
mtd: edit NAND-related comment
drivers/mtd/mtdchar.c | 5 +++-- drivers/mtd/nand/nand_bbt.c | 13 ++++++++++--- drivers/mtd/tests/mtd_readtest.c | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-)
PATCH 1/3 mtd: nand: ignore ECC errors for simple BBM scans
Now that nand_do_readoob() may return -EUCLEAN or -EBADMSG on ECC errors, we need to handle the return value specially in some cases.
When scanning for simple bad block markers, reacting to an ECC error is not very useful, as we assume that the relevant markers are still non-0xFF for true bad blocks.
--- drivers/mtd/nand/nand_bbt.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
drivers/mtd/nand/nand_bbt.c +10 -3
@@ -312,14 +312,20 @@ static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs, ops.oobbuf = buf + len; ops.datbuf = buf; ops.len = len; -return mtd->read_oob (mtd, offs, &ops); + res = mtd->read_oob (mtd, offs, &ops); + +/* Ignore ECC errors when checking for BBM */ +if (res != -EUCLEAN && res != -EBADMSG ) +return res; +return 0 ; }else { ops.oobbuf = buf + mtd->writesize; ops.datbuf = buf; ops.len = mtd->writesize; res = mtd->read_oob (mtd, offs, &ops); -if (res) +/* Ignore ECC errors when checking for BBM */ +if (res && res != -EUCLEAN && res != -EBADMSG )return res; }
@@ -435,7 +441,8 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,* byte reads for 16 bit buswidth. */ ret = mtd->read_oob (mtd, offs, &ops); -if (ret) +/* Ignore ECC errors when checking for BBM */ +if (ret && ret != -EUCLEAN && ret != -EBADMSG )return ret;if (check_short_pattern (buf, bd))
Signature · 1 line
1.7.0.4
Artem Bityutskiy
AppliedRe: [PATCH 1/3] mtd: nand: ignore ECC errors for simple BBM scans
Quoted 11 lines · Brian Norris
Now that
nand_do_readoob()may return-EUCLEANor-EBADMSGon ECC errors, we need to handle the return value specially in some cases.When scanning for simple bad block markers, reacting to an ECC error is not very useful, as we assume that the relevant markers are still non-0xFF for true bad blocks.
Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/nand/nand_bbt.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
Pushed to l2-mtd-2.6.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy
PATCH 2/3 mtd: tests: ignore corrected bitflips in OOB on mtd_readtest
In reply to Brian Norrisread_oob may now return ECC error codes. If the code is -EUCLEAN, then we can safely ignore the error as a corrected bitflip.
--- drivers/mtd/tests/mtd_readtest.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mtd/tests/mtd_readtest.c +2 -1
@@ -75,7 +75,8 @@ static int read_eraseblock_by_page(int ebnum) ops.datbuf =NULL ; ops.oobbuf = oobbuf; ret = mtd->read_oob (mtd, addr, &ops); -if (ret || ops.oobretlen != mtd->oobsize) { +if (ret && ret != -EUCLEAN || + ops.oobretlen != mtd->oobsize) {printk (PRINT_PREF "error: read oob failed at " "%#llx\n" , (long long )addr);if (!err)
Signature · 1 line
1.7.0.4
PATCH 3/3 mtd: edit NAND-related comment
In reply to Brian NorrisThis comment was unclear regarding which NAND functions do and do not support ECC on the spare area. This update should reflect the current status of the NAND system but can be updated if changes are made in the standard functions.
--- drivers/mtd/mtdchar.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/mtdchar.c +3 -2
@@ -482,8 +482,9 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,* to signal the caller that a bitflip has occured and has * been corrected by the ECC algorithm. * -* Note: most NAND ECC algorithms do not calculate ECC -* for the OOB area. +* Note: currently the standard NAND function, nand_read_oob_std, +* does not calculate ECC for the OOB area, so do not rely on +* this behavior unless you have replaced it with your own. */ if (ret == -EUCLEAN || ret == -EBADMSG )return 0 ;
Signature · 1 line
1.7.0.4
Quoted 9 lines · Brian Norris
Hello,
Now that we have added the possibility that
mtd->read_oobreturns-EUCLEANor-EBADMSGfor corrected bitflips and for uncorrectable errors, respectively, there are more pieces of code that need to take this into account. These patches should address some of these by ignoring bitflips when bit accuracy is not needed or by ignoring corrected errors when scrubbing would be unnecessary.
Quoted 7 lines
There are still other cases to address, for example, some flash-based BBT code.
This applies on top of l2-mtd-2.6.git. Patch 3 is an amendment to commit
abf386c475beab813dc9b3366e592e00255e987a, ("mtd: nand: handle ECC errors in OOB"), so it can be squashed in if you want. Let me know if you want me to do this and do a resend.
Do you test these things somehow? I'd just injected some code to a driver or nandsim which returns -EUCLEAN for OOB and check what fails.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 10 lines · Artem Bityutskiy
Quoted 6 lines · Brian Norris
Now that we have added the possibility that
mtd->read_oobreturns-EUCLEANor-EBADMSGfor corrected bitflips and for uncorrectable errors, respectively, there are more pieces of code that need to take this into account. These patches should address some of these by ignoring bitflips when bit accuracy is not needed or by ignoring corrected errors when scrubbing would be unnecessary.Do you test these things somehow? I'd just injected some code to a driver or nandsim which returns
-EUCLEANfor OOB and check what fails.
Yes, I've done some testing.
Particularly, I was seeing a problem on boot-time BBM scan (scanning each block's spare area for a bad block marker), since every ECC error (correctable or uncorrectable) caused the scan to panic and quit. So if there were any ECC problems on the whole device, our BBM scan would fail and the device wouldn't be initialized. I tested this fix on this particular BBM scan issue, and I've tested some other general OOB injections and it looks good for now.
Brian