Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4126301yba; Wed, 17 Apr 2019 05:17:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg9QBOxQZm1MhgRMnN6f32a97cSQz2Dv9iXORT7KDj0s2hM8ixKn9llMxY1t9XR66pIsUJ X-Received: by 2002:a17:902:be0a:: with SMTP id r10mr85626344pls.4.1555503422287; Wed, 17 Apr 2019 05:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555503422; cv=none; d=google.com; s=arc-20160816; b=KJuYeXTxfob/S/F2izmKjdetBUMxl14xUE61EOHkc2xws9gjh9y5CVZaSH/4mIsMNj orOXn/sfodY0b9bIXhA+PTukcZdGcTsT77Dvj9EHE2xdbpycUmbxRz2Mosk6RWqp08Yx FsU26dhdd+8IzMr1YSeAZ94TzJg1SEr0vQWsMGVAnqTisbhBpu9rKEQewHCjUXHW8Gy4 BOWmV97jDhTQkOMKSqUQpkya3H4HghwgvFNU4rRwAiEwxD/HKWlWofRmctHeERoKJrCi I4hFnWHy0ZwqLZHhIc+eL88cP8/8KbnbQIODEYQYdH/67zdxxdJAkZ+ELLzr9M07fwFb 0FZQ== 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=wwf1Nyfq3T08+ZuZG90w9ecN66+rmGvgtYREcpNbH2E=; b=XXwQZWSd+AEoHs432ZCoF22tEt0MnQmbrn4HwhYM5vcZCMZO1EQPcjmBNdLJk7c3vY EIjbSJCVpwtvkNtp7sc4UXvxlbRK/FPe7gPzQ/lnyyOH4ap4NxAbIvRIhFfBkyYXJ00Z 8kqUYu6Cy4zhqDt/bVCrk6E+8ywNq6n02pviWakfAlFZmMXIcwqzzrmyRNXKuSpystfn DuH3d6Ak6aykO8wQn+quhxT5BubBpz1dlVLFs0glAOjn/DfarP49IkCP9PhTVoZU1jYF OV6FVZYZU3Hhl9paVmsY3SbmfWhRfCGBe1Nq3AblvrZXZPJnn1PExMClPBHyhdn8oHil NVEw== 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 19si49494939pgl.402.2019.04.17.05.16.46; Wed, 17 Apr 2019 05:17:02 -0700 (PDT) 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 S1732008AbfDQMPl convert rfc822-to-8bit (ORCPT + 99 others); Wed, 17 Apr 2019 08:15:41 -0400 Received: from skedge04.snt-world.com ([91.208.41.69]:49272 "EHLO skedge04.snt-world.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732090AbfDQMP0 (ORCPT ); Wed, 17 Apr 2019 08:15:26 -0400 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 skedge04.snt-world.com (Postfix) with ESMTPS id 3B27767A887; Wed, 17 Apr 2019 14:15:20 +0200 (CEST) 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; Wed, 17 Apr 2019 14:15:19 +0200 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; Wed, 17 Apr 2019 14:15:19 +0200 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 v5 2/7] mtd: onenand: Store bad block marker position in chip struct Thread-Topic: [PATCH v5 2/7] mtd: onenand: Store bad block marker position in chip struct Thread-Index: AQHU9Rc5eF4njLLmwUeQtVWka7UOtw== Date: Wed, 17 Apr 2019 12:15:19 +0000 Message-ID: <20190417121420.21752-3-frieder.schrempf@kontron.de> References: <20190417121420.21752-1-frieder.schrempf@kontron.de> In-Reply-To: <20190417121420.21752-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.193] 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: 3B27767A887.AD46F 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 Reviewed-by: Miquel Raynal --- 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..bfe9e10fae04 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; + unsigned 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