Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5895842imu; Wed, 30 Jan 2019 05:31:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN7bbhnFmwo6mKifynzb1QvqWNHO3e0UH9Sv5Ql8fwDsm3FqWqp0bmnvOs2DDSNIRyRqT5M2 X-Received: by 2002:a63:d747:: with SMTP id w7mr26963269pgi.360.1548855068403; Wed, 30 Jan 2019 05:31:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548855068; cv=none; d=google.com; s=arc-20160816; b=hQ6mCmv9+VnKZSVnRraKVWx5xcSYVEuIj3QIyAqZwVdyrdyNuMs2NByfiNOFPHyyPL fc3lV3kObt4m7O+8eBZj2bCUhhwMBPjSllDhyimtxCQR5GSrzbbr4DzKzfFMihCOW9kh /HbRpifWQjmYl5e07dD5uWPh19iIfinDwZ7KlwrDHTLVADCXYy/OfeDJEHzUazvPSReL HMKSzSR0ITN0nEWoCIN3pwUCrCrLVlcGeqI0tffr4AiTSFyPtMH4Q5pUgOJIUA9tOZUz 2luncUA/vqJg5w7Ls56x38wex2VLvhhS5ax+9ibz2sXW4WOb46rBPqDu+AEUsDnUs4GB g7AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=qpLUE1HwLty6/Yk16JhZlBqTIeFJOgKT4V5i6lZp30A=; b=Co2VZ0qLT/Q8GgYxTRJkuSm6vOHbq6cGaYnjYgXkY7BJXX8AL3Tt8QFmPQHGXzvQ39 4SA+A0wH3V4WhbQHiW/4MaTma2S9utRae6I6EzSkcjAVJbp31s3/eODr1Eot179LeHJL GqEFz130HhZm/2l+e8tkffH8Wg7JqWfoOO3bIfxiiZVb/jkAjzdDZGPqrdP1KwCypqzb YOImDWOGJsDkPhIJQSp++fnSF5f8fP+lYf7bcdHN3RJGGQDefthJ4Y7EDjCzGj9HeuIO 0fpNaCr46M9Lt9kEL0urA5PmUwSP06nXrHt50x6XYG2H6LtPEhrrMZRWFeBXSx/Q3G3J EqZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=udQRjtYq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19si1420607pgf.573.2019.01.30.05.30.51; Wed, 30 Jan 2019 05:31:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=udQRjtYq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730988AbfA3N2v (ORCPT + 99 others); Wed, 30 Jan 2019 08:28:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:51786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726233AbfA3N2v (ORCPT ); Wed, 30 Jan 2019 08:28:51 -0500 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CF82920989; Wed, 30 Jan 2019 13:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548854929; bh=qavFVLHOnztYwoAr490K7QpDJg81d45YuBOQPHprG6k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=udQRjtYqYAV3tiBLoPP6EeR8oRLUeKGt9IiKjpyIDwcCZkXEvDg5yzIJQhuXwJ05m R2QWjJ/P14lwKTeinjzUVce5lp3havNOTTOSW1jy+uUl3jti/Q5VvVHQI4xVGyaqhk RhEJnhFTTMANOINH4gdtgDb3PKmP/x2g6WHh5MoQ= Date: Wed, 30 Jan 2019 14:28:38 +0100 From: Boris Brezillon To: Schrempf Frieder Cc: "miquel.raynal@bootlin.com" , "richard@nod.at" , Kyungmin Park , David Woodhouse , Brian Norris , "Marek Vasut" , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 1/5] mtd: nand: Always store info about bad block markers in chip struct Message-ID: <20190130142838.5590f8b4@bbrezillon> In-Reply-To: <20190130130111.32724-2-frieder.schrempf@kontron.de> References: <20190130130111.32724-1-frieder.schrempf@kontron.de> <20190130130111.32724-2-frieder.schrempf@kontron.de> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Jan 2019 13:01:44 +0000 Schrempf Frieder wrote: > From: Frieder Schrempf > > The information about where the manufacturer puts the bad block > markers inside the bad block and in the OOB data is stored in > different places. Let's move this information to nand_chip.options > and nand_chip.badblockpos. > > As this chip-specific information is not directly related to the > bad block table (BBT), we also rename the flags to NAND_BBM_*. > > Signed-off-by: Frieder Schrempf > --- > drivers/mtd/nand/onenand/onenand_base.c | 2 +- > drivers/mtd/nand/onenand/onenand_bbt.c | 2 +- > drivers/mtd/nand/raw/nand_amd.c | 2 +- > drivers/mtd/nand/raw/nand_base.c | 12 ++++++------ > drivers/mtd/nand/raw/nand_bbt.c | 4 ++-- > drivers/mtd/nand/raw/nand_esmt.c | 2 +- > drivers/mtd/nand/raw/nand_hynix.c | 4 ++-- > drivers/mtd/nand/raw/nand_macronix.c | 2 +- > drivers/mtd/nand/raw/nand_micron.c | 2 +- > drivers/mtd/nand/raw/nand_samsung.c | 4 ++-- > drivers/mtd/nand/raw/nand_toshiba.c | 2 +- > drivers/mtd/nand/raw/sh_flctl.c | 4 ++-- > include/linux/mtd/bbm.h | 14 +------------- > include/linux/mtd/rawnand.h | 15 +++++++++++++++ Might be better to split that in 2 patches: - update onenand logic - update rawnand logic > 14 files changed, 37 insertions(+), 34 deletions(-) > > diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c > index 4ca4b194e7d7..d6701b8f031f 100644 > --- a/drivers/mtd/nand/onenand/onenand_base.c > +++ b/drivers/mtd/nand/onenand/onenand_base.c > @@ -2458,7 +2458,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) > bbm->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1); > > /* We write two bytes, so we don't have to mess with 16-bit access */ > - ofs += mtd->oobsize + (bbm->badblockpos & ~0x01); > + ofs += mtd->oobsize + (this->badblockpos & ~0x01); Looks like the ->badblockpos field does not exist in struct onenand_chip, which means you didn't compile test this part ;-). > /* FIXME : What to do when marking SLC block in partition > * with MLC erasesize? For now, it is not advisable to > * create partitions containing both SLC and MLC regions. > diff --git a/drivers/mtd/nand/onenand/onenand_bbt.c b/drivers/mtd/nand/onenand/onenand_bbt.c > index dde20487937d..880b0abd36c8 100644 > --- a/drivers/mtd/nand/onenand/onenand_bbt.c > +++ b/drivers/mtd/nand/onenand/onenand_bbt.c > @@ -191,7 +191,7 @@ static int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) > return -ENOMEM; > > /* Set the bad block position */ > - bbm->badblockpos = ONENAND_BADBLOCK_POS; > + this->badblockpos = NAND_BBM_POS_ONENAND; This should be done in onenand_base.c not onenand_bbt.c. > > /* Set erase shift */ > bbm->bbt_erase_shift = this->erase_shift; ... > diff --git a/drivers/mtd/nand/raw/nand_bbt.c b/drivers/mtd/nand/raw/nand_bbt.c > index 1b722fe9213c..862eaa3a0552 100644 > --- a/drivers/mtd/nand/raw/nand_bbt.c > +++ b/drivers/mtd/nand/raw/nand_bbt.c > @@ -466,7 +466,7 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf, > > pr_info("Scanning device for bad blocks\n"); > > - if (bd->options & NAND_BBT_SCAN2NDPAGE) > + if (this->options & NAND_BBM_SECONDPAGE) > numpages = 2; > else > numpages = 1; > @@ -487,7 +487,7 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf, > from = (loff_t)startblock << this->bbt_erase_shift; > } > > - if (this->bbt_options & NAND_BBT_SCANLASTPAGE) > + if (this->bbt_options & NAND_BBM_LASTPAGE) You're not checking the right field here: if (this->options & NAND_BBM_LASTPAGE) > from += mtd->erasesize - (mtd->writesize * numpages); > > for (i = startblock; i < numblocks; i++) {