* [PATCH] MTD: NAND: Fix bad-block detection for 8-bit NAND
@ 2007-09-26 14:10 Frank Haverkamp
2007-09-26 15:10 ` Thomas Gleixner
0 siblings, 1 reply; 2+ messages in thread
From: Frank Haverkamp @ 2007-09-26 14:10 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: David Woodhouse, haver, MTD Mailinglist
[-- Attachment #1: Type: text/plain, Size: 2187 bytes --]
Hi Thomas,
I found the following block in our 128MiB NAND flash:
hexdump vic.img.460
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000800 00ff 0000 0000 0000 0000 0000 0000 0000
0000810 0000 0000 0000 0000 0000 0000 0000 0000
*
0001040 00ff 0000 0000 0000 0000 0000 0000 0000
0001050 0000 0000 0000 0000 0000 0000 0000 0000
*
0021000
According to the specification this is a good block, because the bytes
in the 1st two OOB areas at offset 0 are 0xff. Nevertheless it was
detected bad because:
static struct nand_bbt_descr largepage_memorybased = {
.options = 0,
.offs = 0,
.len = 2, /* <<<< bytes to check!!! */
.pattern = scan_ff_pattern
};
used a len of 2 instead of 1, which I consider to be correct. Here a
potential fix for the problem. Please have a look if it matches your
understanding of the specification.
Signed-off-by: Frank Haverkamp <haver@vnet.ibm.com>
---
drivers/mtd/nand/nand_bbt.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
--- ubi-2.6.git.orig/drivers/mtd/nand/nand_bbt.c
+++ ubi-2.6.git/drivers/mtd/nand/nand_bbt.c
@@ -1081,7 +1081,14 @@ static struct nand_bbt_descr smallpage_m
.pattern = scan_ff_pattern
};
-static struct nand_bbt_descr largepage_memorybased = {
+static struct nand_bbt_descr largepage_memorybased_8bit = {
+ .options = 0,
+ .offs = 0,
+ .len = 1,
+ .pattern = scan_ff_pattern
+};
+
+static struct nand_bbt_descr largepage_memorybased_16bit = {
.options = 0,
.offs = 0,
.len = 2,
@@ -1179,8 +1186,15 @@ int nand_default_bbt(struct mtd_info *mt
this->bbt_td = NULL;
this->bbt_md = NULL;
if (!this->badblock_pattern) {
- this->badblock_pattern = (mtd->writesize > 512) ?
- &largepage_memorybased : &smallpage_memorybased;
+ if (mtd->writesize > 512) {
+ if (this->options & NAND_BUSWIDTH_16)
+ this->badblock_pattern =
+ &largepage_memorybased_16bit;
+ else
+ this->badblock_pattern =
+ &largepage_memorybased_8bit;
+ } else
+ this->badblock_pattern = &smallpage_memorybased;
}
}
return nand_scan_bbt(mtd, this->badblock_pattern);
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5269 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] MTD: NAND: Fix bad-block detection for 8-bit NAND
2007-09-26 14:10 [PATCH] MTD: NAND: Fix bad-block detection for 8-bit NAND Frank Haverkamp
@ 2007-09-26 15:10 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2007-09-26 15:10 UTC (permalink / raw)
To: haver; +Cc: MTD Mailinglist, David Woodhouse
On Wed, 2007-09-26 at 16:10 +0200, Frank Haverkamp wrote:
> Hi Thomas,
>
> I found the following block in our 128MiB NAND flash:
>
> hexdump vic.img.460
> 0000000 0000 0000 0000 0000 0000 0000 0000 0000
> *
> 0000800 00ff 0000 0000 0000 0000 0000 0000 0000
> 0000810 0000 0000 0000 0000 0000 0000 0000 0000
> *
> 0001040 00ff 0000 0000 0000 0000 0000 0000 0000
> 0001050 0000 0000 0000 0000 0000 0000 0000 0000
> *
> 0021000
>
> According to the specification this is a good block, because the bytes
> in the 1st two OOB areas at offset 0 are 0xff. Nevertheless it was
> detected bad because:
>
> static struct nand_bbt_descr largepage_memorybased = {
> .options = 0,
> .offs = 0,
> .len = 2, /* <<<< bytes to check!!! */
> .pattern = scan_ff_pattern
> };
>
> used a len of 2 instead of 1, which I consider to be correct. Here a
> potential fix for the problem. Please have a look if it matches your
> understanding of the specification.
>
> Signed-off-by: Frank Haverkamp <haver@vnet.ibm.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> drivers/mtd/nand/nand_bbt.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> --- ubi-2.6.git.orig/drivers/mtd/nand/nand_bbt.c
> +++ ubi-2.6.git/drivers/mtd/nand/nand_bbt.c
> @@ -1081,7 +1081,14 @@ static struct nand_bbt_descr smallpage_m
> .pattern = scan_ff_pattern
> };
>
> -static struct nand_bbt_descr largepage_memorybased = {
> +static struct nand_bbt_descr largepage_memorybased_8bit = {
> + .options = 0,
> + .offs = 0,
> + .len = 1,
> + .pattern = scan_ff_pattern
> +};
> +
> +static struct nand_bbt_descr largepage_memorybased_16bit = {
> .options = 0,
> .offs = 0,
> .len = 2,
> @@ -1179,8 +1186,15 @@ int nand_default_bbt(struct mtd_info *mt
> this->bbt_td = NULL;
> this->bbt_md = NULL;
> if (!this->badblock_pattern) {
> - this->badblock_pattern = (mtd->writesize > 512) ?
> - &largepage_memorybased : &smallpage_memorybased;
> + if (mtd->writesize > 512) {
> + if (this->options & NAND_BUSWIDTH_16)
> + this->badblock_pattern =
> + &largepage_memorybased_16bit;
> + else
> + this->badblock_pattern =
> + &largepage_memorybased_8bit;
> + } else
> + this->badblock_pattern = &smallpage_memorybased;
> }
> }
> return nand_scan_bbt(mtd, this->badblock_pattern);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-09-26 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-26 14:10 [PATCH] MTD: NAND: Fix bad-block detection for 8-bit NAND Frank Haverkamp
2007-09-26 15:10 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox