From: Matthieu CASTET <matthieu.castet@parrot.com>
To: Matthieu CASTET <matthieu.castet@parrot.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: bbt and bitflip
Date: Thu, 21 Apr 2011 19:17:07 +0200 [thread overview]
Message-ID: <4DB06693.5000100@parrot.com> (raw)
In-Reply-To: <4DB033E4.6030105@parrot.com>
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
Matthieu CASTET a écrit :
> Hi,
>
> the current bad block table implementation doesn't seem robust against bit flip.
>
> at boot we call :
> - search_read_bbts which scan for bbt using oob pattern.
> - check_create
> -- read_abs_bbt
> --- read_bbt which ignore ecc bit flip/error
>
> So if bit flip happen in BBT, we never scrub it.
> And if bit flip accumulate and we can't correct it anymore, the code will parse
> the corrupted data and our bad block info will be wrong (valid block can be
> marked as bad and we lose bad, bad block can be see as valid).
>
>
> Also the pattern and version in oob isn't protected by ecc. They can be corrupted.
>
> Are bbt safe to use ?
>
> Are there any plan to make the bbt more robust ?
>
Here a quick and dirty patch to make them more robust.
Any comment are welcomed.
Matthieu
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 1733 bytes --]
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 5fedf4a..7b85b54 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -171,7 +171,7 @@ static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
int bits, int offs, int reserved_block_code)
{
- int res, i, j, act = 0;
+ int res, i, j, act = 0, ret = 0;
struct nand_chip *this = mtd->priv;
size_t retlen, len, totlen;
loff_t from;
@@ -188,6 +188,12 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
printk(KERN_INFO "nand_bbt: Error reading bad block table\n");
return res;
}
+ if (res != -EUCLEAN) {
+ printk(KERN_INFO "nand_bbt: Error reading bad block table2\n");
+ return res;
+ }
+ /* inform caller that there is bit flips */
+ ret |= res;
printk(KERN_WARNING "nand_bbt: ECC error while reading bad block table\n");
}
@@ -220,7 +226,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
totlen -= len;
from += len;
}
- return 0;
+ return ret;
}
/**
@@ -900,7 +906,20 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
writecheck:
/* read back first ? */
if (rd)
- read_abs_bbt(mtd, buf, rd, chipsel);
+ res = read_abs_bbt(mtd, buf, rd, chipsel);
+ if (!rd2) {
+ if (res == -EBADMSG) {
+ /* bad recreate it */
+ rd = NULL;
+ writeops = 0x03;
+ goto create;
+ }
+ else if (!rd2 && res == -EUCLEAN) {
+ /* rewrite it */
+ writeops = 0x03;
+ }
+ }
+
/* If they weren't versioned, read both. */
if (rd2)
read_abs_bbt(mtd, buf, rd2, chipsel);
next prev parent reply other threads:[~2011-04-21 17:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 13:40 bbt and bitflip Matthieu CASTET
2011-04-21 17:17 ` Matthieu CASTET [this message]
2011-04-22 8:14 ` Artem Bityutskiy
2011-04-22 8:15 ` Artem Bityutskiy
2011-06-23 16:36 ` Brian Norris
2011-06-24 19:55 ` Artem Bityutskiy
2011-06-24 20:36 ` Matthew L. Creech
2011-04-22 8:08 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DB06693.5000100@parrot.com \
--to=matthieu.castet@parrot.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox