From patchwork Tue Feb 16 00:37:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshio Furuyama X-Patchwork-Id: 1440735 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:1231::1; helo=merlin.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=merlin.20170209 header.b=f0JO2K0m; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4DfhtK6zRtz9sVV for ; Tue, 16 Feb 2021 11:39:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qcrQQ7enzYlluosZCIvwJ4bls+6XczsJ0A3lCiLmBA4=; b=f0JO2K0mFf9WR58QndzyTfPfTt t6WxFyWxqVmfTrv5cn8qNpqhyyRN6A0gQl9A+PIgRQdiciStOp8vVKU7qD6B+dBzDk5fLxrU1sPxD YIXk4DyMPeXEy8YqehZvedl1nzjBkxzIM2VXtfK58UYVwwsJ1f6kkzPoqV2JbQV/nQ+7TsSTu11c2 EjNLL3AdAm3F92weRJ+vRmyczZ+NvLS6ryCkneP77R0rMeCbHjSKCA1EHn8AeSLUA6kkLaQcqzjs3 EX0i3lE0/xEjnAYYNnej9/lvXYw4SXEXSM5YhufojCCmF4qCLJ8njpy6Blcx4NLd5+GG1eA/YHVsQ VMCbYzoA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBoNn-0002Dw-7j; Tue, 16 Feb 2021 00:38:27 +0000 Received: from mo-csw1114.securemx.jp ([210.130.202.156] helo=mo-csw.securemx.jp) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBoNi-0002D9-3X for linux-mtd@lists.infradead.org; Tue, 16 Feb 2021 00:38:23 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1114) id 11G0c839023879; Tue, 16 Feb 2021 09:38:08 +0900 X-Iguazu-Qid: 2wGqn5DuWvVM6sYQCW X-Iguazu-QSIG: v=2; s=0; t=1613435888; q=2wGqn5DuWvVM6sYQCW; m=jnHDndSUrFfAQglWXjmb49JJo8sxPyZ3Gev6yI5lHw8= Received: from imx2.toshiba.co.jp (imx2.toshiba.co.jp [106.186.93.51]) by relay.securemx.jp (mx-mr1110) id 11G0c5PV015544; Tue, 16 Feb 2021 09:38:06 +0900 Received: from enc01.toshiba.co.jp ([106.186.93.100]) by imx2.toshiba.co.jp with ESMTP id 11G0c5oW005610; Tue, 16 Feb 2021 09:38:05 +0900 (JST) Received: from hop001.toshiba.co.jp ([133.199.164.63]) by enc01.toshiba.co.jp with ESMTP id 11G0c59I026414; Tue, 16 Feb 2021 09:38:05 +0900 From: Yoshio Furuyama To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Subject: [PATCH v1] mtd: nand: Fix BBT update issue Date: Tue, 16 Feb 2021 09:37:55 +0900 X-TSB-HOP: ON Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: <1613435875-6846-1-git-send-email-ytc-mb-yfuruyama7@kioxia.com> References: <1613435875-6846-1-git-send-email-ytc-mb-yfuruyama7@kioxia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210215_193822_550841_C3F58EA9 X-CRM114-Status: GOOD ( 10.43 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [210.130.202.156 listed in wl.mailspike.net] -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 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Fixed issue of manages BBT (Bad Block Table). It didn't mark correctly when a specific block was bad block. This issue occurs when the bad block mark (3-bit chunk) is crosses over 32 bit (e.g. Block10, Block21...) unit. Signed-off-by: Yoshio Furuyama --- drivers/mtd/nand/bbt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c index 044adf913854..979c47e61381 100644 --- a/drivers/mtd/nand/bbt.c +++ b/drivers/mtd/nand/bbt.c @@ -112,18 +112,20 @@ 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) { unsigned int rbits = bits_per_block + offs - BITS_PER_LONG; pos[1] &= ~GENMASK(rbits - 1, 0); - pos[1] |= val >> rbits; + pos[1] |= (val >> (BITS_PER_LONG - offs)); } return 0;