From: ezequiel@vanguardiasur.com.ar
To: "Gupta, Pekon" <pekon@ti.com>
Cc: "Nori, Sekhar" <nsekhar@ti.com>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd <linux-mtd@lists.infradead.org>,
"Quadros, Roger" <rogerq@ti.com>
Subject: Re: [PATCH] mtd: nand: omap: save Bad-Block-Table (BBT) on device
Date: Wed, 23 Jul 2014 17:27:46 -0300 [thread overview]
Message-ID: <20140723202746.GA26346@arch.cereza> (raw)
In-Reply-To: <20980858CB6D3A4BAE95CA194937D5E73EB064F3@DBDE04.ent.ti.com>
(Brian, correct me if I'm wrong here, you're the BBT expert).
On 23 Jul 04:26 PM, Gupta, Pekon wrote:
> >From: Ezequiel Garcia [mailto:ezequiel@vanguardiasur.com.ar]
> >>On 23 Jul 05:24 PM, Pekon Gupta wrote:
> >> This patch makes OMAP NAND driver to
> >> - save Bad-Block-Table (BBT) on NAND Flash device
> >> - scan on device BBT during probe
> >>
> >
> >Doesn't this break backward compatibility? Please correct me if I'm wrong
> >here, but if I apply this patch, and boot with my current NAND flash
> >contents, the kernel won't have any place to store the BBT (assuming
> >there are no blocks reserved).
>
> Good point. I'll rather like your opinion to judge my below understanding
> as you were recently involved in some NAND BBT features additions..
>
> When bbt_options "NAND_BBT_USE_FLASH" is enabled, default BBT
> options will be used which are:
>
> $KERNEL/drivers/mtd/nand_bbt.c
> static struct nand_bbt_descr bbt_main_descr = {
> .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
> | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
>
> As default options have NAND_BBT_CREATE and NAND_BBT_WRITE,
> so kernel will try to reserve erase-blocks for main-BBT and mirror-BBT
> towards end of NAND device.
>
> - Case-1: If there is un-allocated space (not allocated to any partition)
> at end of Flash device then it will be used. And there is no problem.
>
Yes, so far, so good.
> - Case-2: If there is no free space towards the end of flash, then ...
> As per my understanding, the create_bbt() would try scanning whole
> NAND to find empty blocks and then it creates BBT wherever it finds
> empty blocks. And those blocks are marked as BAD with BBT signature
> to prevent getting erased or over-written by any user-data.
>
OK, I just went through the BBT code, trying to see if I was missing
something. I can't see any place where the kernel scans the device
and searches for empty space for the BBT.
Instead, what create_bbt() seem to do is scan the whole device, searching
for bad blocks to fill an in-memory BBT. I presume that if I have some
blocks marked as bad in the OOB region, they are identified as bad
and the BBT is filled.
I think that write_bbt() is where the (previously created, in-memory) BBT
is written to flash. It goes like this:
write_bbt()
{
[..]
/*
* Automatic placement of the bad block table. Search direction
* top -> down?
*/
if (td->options & NAND_BBT_LASTBLOCK) {
startblock = numblocks * (chip + 1) - 1;
dir = -1;
} else {
startblock = chip * numblocks;
dir = 1;
}
for (i = 0; i < td->maxblocks; i++) {
int block = startblock + dir * i;
/* Check, if the block is bad */
switch (bbt_get_entry(this, block)) {
case BBT_BLOCK_WORN:
case BBT_BLOCK_FACTORY_BAD:
continue;
}
page = block <<
(this->bbt_erase_shift - this->page_shift);
/* Check, if the block is used by the mirror table */
if (!md || md->pages[chip] != page)
goto write;
}
pr_err("No space left to write bad block table\n");
return -ENOSPC;
[..]
}
which fails if there's no room left for the BBT. This will happen on every
boot, so it's not an ideal situation.
> Is my understanding correct?
> If yes, then this will not break backward compatibility, as on upgrading
> the kernel new BBT will be automatically written on first boot. And
> it will be used in subsequent boots.
> Need feedbacks ...
>
In fact, you do have a simple way to solve this. Just support BBT through
the "nand-on-flash-bbt" devicetree property, so a user can tell if his flash
has a BBT or not. See pxa3xx-nand.c, which should be correct.
--
Ezequiel Garcia, VanguardiaSur
www.vanguardiasur.com.ar
next prev parent reply other threads:[~2014-07-23 20:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 11:54 [PATCH] mtd: nand: omap: save Bad-Block-Table (BBT) on device Pekon Gupta
2014-07-23 12:05 ` Ezequiel Garcia
2014-07-23 16:26 ` Gupta, Pekon
2014-07-23 20:27 ` ezequiel [this message]
2014-07-24 1:54 ` Brian Norris
2014-07-24 13:40 ` Ezequiel Garcia
2014-07-24 19:11 ` Brian Norris
2014-07-24 17:56 ` Gupta, Pekon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140723202746.GA26346@arch.cereza \
--to=ezequiel@vanguardiasur.com.ar \
--cc=computersforpeace@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=nsekhar@ti.com \
--cc=pekon@ti.com \
--cc=rogerq@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox