Skip to content

Commit a3c4c23

Browse files
psr0kamiquelraynal
authored andcommitted
mtd: rawnand: Change calculating of position page containing BBM
Change calculating of position page containing BBM If none of BBM flags are set then function nand_bbm_get_next_page reports EINVAL. It causes that BBM is not read at all during scanning factory bad blocks. The result is that the BBT table is build without checking factory BBM at all. For Micron flash memories none of these flags are set if page size is different than 2048 bytes. Address this regression by: - adding NAND_BBM_FIRSTPAGE chip flag without any condition. It solves issue only for Micron devices. - changing the nand_bbm_get_next_page_function. It will return 0 if no of BBM flag is set and page parameter is 0. After that modification way of discovering factory bad blocks will work similar as in kernel version 5.1. Cc: stable@vger.kernel.org Fixes: f90da78 (mtd: rawnand: Support bad block markers in first, second or last page) Signed-off-by: Piotr Sroka <piotrs@cadence.com> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 83156c1 commit a3c4c23

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/mtd/nand/raw/nand_base.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
292292
struct mtd_info *mtd = nand_to_mtd(chip);
293293
int last_page = ((mtd->erasesize - mtd->writesize) >>
294294
chip->page_shift) & chip->pagemask;
295+
unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
296+
| NAND_BBM_LASTPAGE;
295297

298+
if (page == 0 && !(chip->options & bbm_flags))
299+
return 0;
296300
if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
297301
return 0;
298-
else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
302+
if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
299303
return 1;
300-
else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
304+
if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
301305
return last_page;
302306

303307
return -EINVAL;

drivers/mtd/nand/raw/nand_micron.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,10 @@ static int micron_nand_init(struct nand_chip *chip)
446446
if (ret)
447447
goto err_free_manuf_data;
448448

449+
chip->options |= NAND_BBM_FIRSTPAGE;
450+
449451
if (mtd->writesize == 2048)
450-
chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
452+
chip->options |= NAND_BBM_SECONDPAGE;
451453

452454
ondie = micron_supports_on_die_ecc(chip);
453455

0 commit comments

Comments
 (0)