Skip to content

Commit a0dc552

Browse files
computersforpeacededekind
authored andcommitted
mtd: nand: remove NAND_BBT_SCANBYTE1AND6 option
This patch reverts most of: commit 58373ff 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>
1 parent 1c3bd14 commit a0dc552

3 files changed

Lines changed: 6 additions & 52 deletions

File tree

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,11 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
410410
else {
411411
nand_get_device(chip, mtd, FL_WRITING);
412412

413-
/* Write to first two pages and to byte 1 and 6 if necessary.
414-
* If we write to more than one location, the first error
415-
* encountered quits the procedure. We write two bytes per
416-
* location, so we dont have to mess with 16 bit access.
413+
/*
414+
* Write to first two pages if necessary. If we write to more
415+
* than one location, the first error encountered quits the
416+
* procedure. We write two bytes per location, so we dont have
417+
* to mess with 16 bit access.
417418
*/
418419
do {
419420
chip->ops.len = chip->ops.ooblen = 2;
@@ -423,11 +424,6 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
423424

424425
ret = nand_do_write_oob(mtd, ofs, &chip->ops);
425426

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-
}
431427
i++;
432428
ofs += mtd->writesize;
433429
} while (!ret && (chip->options & NAND_BBT_SCAN2NDPAGE) &&
@@ -3131,16 +3127,6 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
31313127
*maf_id == NAND_MFR_MICRON))
31323128
chip->options |= NAND_BBT_SCAN2NDPAGE;
31333129

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-
31443130
/* Check for AND chips with 4 page planes */
31453131
if (chip->options & NAND_4PAGE_ARRAY)
31463132
chip->erase_cmd = multi_erase_cmd;

‎drivers/mtd/nand/nand_bbt.c‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,6 @@ static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_desc
114114
return -1;
115115
}
116116

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-
139117
if (td->options & NAND_BBT_SCANEMPTY) {
140118
p += td->len;
141119
end += td->len;
@@ -167,13 +145,6 @@ static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
167145
if (p[td->offs + i] != td->pattern[i])
168146
return -1;
169147
}
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-
}
177148
return 0;
178149
}
179150

@@ -1330,8 +1301,7 @@ static struct nand_bbt_descr bbt_mirror_no_bbt_descr = {
13301301
.pattern = mirror_pattern
13311302
};
13321303

1333-
#define BBT_SCAN_OPTIONS (NAND_BBT_SCANLASTPAGE | NAND_BBT_SCAN2NDPAGE | \
1334-
NAND_BBT_SCANBYTE1AND6)
1304+
#define BBT_SCAN_OPTIONS (NAND_BBT_SCANLASTPAGE | NAND_BBT_SCAN2NDPAGE)
13351305
/**
13361306
* nand_create_default_bbt_descr - [Internal] Creates a BBT descriptor structure
13371307
* @this: NAND chip to create descriptor for

‎include/linux/mtd/bbm.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ struct nand_bbt_descr {
9898
#define NAND_BBT_SCAN2NDPAGE 0x00004000
9999
/* Search good / bad pattern on the last page of the eraseblock */
100100
#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
103101
/* The nand_bbt_descr was created dynamicaly and must be freed */
104102
#define NAND_BBT_DYNAMICSTRUCT 0x00200000
105103
/* The bad block table does not OOB for marker */

0 commit comments

Comments
 (0)