OneNAND: Runtime badblock support
Subsystems (3)
PATCH 1/1 OneNAND: Runtime badblock support
At bootloader, we don't need to read full page. It takes too long time. Instead it only read pages required for boot.
Of course, this patch reduces the boot time
---
drivers/mtd/onenand/onenand_bbt.c +48 -0
@@ -48,6 +48,43 @@ static int check_short_pattern(uint8_t * buf, int len, int paglen,return 0 ; } +static int read_page_oob (struct mtd_info *mtd,loff_t from,u_char *buf) +{ +struct onenand_chip *this = mtd->priv; +struct bbm_info *bbm = this->bbm; +struct nand_bbt_descr *bd = bbm->badblock_pattern; +struct mtd_oob_ops ops; +int ret, scanlen, block, j, res; + + scanlen =0 ; + + ops.mode =MTD_OOB_PLACE ; + ops.ooblen =16 ; + ops.oobbuf = buf; + ops.len = ops.ooboffs = ops.retlen = ops.oobretlen =0 ; + +/* Get block number * 2 */ + block = (int )(from >> (bbm->bbt_erase_shift -1 )); + +/* Set as normal block */ + res =0x00 ; + bbm->bbt[block >>3 ] |=0x00 << (block &0x6 ); + +for (j =0 ; j <2 ; j++) { + ret =onenand_bbt_read_oob (mtd, from + j * mtd->writesize + bd->offs, &ops); +if (ret ||check_short_pattern (&buf[j * scanlen], scanlen, mtd->writesize, bd)) { + bbm->bbt[block >>3 ] |=0x03 << (block &0x6 ); + res =0x03 ; +printk (KERN_WARNING "Bad eraseblock %d@0x%08x\n" , + block >>1 , (unsigned int ) from); + mtd->ecc_stats.badblocks++; +break ; + } + } + +return ret; +} +/** * create_bbt - [GENERIC] Create a bad block table by scanning the device * @param mtd MTD device structure
@@ -155,6 +192,11 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) block = (int )(offs >> (bbm->bbt_erase_shift -1 )); res = (bbm->bbt[block >>3 ] >> (block &0x06 )) &0x03 ; +if (this->options &ONENAND_RUNTIME_BADBLOCK_CHECK ) { +if (res ==0x02 ) + res =read_page_oob (mtd, offs, this->oob_buf); + } +MTDDEBUG (MTD_DEBUG_LEVEL2 ,"onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n" , (unsigned int )offs, block >>1 , res);
@@ -210,6 +252,12 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)if (!bbm->isbad_bbt) bbm->isbad_bbt = onenand_isbad_bbt; +if (this->options &ONENAND_RUNTIME_BADBLOCK_CHECK ) { +printk (KERN_INFO "Scanning device for bad blocks (skipped)\n" ); +memset (bbm->bbt,0xaa , len); +return 0 ; + } +/* Scan the device to build a memory based bad block table */ if ((ret =onenand_memory_bbt (mtd, bd))) { printk(KERN_ERR
include/linux/mtd/onenand.h +1 -0
@@ -135,6 +135,7 @@ struct onenand_chip {#define ONENAND_HAS_CONT_LOCK (0x0001)#define ONENAND_HAS_UNLOCK_ALL (0x0002)#define ONENAND_HAS_2PLANE (0x0004) +#define ONENAND_RUNTIME_BADBLOCK_CHECK (0x0200)#define ONENAND_PAGEBUF_ALLOC (0x1000)#define ONENAND_OOBBUF_ALLOC (0x2000)
PATCH 1/1 OneNAND: Runtime badblock support
Dear Kyungmin Park,
Quoted 3 lines · In message <20090721095528.GA23408@july> you wrote:
At bootloader, we don't need to read full page. It takes too long time. Instead it only read pages required for boot.
Of course, this patch reduces the boot time
What does "don't need to read full page" mean? when we read pages, we always read fullpages, don't we?
drivers/mtd/onenand/onenand_bbt.c static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) · line 199
Quoted 9 lines
drivers/mtd/onenand/onenand_bbt.c +5
-0@@ -155,6 +192,11 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) block = (int )(offs >> (bbm->bbt_erase_shift -1 )); res = (bbm->bbt[block >>3 ] >> (block &0x06 )) &0x03 ; +if (this->options &ONENAND_RUNTIME_BADBLOCK_CHECK ) { +if (res ==0x02 ) + res =read_page_oob (mtd, offs, this->oob_buf); + } +
ONENAND_RUNTIME_BADBLOCK_CHECK is a new #define, right? It should be documented (for example in the README, or even better in doc/README.OneNand or so).
Best regards,
Wolfgang Denk
Signature · 7 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 Quote from the Boss after overriding the decision of a task force he created to find a solution: "I'm sorry if I ever gave you the impression your input would have any effect on my decision for the outcome of this project!"
PATCH 1/1 OneNAND: Runtime badblock support
Hi,
Quoted 8 lines · Wolfgang Denk
Dear Kyungmin Park,
Quoted 3 lines · In message <20090721095528.GA23408@july> you wrote:
At bootloader, we don't need to read full page. It takes too long time. Instead it only read pages required for boot.
Of course, this patch reduces the boot timeWhat does "don't need to read full page" mean?
It means all blocks at scanning time.
Quoted 6 lines
when we read pages, we always read fullpages, don't we?
Quoted 4 lines
(quoted diff) +0
-0@@ -155,6 +192,11 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) ? ? ? block = (int)(offs >> (bbm->bbt_erase_shift - 1)); ? ? ? res = (bbm->bbt[block >> 3] >> (block & 0x06)) & 0x03;
Quoted 9 lines
Review static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) · line 199
Quoted 5 lines
(quoted diff) +5
-0+ ? ? if (this->options & ONENAND_RUNTIME_BADBLOCK_CHECK) { + ? ? ? ? ? ? if (res == 0x02) + ? ? ? ? ? ? ? ? ? ? res = read_page_oob(mtd, offs, this->oob_buf); + ? ? } +
ONENAND_RUNTIME_BADBLOCK_CHECKis a new #define, right? It should be documented (for example in the README, or even better in doc/README.OneNand or so).
It's OneNAND specific option. Umm I'll try to describe it
Thank you,
Kyungmin Park