linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ezequiel.garcia@free-electrons.com (Ezequiel Garcia)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 13/28] mtd: nand: pxa3xx: Add bad block handling
Date: Tue, 5 Nov 2013 20:40:56 -0300	[thread overview]
Message-ID: <20131105234055.GE11759@localhost> (raw)
In-Reply-To: <20131105182301.GN20061@ld-irv-0074.broadcom.com>

On Tue, Nov 05, 2013 at 10:23:01AM -0800, Brian Norris wrote:
> Hi Ezequiel,
> 
> I wrote up some comments on your v2 series while on a plane Sunday, but
> I didn't make time to send them out until now. Oh well.
> 

No problem. I just wanted to push a new version with the minor fixes
from Huang to prevent from stalling.

> On Tue, Nov 05, 2013 at 09:55:20AM -0300, Ezequiel Garcia wrote:
> > --- a/drivers/mtd/nand/pxa3xx_nand.c
> > +++ b/drivers/mtd/nand/pxa3xx_nand.c
> > @@ -1128,6 +1152,14 @@ KEEP_CONFIG:
> >  
> >  	if (nand_scan_ident(mtd, 1, def))
> >  		return -ENODEV;
> > +
> > +	if (pdata->flash_bbt) {
> > +		chip->bbt_options |= NAND_BBT_USE_FLASH |
> > +				     NAND_BBT_NO_OOB_BBM;
> 
> You're using NAND_BBT_NO_OOB_BBM? So you are unable to write bad block
> markers to flash at all? Is this related to your independent patch for
> trying to scan BBM from the data area?

Yes.

> Could you instead write a
> nand_chip.block_markbad() callback routine that would program BBM to the
> appropriate data area?
> 

No :-)

> Or, if you really want to avoid programming new BBMs, then you should
> probably describe this decision in the patch description more clearly.
> 

Right.

I'll have to describe a bunch of stuff about the controller so this
NO_OOB_BBM makes sense. Please bare with me and keep reading :)

The central issue and the main difficulty is the "splitted"
data/oob/data/oob way of regarding a page.

This is intrinsic to the hardware and we must learn to deal with it.
So, let's suppose we have 4K pages, and the manufacturer marks a block at
offset 4096 (the 'x' is offset 4096).

-----------------------------------------------
|                    Data           |x  OOB   |
-----------------------------------------------

When this same page is 'viewed' by the driver, and because of the
splitted layout, the data and OOB regions are now at different
locations. It would be something like this:

-----------------------------------------------
|      Data      | OOB |      Data   x  | OOB |
-----------------------------------------------

The offset *in the data region* depends in the controller configuration,
but considering we have a 32B and 30B ECC, the calculation would give:

 2048 + 2048 - 32 - 30 = 4034.

So, if I use nanddump to dump a page, I would have to look at offset
4034 to find the factory bad block marker.

For this reason, why need to use a customize bad block scanning.

In addition, this means under regular usage we will write such position
(since it belongs to the data region) and every used block is likely
to be marked as bad.

So, there's no point in marking a block as bad, because good blocks
are *also* mark as bad. We need to rely in the bad block table, and only
perform the scan in on the very first time (when the device is unused).

We're aware this sounds kind of crappy since we'll get completely screwed
in case the bad block table is somehow lost or corrupted, but we don't
care about such case.

Still, I'd like to know:

1. Do you think the bad block table could be corrupted or is this not
likely to ever happen?

2. Do you have any ideas to 'avoid' writing to the marker? or maybe to
otherwise scan the factory markers the first time, but then use some
other position for the kernel in-flash BB marker?

> > +		chip->bbt_td = &bbt_main_descr;
> > +		chip->bbt_md = &bbt_mirror_descr;
> > +	}
> > +
> >  	/* calculate addressing information */
> >  	if (mtd->writesize >= 2048)
> >  		host->col_addr_cycles = 2;
> > @@ -1323,6 +1355,7 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
> >  	if (of_get_property(np, "marvell,nand-keep-config", NULL))
> >  		pdata->keep_config = 1;
> >  	of_property_read_u32(np, "num-cs", &pdata->num_cs);
> > +	pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
> 
> Now that you're using the "nand-on-flash-bbt" property, you should
> document it in Documentation/devicetree/bindings/mtd/pxa3xx-nand.txt
> like the other drivers do. (It's already documented generically in
> Documentation/.../nand.txt, but I think it's good practice to explicitly
> note which drivers support the binding, since nand_base doesn't do this
> generically for all NAND drivers.)
>

