All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: "Bean Huo 霍斌斌 (beanhuo)" <beanhuo@micron.com>
Cc: "Xander Huff" <xander.huff@ni.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jeff.westfahl@ni.com" <jeff.westfahl@ni.com>,
	"jaeden.amero@ni.com" <jaeden.amero@ni.com>,
	"joshc@ni.com" <joshc@ni.com>, "Ben Shelton" <ben.shelton@ni.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Peter Pan 潘栋 (peterpandong)" <peterpandong@micron.com>
Subject: Re: [RESEND RESEND RESEND PATCH v2] mtd: nand_bbt: scan for next free bbt block if writing bbt fails
Date: Wed, 26 Aug 2015 17:07:31 -0700	[thread overview]
Message-ID: <20150827000731.GW81844@google.com> (raw)
In-Reply-To: <A765B125120D1346A63912DDE6D8B6310BF47F35@NTXXIAMBX02.xacn.micron.com>

On Wed, Aug 26, 2015 at 03:57:00PM +0000, Bean Huo 霍斌斌 (beanhuo) wrote:
> > On Tue, Aug 25, 2015 at 12:49:26PM -0500, Xander Huff wrote:

> > > diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
> > > index 63a1a36..09f9e62 100644
> > > --- a/drivers/mtd/nand/nand_bbt.c
> > > +++ b/drivers/mtd/nand/nand_bbt.c

> > > -787,13 +788,42 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
> > >  		einfo.addr = to;
> > >  		einfo.len = 1 << this->bbt_erase_shift;
> > >  		res = nand_erase_nand(mtd, &einfo, 1);
> > > -		if (res < 0)
> > > +		if (res == -EIO && einfo.state == MTD_ERASE_FAILED
> > > +		    && einfo.priv == NAND_ERASE_BLOCK_ERASE_FAILED) {
> > 
> > Do you actually need that last condition? What's wrong with the first two?
> > 
> > > +			/* This block is bad. Mark it as such and see if
> > > +			 * there's another block available in the BBT area. */
> > > +			int block = page >>
> > > +				(this->bbt_erase_shift - this->page_shift);
> > > +			pr_info("nand_bbt: failed to erase block %d when writing
> > BBT\n",
> > > +				block);
> > > +			bbt_mark_entry(this, block, BBT_BLOCK_WORN);
> > > +
> > > +			res = this->block_markbad(mtd, block);
> > > +			if (res)
> > > +				pr_warn("nand_bbt: error %d while marking block %d
> > bad\n",
> > > +					res, block);
> > > +			goto next;
> > > +		} else if (res < 0)
> > >  			goto outerr;
> 
> 
> For my knowledge , we don't directly mark this block be a bad block,
> Just like ubi layer,this block also need to further testing and verify if
> It is real bad block.right?

That's a good point...we might want some kind of separate function for a
torture test. Might look at UBI's torture_peb() for inspiration.

> > >
> > >  		res = scan_write_bbt(mtd, to, len, buf,
> > >  				td->options & NAND_BBT_NO_OOB ? NULL :
> > >  				&buf[len]);
> > > -		if (res < 0)
> > > +		if (res == -EIO) {
> > > +			/* This block is bad. Mark it as such and see if
> > > +			 * there's another block available in the BBT area. */
> > > +			int block = page >>
> > > +				(this->bbt_erase_shift - this->page_shift);
> > > +			pr_info("nand_bbt: failed to erase block %d when writing
> > BBT\n",
> > > +				block);
> > > +			bbt_mark_entry(this, block, BBT_BLOCK_WORN);
> > > +
> > > +			res = this->block_markbad(mtd, block);
> > > +			if (res)
> > > +				pr_warn("nand_bbt: error %d while marking block %d
> > bad\n",
> > > +					res, block);
> > > +			goto next;
> > > +		} else if (res < 0)
> > >  			goto outerr;
> > >
> > >  		pr_info("Bad block table written to 0x%012llx, version 0x%02X\n",

Brian

  reply	other threads:[~2015-08-27  0:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 16:00 [PATCH v2] mtd: nand_bbt: scan for next free bbt block if writing bbt fails Xander Huff
2015-07-22 19:42 ` [RESEND PATCH " Xander Huff
2015-08-11 21:55   ` [RESEND RESEND " Xander Huff
2015-08-25 17:49     ` [RESEND RESEND " Xander Huff
2015-08-25 18:34       ` Brian Norris
2015-08-26 15:57         ` Bean Huo 霍斌斌 (beanhuo)
2015-08-27  0:07           ` Brian Norris [this message]
2015-09-04 21:20             ` Xander Huff

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=20150827000731.GW81844@google.com \
    --to=computersforpeace@gmail.com \
    --cc=beanhuo@micron.com \
    --cc=ben.shelton@ni.com \
    --cc=dwmw2@infradead.org \
    --cc=jaeden.amero@ni.com \
    --cc=jeff.westfahl@ni.com \
    --cc=joshc@ni.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=peterpandong@micron.com \
    --cc=richard@nod.at \
    --cc=xander.huff@ni.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.