Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp980378ybe; Thu, 19 Sep 2019 06:56:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHdd+WwkDk3C1HfXOAZkq336rl/tIqT6RCRt0FWMMvgJ4pVaHEil226bCBY4nCifXh3FWh X-Received: by 2002:a17:906:244c:: with SMTP id a12mr14117671ejb.288.1568901407403; Thu, 19 Sep 2019 06:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568901407; cv=none; d=google.com; s=arc-20160816; b=DCfLbK3eYSfBwkZQRSWi6SpoFAS9eQQ4Lvn2d4nqeo4K9po+x+6hsxe8mX8UQzaJov ufP3u5CdZpr6hNocbO4M1ZceS9K3fW5rBVAkxQEaBJydOaszDQBQq3eX+2XZ4ALG3jm3 nMsiveqN3H7NNDzYFSzJOJWjz4MJkHAEvRsxRlU07WzhEE6/Rtikc9x5H7vuaq1KTVor 6qLImkXlp3aosETKC6V76pEqxX/6G/q9e/YavKdzvlyi+FPPdK5vhOD8Ey13GWjSjOGQ QU81sAb4z4r3ZqP8InAPhFP705i9DUcuTWrccME4oXIcIrQSK8fXtBmYh5mZYVBp/hF1 Ai5Q== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=NY8iNaxIRG1djRo95TWkxd0iGF2RTVnkB2AW2okwzEQ=; b=SR0TSAn+3iBhx0NTdS86eKNn+Da9JDoNZsVKMalO4qbOf3LldaGn5WDn5HbUeuCUaJ Z7t8O6EbN/BOK5x+yZwldGM9Zy4L56T3/P5WdYGdXZ5lREFNbBXEad/U0g958d0mKfLW vwNDSYqycSvdeqT0Ems5HwYLiMgAP6IPK7hYkP7WbG6ZbAeP3Okewk8gVJZwqdIVquwh txSV8vL4HNkocvynP58A8pN7k4Vfk7KZb416pHrdLYGPNdyVOIRYWdftLFcpZWuxq7oi c0k/snR1R8pAlisqyJxFi+85mWXox9dDFwPomoS4KDZ1Xi/dcQEKWl4NHCFz2ktkuPXA bBpg== 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 e47si5426816ede.325.2019.09.19.06.56.23; Thu, 19 Sep 2019 06:56:47 -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 S1732346AbfISNS0 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 19 Sep 2019 09:18:26 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:53491 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729629AbfISNS0 (ORCPT ); Thu, 19 Sep 2019 09:18:26 -0400 X-Originating-IP: 86.250.200.211 Received: from xps13 (lfbn-1-17395-211.w86-250.abo.wanadoo.fr [86.250.200.211]) (Authenticated sender: miquel.raynal@bootlin.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 1B180E0015; Thu, 19 Sep 2019 13:18:20 +0000 (UTC) Date: Thu, 19 Sep 2019 15:18:20 +0200 From: Miquel Raynal To: Schrempf Frieder Cc: Piotr Sroka , Richard Weinberger , David Woodhouse , Brian Norris , "Marek Vasut" , Vignesh Raghavendra , "Boris Brezillon" , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] - change calculating of position page containing BBM Message-ID: <20190919151820.2bb8313d@xps13> In-Reply-To: References: <20190919124139.10856-1-piotrs@cadence.com> <20190919145819.66e74aef@xps13> Organization: Bootlin X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Schrempf Frieder wrote on Thu, 19 Sep 2019 13:15:08 +0000: > On 19.09.19 14:58, Miquel Raynal wrote: > > Hi Piotr, > > > > Piotr Sroka wrote on Thu, 19 Sep 2019 13:41:35 > > +0100: > > > >> Change calculating of position page containing BBM > >> > >> If none of BBM flags is set then function nand_bbm_get_next_page > >> reports EINVAL. It causes that BBM is not read at all during scanning > >> factory bad blocks. The result is that the BBT table is build without > >> checking factory BBM at all. For Micron flash memories none of this > >> flag is set if page size is different than 2048 bytes. > > I wonder if it wouldn't be better to fix the Micron driver instead: > > --- a/drivers/mtd/nand/raw/nand_micron.c > +++ b/drivers/mtd/nand/raw/nand_micron.c > @@ -448,6 +448,8 @@ static int micron_nand_init(struct nand_chip *chip) > > if (mtd->writesize == 2048) > chip->options |= NAND_BBM_FIRSTPAGE | > NAND_BBM_SECONDPAGE; > + else > + chip->options |= NAND_BBM_FIRSTPAGE; That's what I forgot in my last answer to this thread, I think I only told Piotr privately: I would like both. I think it is important to fix the bbm_get_next_page function but for clarity, setting the FIRSTPAGE flag in Micron's driver seems also pertinent. > > ondie = micron_supports_on_die_ecc(chip); > > > > > > "none of these flags are set" > > > >> > >> This patch changes the nand_bbm_get_next_page function. > > > > "Address this regression by changing the > > nand_bbm_get_next_page_function." > > > >> It will return 0 if none of BBM flag is set and page parameter is 0. > > > > no BBM flag is set > > > >> After that modification way of discovering factory bad blocks will work > >> similar as in kernel version 5.1. > >> > > > > Fixes + stable tags would be great! > > > >> Signed-off-by: Piotr Sroka > >> --- > >> drivers/mtd/nand/raw/nand_base.c | 8 ++++++-- > >> 1 file changed, 6 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > >> index 5c2c30a7dffa..f64e3b6605c6 100644 > >> --- a/drivers/mtd/nand/raw/nand_base.c > >> +++ b/drivers/mtd/nand/raw/nand_base.c > >> @@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page) > >> struct mtd_info *mtd = nand_to_mtd(chip); > >> int last_page = ((mtd->erasesize - mtd->writesize) >> > >> chip->page_shift) & chip->pagemask; > >> + unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE > >> + | NAND_BBM_LASTPAGE; > >> > >> + if (page == 0 && !(chip->options & bbm_flags)) > >> + return 0; > >> if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE) > >> return 0; > >> - else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE) > >> + if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE) > >> return 1; > >> - else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE) > >> + if (page <= last_page && chip->options & NAND_BBM_LASTPAGE) > >> return last_page; > >> > >> return -EINVAL; > > > > Lookgs good otherwise. > > > > Thanks, > > Miquèl > > Thanks, Miquèl