Yeah, good idea.

Thanks,
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

  reply	other threads:[~2013-11-05 23:40 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 12:55 [PATCH v3 00/28] Armada 370/XP NAND support Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 01/28] clk: mvebu: Add Core Divider clock Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 02/28] ARM: mvebu: Add Core Divider clock device-tree binding Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 03/28] ARM: mvebu: Add a 2 GHz fixed-clock Armada 370/XP Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 04/28] ARM: mvebu: Add the core-divider clock to " Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 05/28] mtd: nand: pxa3xx: Make config menu show supported platforms Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 06/28] mtd: nand: pxa3xx: Prevent sub-page writes Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 07/28] mtd: nand: pxa3xx: Early variant detection Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 08/28] mtd: nand: pxa3xx: Use chip->cmdfunc instead of the internal Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 09/28] mtd: nand: pxa3xx: Split FIFO size from to-be-read FIFO count Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 10/28] mtd: nand: pxa3xx: Replace host->page_size by mtd->writesize Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 11/28] mtd: nand: pxa3xx: Add a nice comment to pxa3xx_set_datasize() Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 12/28] mtd: nand: pxa3xx: Use a completion to signal device ready Ezequiel Garcia
2013-11-05 19:51   ` Brian Norris
2013-11-06  0:28     ` Ezequiel Garcia
2013-11-06  0:46       ` Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 13/28] mtd: nand: pxa3xx: Add bad block handling Ezequiel Garcia
2013-11-05 18:23   ` Brian Norris
2013-11-05 23:40     ` Ezequiel Garcia [this message]
2013-11-06  1:36       ` Brian Norris
2013-11-05 12:55 ` [PATCH v3 14/28] mtd: nand: pxa3xx: Add driver-specific ECC BCH support Ezequiel Garcia
2013-11-05 18:31   ` Brian Norris
2013-11-05 23:24     ` Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 15/28] mtd: nand: pxa3xx: Clear cmd buffer #3 (NDCB3) on command start Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 16/28] mtd: nand: pxa3xx: Add helper function to set page address Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 17/28] mtd: nand: pxa3xx: Remove READ0 switch/case falltrough Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 18/28] mtd: nand: pxa3xx: Split prepare_command_pool() in two stages Ezequiel Garcia
2013-11-05 18:32   ` Brian Norris
2013-11-05 12:55 ` [PATCH v3 19/28] mtd: nand: pxa3xx: Move the data buffer clean to prepare_start_command() Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 20/28] mtd: nand: pxa3xx: Fix SEQIN column address set Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 21/28] mtd: nand: pxa3xx: Add a read/write buffers markers Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 22/28] mtd: nand: pxa3xx: Introduce multiple page I/O support Ezequiel Garcia
2013-11-05 19:04   ` Brian Norris
2013-11-06  1:13     ` Ezequiel Garcia
2013-11-06  2:20       ` Brian Norris
2013-11-06  2:27         ` Brian Norris
2013-11-06  3:35         ` Ezequiel Garcia
2013-11-06 11:32         ` Ezequiel Garcia
2013-11-18 18:10           ` Brian Norris
2013-11-18 18:33             ` Ezequiel Garcia
2013-11-18 18:50               ` Brian Norris
2013-12-04 21:41                 ` Brian Norris
2013-11-05 19:08   ` Brian Norris
2013-11-05 12:55 ` [PATCH v3 23/28] mtd: nand: pxa3xx: Add multiple chunk write support Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 24/28] mtd: nand: pxa3xx: Add ECC BCH correctable errors detection Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 25/28] ARM: mvebu: Add support for NAND controller in Armada 370/XP Ezequiel Garcia
2013-11-05 13:29   ` Jason Cooper
2013-11-05 13:51     ` Ezequiel Garcia
2013-11-05 15:15       ` Jason Cooper
2013-11-05 15:37         ` Ezequiel Garcia
2013-11-06  8:24         ` Thomas Petazzoni
2013-11-06 11:42           ` Jason Cooper
2013-11-06 12:56             ` Thomas Petazzoni
2013-11-06 17:21               ` Jason Cooper
2013-11-05 12:55 ` [PATCH v3 26/28] ARM: mvebu: Enable NAND controller in Armada XP GP board Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 27/28] ARM: mvebu: Enable NAND controller in Armada 370 Mirabox Ezequiel Garcia
2013-11-05 12:55 ` [PATCH v3 28/28] mtd: nand: pxa3xx: Add documentation about the controller Ezequiel Garcia

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=20131105234055.GE11759@localhost \
    --to=ezequiel.garcia@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).