From patchwork Tue Apr 6 01:47:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshio Furuyama X-Patchwork-Id: 1462568 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=TjcB/xz5; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FDr5k3YSdz9sRR for ; Tue, 6 Apr 2021 11:48:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AzFVaTez51rY25btoBYrVPKo2om57mwbqbQEr1Cw3TY=; b=TjcB/xz5UESjOxT0nuGgLbdn4d IPLCQAFX38aUG5hxfvhTGyoIkLa8ENbiaqPxzYwYyqdW+eh0+1L3J7pMIzahYX+d1/6xgz2qUCIUh 52j2KL780iLWzmRwfDCxENhrOzReDpSz+A8cKGNQcy2Ku5miVo9/o12DsRuraAvSAs5FgY3fffNRW duFQU7rDq26PAJM5uA3bJjDz5Pimu6HMWfPZm2AfWyq1tVrXezUbSwEtVubgTwXExg0UgzZZETITu Eby0AzI306V191Hz2YelaeKpTjhzcHP8wN+Ka/iXzJBAU1ys7sxmkfH3/URbCVad2L+WIhz2xfEzg zbIRJxcA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTaok-001Bue-Ht; Tue, 06 Apr 2021 01:47:46 +0000 Received: from mo-csw1114.securemx.jp ([210.130.202.156] helo=mo-csw.securemx.jp) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lTaoc-001BtF-7f for linux-mtd@lists.infradead.org; Tue, 06 Apr 2021 01:47:43 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1114) id 1361lUwb008479; Tue, 6 Apr 2021 10:47:30 +0900 X-Iguazu-Qid: 2wGrBJasm3hdJ6uKHL X-Iguazu-QSIG: v=2; s=0; t=1617673650; q=2wGrBJasm3hdJ6uKHL; m=GP88N+NcFEyBcPCzzwJsFRf8/vyZgOZVf7KUXtPOf0U= Received: from imx12-a.toshiba.co.jp (imx12-a.toshiba.co.jp [61.202.160.135]) by relay.securemx.jp (mx-mr1113) id 1361lSqw038187 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 6 Apr 2021 10:47:29 +0900 Received: from enc02.toshiba.co.jp (enc02.toshiba.co.jp [61.202.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by imx12-a.toshiba.co.jp (Postfix) with ESMTPS id CFF6B1000AC; Tue, 6 Apr 2021 10:47:28 +0900 (JST) Received: from hop101.toshiba.co.jp ([133.199.85.107]) by enc02.toshiba.co.jp with ESMTP id 1361lS6q013306; Tue, 6 Apr 2021 10:47:28 +0900 From: Yoshio Furuyama To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] Fix the issue for clearing status process Date: Tue, 6 Apr 2021 10:47:26 +0900 X-TSB-HOP: ON Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210406_024739_269001_86AFB4E5 X-CRM114-Status: GOOD ( 14.33 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: In the unlikely event of bad block, it should update its block status to BBT, In this case, there are 2 kind of issue for handling a) Mark bad block status to BBT: It was fixed by Patric's patch b) Cl [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [210.130.202.156 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.130.202.156 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In the unlikely event of bad block, it should update its block status to BBT, In this case, there are 2 kind of issue for handling a) Mark bad block status to BBT: It was fixed by Patric's patch b) Clear status to BBT: I posted patch for this issue Patch: Issue of handing BBT (Bad Block Table) for some particular blocks (Ex:10, 11) Updating status is, first clear status, second set bad block status. Patrick's patch is only fixed the issue for setting status process, so this patch fix the clearing status process. Signed-off-by: Yoshio Furuyama --- drivers/mtd/nand/bbt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c index 64af6898131d..0780896eaafe 100644 --- a/drivers/mtd/nand/bbt.c +++ b/drivers/mtd/nand/bbt.c @@ -112,11 +112,13 @@ int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry, ((entry * bits_per_block) / BITS_PER_LONG); unsigned int offs = (entry * bits_per_block) % BITS_PER_LONG; unsigned long val = status & GENMASK(bits_per_block - 1, 0); + unsigned long shift = ((bits_per_block + offs <= BITS_PER_LONG) ? + (offs + bits_per_block - 1) : (BITS_PER_LONG - 1)); if (entry >= nanddev_neraseblocks(nand)) return -ERANGE; - pos[0] &= ~GENMASK(offs + bits_per_block - 1, offs); + pos[0] &= ~GENMASK(shift, offs); pos[0] |= val << offs; if (bits_per_block + offs > BITS_PER_LONG) {