Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752512AbbH0AHk (ORCPT ); Wed, 26 Aug 2015 20:07:40 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33869 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949AbbH0AHj (ORCPT ); Wed, 26 Aug 2015 20:07:39 -0400 Date: Wed, 26 Aug 2015 17:07:31 -0700 From: Brian Norris To: Bean Huo =?utf-8?B?6ZyN5paM5paMIChiZWFuaHVvKQ==?= Cc: Xander Huff , "dwmw2@infradead.org" , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "jeff.westfahl@ni.com" , "jaeden.amero@ni.com" , "joshc@ni.com" , Ben Shelton , Richard Weinberger , Peter Pan =?utf-8?B?5r2Y5qCLIChwZXRlcnBhbmRvbmcp?= Subject: Re: [RESEND RESEND RESEND PATCH v2] mtd: nand_bbt: scan for next free bbt block if writing bbt fails Message-ID: <20150827000731.GW81844@google.com> References: <1439330122-41912-1-git-send-email-xander.huff@ni.com> <1440524966-29627-1-git-send-email-xander.huff@ni.com> <20150825183400.GH81844@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2831 Lines: 76 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/