Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4144404yba; Wed, 17 Apr 2019 05:39:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUtX4DsOdyqcwq3HyKNAxoMkQiXqmJOhBJFRV+Yi/YVDkx/YcFHC7AydpBJrnxmGFpSIVF X-Received: by 2002:a17:902:2a:: with SMTP id 39mr48353337pla.64.1555504744193; Wed, 17 Apr 2019 05:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555504744; cv=none; d=google.com; s=arc-20160816; b=iHM6q5vi3/ma2ypLs+/7h6h2bt3smCEXO8DboILXUsHRnTST0mdLb0doxDQxjPxRNZ OFD+i0nwgUWYDE2EmIstECTwsBhXGiUWITZzqQoEZRNJC1r3Kok/1QXPBA/WCznSnxRA ogSMBUVLL29Aj32sRp1AIU0Tto57OEwU6P359lchW0gTqUP1UYacka0qt9Hh3Pa/+i2B F3alRzCUbhEWWXb+yBx4nl8QOdR3Aj3Fp7CsiJpP8t6C6RKCpvVVWtGcFAUbmnJoL++3 aU6YAMve6q4WiXoNQtj+dPDAVpNOOy1XTNcCaozB01xHmftoBDPLoMYcMb7xqZUemw8M kylg== 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=jnjeGFuMfzW1RUFBwkLy3+SCDV26KUNJq6aTCt+GSxi51GZIG7jpkPrpx0y7TzsHX7 veI2oe6JPm4Zwc+gsaRHjt8/s3awBlMavzbQS4SHBVzlmB6sEzD9DG5P8R9stJJ/Y35/ AnSV89TKm5m20Wf/K6OP5iSX7/WoHfCCj8SjDtlS53sOrA9MKFeD2nRs0Y4alI7OnHls q5VcrXLXrwm16swrMTO2t++dD9BwVfm2Oosx77O9Zr71pTbHAuOh4vn7phe7XPdsMoc6 /k7tichSWe0WQSmsNlwrfcQnj4sm/cCtyGHd5zzwSUnsSpLwm5uPWJimV06MHAeR4Q/u YzGA== 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 q5si46837941pga.498.2019.04.17.05.38.49; Wed, 17 Apr 2019 05:39:04 -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 S1732113AbfDQMgi convert rfc822-to-8bit (ORCPT + 99 others); Wed, 17 Apr 2019 08:36:38 -0400 Received: from skedge04.snt-world.com ([91.208.41.69]:55186 "EHLO skedge04.snt-world.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726708AbfDQMgi (ORCPT ); Wed, 17 Apr 2019 08:36:38 -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 9ED5367A6E8; Wed, 17 Apr 2019 14:36:35 +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:36:35 +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:36:35 +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 v6 2/7] mtd: onenand: Store bad block marker position in chip struct Thread-Topic: [PATCH v6 2/7] mtd: onenand: Store bad block marker position in chip struct Thread-Index: AQHU9Rox82D1mFBz3kG4yQ5EH0ZdnQ== Date: Wed, 17 Apr 2019 12:36:35 +0000 Message-ID: <20190417123631.22545-3-frieder.schrempf@kontron.de> References: <20190417123631.22545-1-frieder.schrempf@kontron.de> In-Reply-To: <20190417123631.22545-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: 9ED5367A6E8.A180F 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