[U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev)

Ilya Yanok yanok at emcraft.com
Mon Jun 30 16:10:52 CEST 2008


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

>From 6f062db5d60215447e9910d6b4a9a220fe02ef44 Mon Sep 17 00:00:00 2001
From: Ilya Yanok <yanok at emcraft.com>
Date: Mon, 30 Jun 2008 15:34:40 +0200
Subject: [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev)

This patch adds support for CONFIG_NAND_LAZY_SCAN configuration option.
With this option enabled mtd layer wouldn't scan NAND bbt during boot,
bbt will be scanned when first bad block check is performed.

Signed-off-by: Ilya Yanok <yanok at emcraft.com>
---
 drivers/mtd/nand/nand_base.c |   12 ++++++++++++
 include/linux/mtd/nand.h     |    4 ++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 740d3fc..c90edde 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -525,6 +525,13 @@ static int nand_block_checkbad (struct mtd_info
*mtd, loff_t ofs, int getchip, i
 {
     struct nand_chip *this = mtd->priv;
 
+#ifdef CONFIG_NAND_LAZY_SCAN
+    if (!(this->options & NAND_BBT_SCANNED)) {
+        this->scan_bbt(mtd);
+        this->options |= NAND_BBT_SCANNED;
+    }
+#endif
+
     if (!this->bbt)
         return this->block_bad(mtd, ofs, getchip);
 
@@ -2652,8 +2659,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
-- 
1.5.4.2





More information about the U-Boot mailing list