All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] mtd: nand: fix two problems related to BBT scan
@ 2014-12-26 13:20 Masahiro Yamada
  2014-12-26 13:20 ` [U-Boot] [PATCH 1/2] mtd: nand: Mark the BBT as scanned prior to calling scan_bbt again Masahiro Yamada
  2014-12-26 13:20 ` [U-Boot] [PATCH 2/2] mtd: nand: do not scan BBT after scrub Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2014-12-26 13:20 UTC (permalink / raw)
  To: u-boot




Masahiro Yamada (2):
  mtd: nand: Mark the BBT as scanned prior to calling scan_bbt again
  mtd: nand: do not scan BBT after scrub

 drivers/mtd/nand/nand_base.c | 9 +++------
 drivers/mtd/nand/nand_util.c | 4 +---
 2 files changed, 4 insertions(+), 9 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/2] mtd: nand: Mark the BBT as scanned prior to calling scan_bbt again
  2014-12-26 13:20 [U-Boot] [PATCH 0/2] mtd: nand: fix two problems related to BBT scan Masahiro Yamada
@ 2014-12-26 13:20 ` Masahiro Yamada
  2014-12-26 13:20 ` [U-Boot] [PATCH 2/2] mtd: nand: do not scan BBT after scrub Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2014-12-26 13:20 UTC (permalink / raw)
  To: u-boot

Commit 35c204d8a9d0 (nand: reinstate lazy bad block scanning)
broke NAND_BBT_USE_FLASH feature.

Its git-log claimed that it reinstated the change as by commit
fb49454b1b6c ("nand: reinstate lazy bad block scanning"), but it moved
"chip->options |= NAND_BBT_SCANNED" below "chip->scan_bbt(mtd);".

It causes recursion if scan_bbt does not find a flash based BBT
and tries to write one, and the attempt to erase the BBT area
causes a bad block check.

Reinstate commit ff49ea8977b5 (NAND: Mark the BBT as scanned prior to
calling scan_bbt.).

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Rostislav Lisovy <lisovy@merica.cz>
Cc: Heiko Schocher <hs@denx.de>
Cc: Scott Wood <scottwood@freescale.com>
---

 drivers/mtd/nand/nand_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d04c7ea..eaa4be1 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -635,8 +635,8 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
 	struct nand_chip *chip = mtd->priv;
 
 	if (!(chip->options & NAND_BBT_SCANNED)) {
-		chip->scan_bbt(mtd);
 		chip->options |= NAND_BBT_SCANNED;
+		chip->scan_bbt(mtd);
 	}
 
 	if (!chip->bbt)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 2/2] mtd: nand: do not scan BBT after scrub
  2014-12-26 13:20 [U-Boot] [PATCH 0/2] mtd: nand: fix two problems related to BBT scan Masahiro Yamada
  2014-12-26 13:20 ` [U-Boot] [PATCH 1/2] mtd: nand: Mark the BBT as scanned prior to calling scan_bbt again Masahiro Yamada
@ 2014-12-26 13:20 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2014-12-26 13:20 UTC (permalink / raw)
  To: u-boot

Currently, "nand scrub" runs chip->scan_bbt at the end of
nand_erase_opts() even if NAND_SKIP_BBTSCAN flag is set.

It violates the intention of NAND_SKIP_BBTSCAN.

Move NAND_SKIP_BBTSCAN flag check to nand_block_checkbad() so that
chip->scan_bbt() is never run if NAND_SKIP_BBTSCAN is set.

Also, unset NAND_BBT_SCANNED flag instead of running chip->scan_bbt()
right after scrub.  We can be lazier here because the BBT is scanned
at the next call of nand_block_checkbad().

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Scott Wood <scottwood@freescale.com>
---

 drivers/mtd/nand/nand_base.c | 7 ++-----
 drivers/mtd/nand/nand_util.c | 4 +---
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index eaa4be1..63bdf65 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -634,7 +634,8 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
 {
 	struct nand_chip *chip = mtd->priv;
 
-	if (!(chip->options & NAND_BBT_SCANNED)) {
+	if (!(chip->options & NAND_SKIP_BBTSCAN) &&
+	    !(chip->options & NAND_BBT_SCANNED)) {
 		chip->options |= NAND_BBT_SCANNED;
 		chip->scan_bbt(mtd);
 	}
@@ -4325,10 +4326,6 @@ int nand_scan_tail(struct mtd_info *mtd)
 	if (!mtd->bitflip_threshold)
 		mtd->bitflip_threshold = mtd->ecc_strength;
 
-	/* Check, if we should skip the bad block table scan */
-	if (chip->options & NAND_SKIP_BBTSCAN)
-		chip->options |= NAND_BBT_SCANNED;
-
 	return 0;
 }
 EXPORT_SYMBOL(nand_scan_tail);
diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
index 024f6fb..afdd160 100644
--- a/drivers/mtd/nand/nand_util.c
+++ b/drivers/mtd/nand/nand_util.c
@@ -91,6 +91,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
 			kfree(chip->bbt);
 		}
 		chip->bbt = NULL;
+		chip->options &= ~NAND_BBT_SCANNED;
 	}
 
 	for (erased_length = 0;
@@ -179,9 +180,6 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
 	if (!opts->quiet)
 		printf("\n");
 
-	if (opts->scrub)
-		chip->scan_bbt(meminfo);
-
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-26 13:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-26 13:20 [U-Boot] [PATCH 0/2] mtd: nand: fix two problems related to BBT scan Masahiro Yamada
2014-12-26 13:20 ` [U-Boot] [PATCH 1/2] mtd: nand: Mark the BBT as scanned prior to calling scan_bbt again Masahiro Yamada
2014-12-26 13:20 ` [U-Boot] [PATCH 2/2] mtd: nand: do not scan BBT after scrub Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.