linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: LW@KARO-electronics.de (Lothar Waßmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv4 5/5] mtd: gpmi: prevent creating a new BBT when blockmark swapping is disabled
Date: Tue, 29 Jul 2014 08:31:45 +0200	[thread overview]
Message-ID: <20140729083145.647b77fc@ipc1.ka-ro> (raw)
In-Reply-To: <20140728052906.GA3095@norris-Latitude-E6410>

Hi,

Brian Norris wrote:
> Hi Lothar,
> 
> On Thu, Jun 12, 2014 at 03:20:45PM +0200, Lothar Wa?mann wrote:
> > Without blockmark swapping, there is no use in creating a BBT from
> > scratch, so use a BBT descriptor with NAND_BBT_CREATE unset in this
> > case.
> 
> I'm curious: what is your plan if there is no BBT available on your
> device, or if it ever gets corrupted? IIUC, nand_bbt will just assume
> you have no bad blocks, and it will never write a bad block table to
> flash. This also means no subsequent discoverable bad blocks can be
> recorded across power cycles, I believe.
> 
That won't happen (unless it's not possible to create a BBT because all
the possible blocks for the BBT are bad), because the bootloader will
have created one before Linux is started.

> Maybe you don't want to specify your own nand_bbt_descr's at all, but
> you just need to set:
> 
> 	chip->bbt_options |= NAND_BBT_CREATE_EMPTY | NAND_BBT_NO_OOB;
> 
> (Note: there's a little bit of fuzziness about NAND_BBT_* flags, where
> some are targeted for the nand_chip::bbt_options field, and others
> belong in struct nand_bbt_descr::options.)
> 
> But if for some reason we need to keep this patch, a comment below:
> 
> > Signed-off-by: Lothar Wa?mann <LW@KARO-electronics.de>
> > ---
> >  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   28 +++++++++++++++++++++++++++-
> >  1 file changed, 27 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> > index 37537b4..fc710d7 100644
> > --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> > +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> > @@ -43,6 +43,29 @@ static struct nand_bbt_descr gpmi_bbt_descr = {
> >  	.pattern	= scan_ff_pattern
> >  };
> >  
> > +static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' };
> > +static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' };
> > +
> > +static struct nand_bbt_descr bbt_main_no_oob_descr = {
> > +	.options = NAND_BBT_LASTBLOCK | NAND_BBT_WRITE |
> > +	NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP |
> > +	NAND_BBT_NO_OOB,
> 
> Please indent the above two lines a bit, preferably matching the
> indentation of NAND_BBT_LASTBLOCK. It should be clear that this is a
> continuation of the '.options' initialization.
> 
OK.

> > +	.len = 4,
> > +	.veroffs = 4,
> > +	.maxblocks = NAND_BBT_SCAN_MAXBLOCKS,
> > +	.pattern = bbt_pattern,
> > +};
> > +
> > +static struct nand_bbt_descr bbt_mirror_no_oob_descr = {
> > +	.options = NAND_BBT_LASTBLOCK | NAND_BBT_WRITE |
> > +	NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP |
> > +	NAND_BBT_NO_OOB,
> 
> Same here.
> 
> > +	.len = 4,
> > +	.veroffs = 4,
> > +	.maxblocks = NAND_BBT_SCAN_MAXBLOCKS,
> > +	.pattern = mirror_pattern,
> > +};
> > +
> >  /*
> >   * We may change the layout if we can get the ECC info from the datasheet,
> >   * else we will use all the (page + OOB).
> > @@ -1728,8 +1751,11 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
> >  			chip->bbt_options |= NAND_BBT_NO_OOB_BBM;
> >  
> >  		if (of_property_read_bool(this->dev->of_node,
> > -						"fsl,no-blockmark-swap"))
> > +						"fsl,no-blockmark-swap")) {
> >  			this->swap_block_mark = false;
> > +			chip->bbt_td = &bbt_main_no_oob_descr;
> > +			chip->bbt_md = &bbt_mirror_no_oob_descr;
> 
> My initial recommendation for this patch and the previous patch means
> that you could just drop both patches and replace them with the
> following:
> 
> 			/* Comment here to explain why... */
> 			chip->bbt_options |= NAND_BBT_CREATE_EMPTY |
> 					     NAND_BBT_NO_OOB |
> 					     NAND_BBT_NO_OOB_BBM;
OK.

Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________

  reply	other threads:[~2014-07-29  6:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12 13:20 [PATCHv4 0/5] mtd: gpmi: make blockmark swapping optional Lothar Waßmann
2014-06-12 13:20 ` [PATCHv4 1/5] mtd: gpmi: remove useless (void *) type casts and spaces between type casts and variables Lothar Waßmann
2014-06-12 13:20   ` [PATCHv4 2/5] mtd: gpmi: remove line breaks from error messages and improve wording Lothar Waßmann
2014-06-12 13:20     ` [PATCHv4 3/5] mtd: gpmi: make blockmark swapping optional Lothar Waßmann
2014-06-12 13:20       ` [PATCHv4 4/5] of/mtd/nand: add generic binding and helper for NAND_BBT_NO_OOB_BBM Lothar Waßmann
2014-06-12 13:20         ` [PATCHv4 5/5] mtd: gpmi: prevent creating a new BBT when blockmark swapping is disabled Lothar Waßmann
2014-07-28  5:29           ` Brian Norris
2014-07-29  6:31             ` Lothar Waßmann [this message]
2014-07-24  2:06         ` [PATCHv4 4/5] of/mtd/nand: add generic binding and helper for NAND_BBT_NO_OOB_BBM Brian Norris
2014-07-24  6:49           ` Lothar Waßmann
2014-07-24  7:47             ` Brian Norris
2014-06-26 10:44 ` [PATCHv4 0/5] mtd: gpmi: make blockmark swapping optional Lothar Waßmann
2014-07-28  5:31 ` Brian Norris

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=20140729083145.647b77fc@ipc1.ka-ro \
    --to=lw@karo-electronics.de \
    --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).