[PATCH v3] mtd: nand: add option to erase NAND blocks even if detected as bad.

Boris Brezillon boris.brezillon at free-electrons.com
Mon May 15 02:41:59 PDT 2017


On Mon, 15 May 2017 11:23:55 +0200
Richard Weinberger <richard at nod.at> wrote:

> Boris,
> 
> Am 15.05.2017 um 10:21 schrieb Boris Brezillon:
>  > #ifndef statements should be at the beginning of the line. But anyway,
> > I think we all agree that always forcing bad block erasure is a bad
> > idea. If we accept to support this feature, this should be done through
> > a per-NAND-chip debugfs entry, with fine grained selection of the block
> > that we're allowing to be forcibly erased.
> > 
> > Here is a suggestion:
> > 
> > echo all > /sys/kernel/debug/nand/<nand-chip-name>/erase-bad-blocks
> > echo none > /sys/kernel/debug/nand/<nand-chip-name>/erase-bad-blocks
> > echo X,Y-Z,... > /sys/kernel/debug/nand/<nand-chip-name>/erase-bad-blocks
> > 
> > where X is an eraseblock number, and X-Y is a range of eraseblocks.  
> 
> Will a write to that file trigger the erase or just allow it?

Just allows it.

> 
> IMHO we can keept it simple such as:
> echo y > /sys/kernel/debug/nand/<nand-chip-name>/allow-bad-block-erase
> 
> Then a user can erase whatever he wants...

Well, I was proposing to do that because several users can use the same
NAND chip in parallel, and allowing to forcibly erase a bad block at
the NAND chip level can be dangerous in this case.
Here is a real example: 2 users are accessing 2 different partitions,
one wants to force bad block erasure on partition 1, while the other
just wants to normally erase partition 0. With the global
"allow/disallow bad block erasure" approach, you're just likely to
erase bad blocks in partition 0 as well.

> 
> > BTW, maybe we should create and expose a top-level mtd debugfs directory
> > to avoid exposing MTD related things at the root of the debugfs FS.
> > 
> > Something like:
> > 
> > /sys/kernel/debug/mtd/<dev-type>/...
> > 
> > so for the NAND related bits it would be
> > 
> > /sys/kernel/debug/mtd/nand/...  
> 
> Yes, this makes sense to me.
> 
> And since this is debugfs we can do what we want.

Yep.



More information about the linux-mtd mailing list