diff options
author | Brian Norris <computersforpeace@gmail.com> | 2011-05-31 19:31:20 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2011-09-11 08:01:46 -0400 |
commit | a0dc552951dcbb2b28a8a2ffb5fa966613e8c025 (patch) | |
tree | 62c71971d00f60fedcb5b265614c8925493877ad | |
parent | 1c3bd14bb0e10ce69761662d575d454f12070838 (diff) |
mtd: nand: remove NAND_BBT_SCANBYTE1AND6 option
This patch reverts most of:
commit 58373ff0afff4cc8ac40608872995f4d87eb72ec
mtd: nand: more BB Detection refactoring and dynamic scan options
According to the discussion at:
http://lists.infradead.org/pipermail/linux-mtd/2011-May/035696.html
the NAND_BBT_SCANBYTE1AND6 flag, although technically valid, can break
some existing ECC layouts that use the 6th byte in the OOB for ECC data.
Furthermore, we apparently do not need to scan both bytes 1 and 6 in
the OOB region of the devices under consideration; instead, we only need
to scan one or the other.
Thus, the NAND_BBT_SCANBYTE1AND6 flag is at best unnecessary and at
worst a regression.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 24 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_bbt.c | 32 | ||||
-rw-r--r-- | include/linux/mtd/bbm.h | 2 |
3 files changed, 6 insertions, 52 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index a46e9bb847bd..bb2e24b2d6c4 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -410,10 +410,11 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
410 | else { | 410 | else { |
411 | nand_get_device(chip, mtd, FL_WRITING); | 411 | nand_get_device(chip, mtd, FL_WRITING); |
412 | 412 | ||
413 | /* Write to first two pages and to byte 1 and 6 if necessary. | 413 | /* |
414 | * If we write to more than one location, the first error | 414 | * Write to first two pages if necessary. If we write to more |
415 | * encountered quits the procedure. We write two bytes per | 415 | * than one location, the first error encountered quits the |
416 | * location, so we dont have to mess with 16 bit access. | 416 | * procedure. We write two bytes per location, so we dont have |
417 | * to mess with 16 bit access. | ||
417 | */ | 418 | */ |
418 | do { | 419 | do { |
419 | chip->ops.len = chip->ops.ooblen = 2; | 420 | chip->ops.len = chip->ops.ooblen = 2; |
@@ -423,11 +424,6 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
423 | 424 | ||
424 | ret = nand_do_write_oob(mtd, ofs, &chip->ops); | 425 | ret = nand_do_write_oob(mtd, ofs, &chip->ops); |
425 | 426 | ||
426 | if (!ret && (chip->options & NAND_BBT_SCANBYTE1AND6)) { | ||
427 | chip->ops.ooboffs = NAND_SMALL_BADBLOCK_POS | ||
428 | & ~0x01; | ||
429 | ret = nand_do_write_oob(mtd, ofs, &chip->ops); | ||
430 | } | ||
431 | i++; | 427 | i++; |
432 | ofs += mtd->writesize; | 428 | ofs += mtd->writesize; |
433 | } while (!ret && (chip->options & NAND_BBT_SCAN2NDPAGE) && | 429 | } while (!ret && (chip->options & NAND_BBT_SCAN2NDPAGE) && |
@@ -3131,16 +3127,6 @@ ident_done: | |||
3131 | *maf_id == NAND_MFR_MICRON)) | 3127 | *maf_id == NAND_MFR_MICRON)) |
3132 | chip->options |= NAND_BBT_SCAN2NDPAGE; | 3128 | chip->options |= NAND_BBT_SCAN2NDPAGE; |
3133 | 3129 | ||
3134 | /* | ||
3135 | * Numonyx/ST 2K pages, x8 bus use BOTH byte 1 and 6 | ||
3136 | */ | ||
3137 | if (!(busw & NAND_BUSWIDTH_16) && | ||
3138 | *maf_id == NAND_MFR_STMICRO && | ||
3139 | mtd->writesize == 2048) { | ||
3140 | chip->options |= NAND_BBT_SCANBYTE1AND6; | ||
3141 | chip->badblockpos = 0; | ||
3142 | } | ||
3143 | |||
3144 | /* Check for AND chips with 4 page planes */ | 3130 | /* Check for AND chips with 4 page planes */ |
3145 | if (chip->options & NAND_4PAGE_ARRAY) | 3131 | if (chip->options & NAND_4PAGE_ARRAY) |
3146 | chip->erase_cmd = multi_erase_cmd; | 3132 | chip->erase_cmd = multi_erase_cmd; |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index ccbeaa1e4a8e..5ffb9a4632ca 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -114,28 +114,6 @@ static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_desc | |||
114 | return -1; | 114 | return -1; |
115 | } | 115 | } |
116 | 116 | ||
117 | /* Check both positions 1 and 6 for pattern? */ | ||
118 | if (td->options & NAND_BBT_SCANBYTE1AND6) { | ||
119 | if (td->options & NAND_BBT_SCANEMPTY) { | ||
120 | p += td->len; | ||
121 | end += NAND_SMALL_BADBLOCK_POS - td->offs; | ||
122 | /* Check region between positions 1 and 6 */ | ||
123 | for (i = 0; i < NAND_SMALL_BADBLOCK_POS - td->offs - td->len; | ||
124 | i++) { | ||
125 | if (*p++ != 0xff) | ||
126 | return -1; | ||
127 | } | ||
128 | } | ||
129 | else { | ||
130 | p += NAND_SMALL_BADBLOCK_POS - td->offs; | ||
131 | } | ||
132 | /* Compare the pattern */ | ||
133 | for (i = 0; i < td->len; i++) { | ||
134 | if (p[i] != td->pattern[i]) | ||
135 | return -1; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | if (td->options & NAND_BBT_SCANEMPTY) { | 117 | if (td->options & NAND_BBT_SCANEMPTY) { |
140 | p += td->len; | 118 | p += td->len; |
141 | end += td->len; | 119 | end += td->len; |
@@ -167,13 +145,6 @@ static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td) | |||
167 | if (p[td->offs + i] != td->pattern[i]) | 145 | if (p[td->offs + i] != td->pattern[i]) |
168 | return -1; | 146 | return -1; |
169 | } | 147 | } |
170 | /* Need to check location 1 AND 6? */ | ||
171 | if (td->options & NAND_BBT_SCANBYTE1AND6) { | ||
172 | for (i = 0; i < td->len; i++) { | ||
173 | if (p[NAND_SMALL_BADBLOCK_POS + i] != td->pattern[i]) | ||
174 | return -1; | ||
175 | } | ||
176 | } | ||
177 | return 0; | 148 | return 0; |
178 | } | 149 | } |
179 | 150 | ||
@@ -1330,8 +1301,7 @@ static struct nand_bbt_descr bbt_mirror_no_bbt_descr = { | |||
1330 | .pattern = mirror_pattern | 1301 | .pattern = mirror_pattern |
1331 | }; | 1302 | }; |
1332 | 1303 | ||
1333 | #define BBT_SCAN_OPTIONS (NAND_BBT_SCANLASTPAGE | NAND_BBT_SCAN2NDPAGE | \ | 1304 | #define BBT_SCAN_OPTIONS (NAND_BBT_SCANLASTPAGE | NAND_BBT_SCAN2NDPAGE) |
1334 | NAND_BBT_SCANBYTE1AND6) | ||
1335 | /** | 1305 | /** |
1336 | * nand_create_default_bbt_descr - [Internal] Creates a BBT descriptor structure | 1306 | * nand_create_default_bbt_descr - [Internal] Creates a BBT descriptor structure |
1337 | * @this: NAND chip to create descriptor for | 1307 | * @this: NAND chip to create descriptor for |
diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h index 57cc0e63714f..08ffa2193c07 100644 --- a/include/linux/mtd/bbm.h +++ b/include/linux/mtd/bbm.h | |||
@@ -98,8 +98,6 @@ struct nand_bbt_descr { | |||
98 | #define NAND_BBT_SCAN2NDPAGE 0x00004000 | 98 | #define NAND_BBT_SCAN2NDPAGE 0x00004000 |
99 | /* Search good / bad pattern on the last page of the eraseblock */ | 99 | /* Search good / bad pattern on the last page of the eraseblock */ |
100 | #define NAND_BBT_SCANLASTPAGE 0x00008000 | 100 | #define NAND_BBT_SCANLASTPAGE 0x00008000 |
101 | /* Chip stores bad block marker on BOTH 1st and 6th bytes of OOB */ | ||
102 | #define NAND_BBT_SCANBYTE1AND6 0x00100000 | ||
103 | /* The nand_bbt_descr was created dynamicaly and must be freed */ | 101 | /* The nand_bbt_descr was created dynamicaly and must be freed */ |
104 | #define NAND_BBT_DYNAMICSTRUCT 0x00200000 | 102 | #define NAND_BBT_DYNAMICSTRUCT 0x00200000 |
105 | /* The bad block table does not OOB for marker */ | 103 | /* The bad block table does not OOB for marker */ |