Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2250958imj; Mon, 18 Feb 2019 02:43:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IaRtiK8mRgQYnQGO76T2gmdMG3T10kX+6yCNGBufB5GwxBFHXe46xxu1p95XQTmHl94vW4T X-Received: by 2002:a62:e716:: with SMTP id s22mr23299575pfh.35.1550486596122; Mon, 18 Feb 2019 02:43:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550486596; cv=none; d=google.com; s=arc-20160816; b=kbe/8zduSBTfYSaJEgYOiUf1t9xyqY87YWYjRJg4J9CT6iw8/eOSHes5sk1SvweXHe 4POcFer82+U8t0uzQaJ+58BQSas4DwT/h+fyi5rlZ8Hs8YND4dtM9sOUeE1a3ek6lnlY aOl1wJrwu2rORCYJCCc6W+nx3fGZCZIRj82c+ZMPPRFR+ro3ogDHD9U6gGMB3vJritlE CFdDvQz/bTGCdInn2RSiWCtbKiwceJsf5QPtszrL5jL6AMwb64DtO5W4kDU753lizpXo e3dxmKuPV2rfYsST1nuWf3hEnuaoZF0ZTd6WUgrqs0Xlb3NPGCIx/hdwmHW4lpxTM8wM Q/rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=GpqWPL7q2FIap8ITtsh1oCMJJ4BrTwjp6cZDaRmvtY4=; b=PgYwaaEVIK7tBJ0UoaAHMsbONQESBFCiTA3cYWpC1Vsck40P1bAUkBMcSsJxboW3Hb OGHGqK0ntDEOKdmsVM6nQDcmtbF16n9r/DtYUy6zaS+dixQQ4L4r8uTPR0n9Dg4f7RKr fQHAPZdG2hLTEyWYCBI3tZFQ7aThruXoMkI51QkCL9sgE9apFXRwThtShUrQ+kR3IU/S 9YDSPPYOdTBQ3LEbSRJYxOq+28vF3EUtfOOPBJTDv/Ve4J5JjV/VdvnkmiIr8Lf0RcdU jYL0nJ8HsgVDIS7sLkfvgxA4GHeb7wI/JBWcaPv6WTBd7ucv6fWcmk5g8V+BWhksZMuo 7llA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k74si7154939pfb.32.2019.02.18.02.43.00; Mon, 18 Feb 2019 02:43:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730096AbfBRKmq convert rfc822-to-8bit (ORCPT + 99 others); Mon, 18 Feb 2019 05:42:46 -0500 Received: from skedge03.snt-world.com ([91.208.41.68]:50144 "EHLO skedge03.snt-world.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727004AbfBRKmp (ORCPT ); Mon, 18 Feb 2019 05:42:45 -0500 Received: from sntmail14r.snt-is.com (unknown [10.203.32.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by skedge03.snt-world.com (Postfix) with ESMTPS id 7967F60376A; Mon, 18 Feb 2019 11:42:42 +0100 (CET) Received: from sntmail12r.snt-is.com (10.203.32.182) by sntmail14r.snt-is.com (10.203.32.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 18 Feb 2019 11:42:41 +0100 Received: from sntmail12r.snt-is.com ([fe80::e551:8750:7bba:3305]) by sntmail12r.snt-is.com ([fe80::e551:8750:7bba:3305%3]) with mapi id 15.01.1713.004; Mon, 18 Feb 2019 11:42:41 +0100 From: Schrempf Frieder To: "bbrezillon@kernel.org" , "miquel.raynal@bootlin.com" , "richard@nod.at" , Kyungmin Park , David Woodhouse , Brian Norris , "Marek Vasut" CC: "linux-mtd@lists.infradead.org" , "Schrempf Frieder" , "linux-kernel@vger.kernel.org" Subject: [PATCH v4 2/7] mtd: onenand: Store bad block marker position in chip struct Thread-Topic: [PATCH v4 2/7] mtd: onenand: Store bad block marker position in chip struct Thread-Index: AQHUx3asBl+PaSojc0CFv8B5tA994g== Date: Mon, 18 Feb 2019 10:42:41 +0000 Message-ID: <20190218104122.18788-3-frieder.schrempf@kontron.de> References: <20190218104122.18788-1-frieder.schrempf@kontron.de> In-Reply-To: <20190218104122.18788-1-frieder.schrempf@kontron.de> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.25.9.43] x-c2processedorg: 51b406b7-48a2-4d03-b652-521f56ac89f3 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-SnT-MailScanner-Information: Please contact the ISP for more information X-SnT-MailScanner-ID: 7967F60376A.AEE7D X-SnT-MailScanner: Not scanned: please contact your Internet E-Mail Service Provider for details X-SnT-MailScanner-SpamCheck: X-SnT-MailScanner-From: frieder.schrempf@kontron.de X-SnT-MailScanner-To: bbrezillon@kernel.org, computersforpeace@gmail.com, dwmw2@infradead.org, kyungmin.park@samsung.com, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, marek.vasut@gmail.com, miquel.raynal@bootlin.com, richard@nod.at X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 the chip struct, as we did it for rawnand. Signed-off-by: Frieder Schrempf --- drivers/mtd/nand/onenand/onenand_base.c | 5 ++++- drivers/mtd/nand/onenand/onenand_bbt.c | 3 --- include/linux/mtd/onenand.h | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c index 4ca4b194e7d7..f41d76248550 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); /* 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. @@ -3967,6 +3967,9 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) if (!(this->options & ONENAND_SKIP_INITIAL_UNLOCKING)) this->unlock_all(mtd); + /* Set the bad block marker position */ + this->badblockpos = ONENAND_BADBLOCK_POS; + ret = this->scan_bbt(mtd); if ((!FLEXONENAND(this)) || ret) return ret; diff --git a/drivers/mtd/nand/onenand/onenand_bbt.c b/drivers/mtd/nand/onenand/onenand_bbt.c index dde20487937d..57c31c81be18 100644 --- a/drivers/mtd/nand/onenand/onenand_bbt.c +++ b/drivers/mtd/nand/onenand/onenand_bbt.c @@ -190,9 +190,6 @@ static int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) if (!bbm->bbt) return -ENOMEM; - /* Set the bad block position */ - bbm->badblockpos = ONENAND_BADBLOCK_POS; - /* Set erase shift */ bbm->bbt_erase_shift = this->erase_shift; diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h index 0aaa98b219a4..e03aea7f7e61 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h @@ -94,6 +94,7 @@ struct onenand_chip { unsigned int technology; unsigned int density_mask; unsigned int options; + int badblockpos; unsigned int erase_shift; unsigned int page_shift; @@ -188,6 +189,8 @@ struct onenand_chip { /* Check byte access in OneNAND */ #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) +#define ONENAND_BADBLOCK_POS 0 + /* * Options bits */ -- 2.17.1