mtd: CONFIG_NAND_LAZY_SCAN option support
Subsystems (2)
PATCH 1/1 mtd: CONFIG_NAND_LAZY_SCAN option support
With this option set, the nand_init() doesn't scan NAND for bad blocks.
This allows one to avoid boot delays caused by the scanning procedure for the boards which do not need NAND for booting.
To work with NAND having this option set, one should explicitely callnand_lazy_scan_finish() before using the NAND chip. This function automatically
called at the first access to NAND chip from the U-Boot command line.
--- common/cmd_nand.c | 2 ++ drivers/mtd/nand/nand_base.c | 5 +++++ include/linux/mtd/nand.h | 4 ++++ include/nand.h | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 0 deletions(-)
common/cmd_nand.c +0 -0
@@ -236,6 +236,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
char *argv[])
}
nand = &nand_info[nand_curr_device];+ nand_lazy_scan_finish(nand);
+
if (strcmp(cmd, "bad") == 0) {
printf("\nDevice %d bad blocks:\n", nand_curr_device);
for (off = 0; off < nand->size; off += nand->erasesize)drivers/mtd/nand/nand_base.c +5 -0
@@ -2652,8 +2652,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips)#if 0 mtd->owner =THIS_MODULE ;#endif +#ifdef CONFIG_NAND_LAZY_SCAN + this->options &= ~NAND_BBT_SCANNED ; +return 0 ; +#else /* Build bad block table */ return this->scan_bbt (mtd); +#endif }/**
include/linux/mtd/nand.h +4 -0
@@ -450,6 +450,10 @@ struct nand_bbt_descr {#define NAND_BBT_SAVECONTENT 0x00002000/* Search good / bad pattern on the first and the second page */ #define NAND_BBT_SCAN2NDPAGE 0x00004000 +#ifdef CONFIG_NAND_LAZY_SCAN +/* bbt is already read */ +#define NAND_BBT_SCANNED 0x80000000 +#endif /* The maximum number of blocks to scan for a bbt */ #define NAND_BBT_SCAN_MAXBLOCKS 4
include/nand.h +0 -0
@@ -122,4 +122,18 @@ int nand_get_lock_status(nand_info_t *meminfo,
ulong offset);
void board_nand_select_device(struct nand_chip *nand, int chip); #endif
+#ifdef CONFIG_NAND_LAZY_SCAN
+static inline void nand_lazy_scan_finish(nand_info_t *info) +{
+ struct nand_chip *chip = info->priv;
+
+ if (!(chip->options & NAND_BBT_SCANNED)) {
+ chip->scan_bbt(info);
+ chip->options |= NAND_BBT_SCANNED;
+ }
+}
+#else
+#define nand_lazy_scan_finish(info) do {} while(0)
+#endif
+
#endif
Signature · 1 line
1.5.4.2
PATCH 1/1 mtd: CONFIG_NAND_LAZY_SCAN option support
common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, · line 241
Quoted 11 lines · Ilya Yanok
common/cmd_nand.c +2
-0@@ -236,6 +236,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } nand = &nand_info[nand_curr_device]; +nand_lazy_scan_finish (nand); +
There are other entry points that need to be covered (e.g. do_nandboot, do_onenand, env_nand, jffs2, etc). Probably better to put the call in nand_block_isbad().
Quoted 5 lines
drivers/mtd/nand/nand_base.c +0
-0
drivers/mtd/nand/nand_base.c int nand_scan (struct mtd_info *mtd, int maxchips) · line 2661
Quoted 10 lines
drivers/mtd/nand/nand_base.c +5
-0@@ -2652,8 +2652,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips)#if 0 mtd->owner =THIS_MODULE ;#endif +#ifdef CONFIG_NAND_LAZY_SCAN + this->options &= ~NAND_BBT_SCANNED ; +return 0 ; +#else /* Build bad block table */ return this->scan_bbt (mtd); +#endif
Is there any reason not to enable this unconditionally?
Also, this patch is whitespace-mangled.
-Scott
PATCH 1/1 mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev)
Quoted 9 lines · Scott Wood
Quoted 9 lines
common/cmd_nand.c +0
-0@@ -236,6 +236,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } nand = &nand_info[nand_curr_device];
Quoted 6 lines
common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, · line 241
Quoted 2 lines
common/cmd_nand.c +2
-0+nand_lazy_scan_finish (nand); +There are other entry points that need to be covered (e.g.
do_nandboot,do_onenand,env_nand, jffs2, etc). Probably better to put the call innand_block_isbad().
You're right. I've added scanning in nand_block_checkbad.
Quoted 1 line
Is there any reason not to enable this unconditionally?
Don't really know. I've used config option just to provide old behavior.
--
Ilya
PATCH 1/1 mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev)
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Is there any reason not to enable this unconditionally?
Don't really know. I've used config option just to provide old behavior.
I vote for adding this unconditionally, too.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de O Staat! Wie tief dir alle Besten fluchen! Du bist kein Ziel. Der Mensch mu? weiter suchen. - Christian Morgenstern