public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN option support
@ 2008-06-26  9:50 Ilya Yanok
  2008-06-26 16:52 ` Scott Wood
  0 siblings, 1 reply; 4+ messages in thread
From: Ilya Yanok @ 2008-06-26  9:50 UTC (permalink / raw)
  To: u-boot

 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 call
nand_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.

Signed-off-by: Ilya Yanok <yanok@emcraft.com>
Signed-off-by: Yuri Tikhonov <yur@emcraft.com>
---
 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(-)

diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 37eb41b..6f5d13d 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -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)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 740d3fc..f3ee705 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -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
 }

 /**
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 4cc4a7d..8a6d69e 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -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
diff --git a/include/nand.h b/include/nand.h
index 247d346..6d3e91a 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -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
-- 
1.5.4.2

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

* [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN option support
  2008-06-26  9:50 [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN option support Ilya Yanok
@ 2008-06-26 16:52 ` Scott Wood
  2008-06-30 14:10   ` [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev) Ilya Yanok
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Wood @ 2008-06-26 16:52 UTC (permalink / raw)
  To: u-boot

Ilya Yanok wrote:
> diff --git a/common/cmd_nand.c b/common/cmd_nand.c
> index 37eb41b..6f5d13d 100644
> --- a/common/cmd_nand.c
> +++ b/common/cmd_nand.c
> @@ -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().

> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 740d3fc..f3ee705 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -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

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

* [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev)
  2008-06-26 16:52 ` Scott Wood
@ 2008-06-30 14:10   ` Ilya Yanok
  2008-07-06 20:47     ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Ilya Yanok @ 2008-06-30 14:10 UTC (permalink / raw)
  To: u-boot

Scott Wood wrote:
>> diff --git a/common/cmd_nand.c b/common/cmd_nand.c
>> index 37eb41b..6f5d13d 100644
>> --- a/common/cmd_nand.c
>> +++ b/common/cmd_nand.c
>> @@ -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().

You're right. I've added scanning in nand_block_checkbad.

> Is there any reason not to enable this unconditionally?

Don't really know. I've used config option just to provide old behavior.

--
Ilya

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

* [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev)
  2008-06-30 14:10   ` [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev) Ilya Yanok
@ 2008-07-06 20:47     ` Wolfgang Denk
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2008-07-06 20:47 UTC (permalink / raw)
  To: u-boot

In message <4868E96C.6000809@emcraft.com> you wrote:
>
> > 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

-- 
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

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

end of thread, other threads:[~2008-07-06 20:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-26  9:50 [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN option support Ilya Yanok
2008-06-26 16:52 ` Scott Wood
2008-06-30 14:10   ` [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev) Ilya Yanok
2008-07-06 20:47     ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox