Question regarding mtd/nand/bbt.c with recent corner case fix
Subsystems (2)
Hi,
Recently I encountered a case where while erasing the SPI-NAND flash, both 0x1d40000 and 0x1d60000 are properly reported as badblocks, but writing data to the flash, improper attempt of write is issued to address 0x1d75800 which is an actual broken NAND array causing write failure. This is fixed by a recently merged patch: [v2,1/2] Fix corner case in bad block table handling (Please check the attachment for details). I want to do a bit more research on the bbt cache management mechanism. I had a hard time locating the mailing series discussing the implementation.
During research, I am confused by how bbt.cache keep track of all the status of the erase blocks on a flash. Take aarch64, and a NAND flash with 128KiB erase block, 2048B page size and a total 128MB capacity as an example. We currently have 3 bits/entry in bbt, so, for all 1024 erase blocks, we'll need 3*1024 = 3072 bits to keep track of all bad block status. On aarch64, unsigned long will have 64 bits., which means we will have kind of a 48-way association for bbt.cache which is similar to actual CPU cache line associations?
My questions are the below ones:
1. Is there such line association? If so, how did we map each entry with the actual erase block?
2. Is there any documentation on the design logic of this bbt.cache?
Any insights are much appreciated, thanks!
Dinggao Pan
From patchwork Tue Apr 6 01:47:08 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yoshio Furuyama <[email protected]>
X-Patchwork-Id: 1462567
X-Patchwork-Delegate: [email protected]
Return-Path:
<linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>
X-Original-To: [email protected]
Delivered-To: [email protected]
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=<UNKNOWN>)
Authentication-Results: ozlabs.org; dkim=pass (2048-bit key;
secure) header.d=lists.infradead.org [email protected] header.a=rsa-sha256 header.s=desiato.20200630 header.b=BQye+iqF;
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 4FDr5d43Plz9sRR for <[email protected]>; Tue, 6 Apr 2021 11:48:21 +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=zXjTqIEgMhZZMHoU/iypchAlDw7H/VmXFAQqmpTY0ww=; b=BQye+iqF0Fy/+T2Gap3wczB2ES LZi3EcIfqTfPxvQbvgi5gEImeT9sn0SQlhmlsUPIqb41UueaySIxYF0T1wbnZaKF+4yi1xVUN1l4O cy3YGCP0H4tlh2vdVmfpQMNpC7QYNGtKdW4yhf3HaJdPp++CEOgirPIqMNq9cwfrB6eI3kPPU1dVL bV7SjTh9cNCdt8DmVr1Wc+bNtB7SaHNExlDzxoXpykVRgPiBTeRiJwGe/8aipnv0qKVwPpEBp7h3D kgQBpnofBg0oOGoqeYqB1UhHfzZaH3TzkywRpcrd0wPDWJEMj4s5MAS/1S1iowcUZ7Tg6TNctBsVU 6sYlpSzg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTaoR-001Bsy-Ej; Tue, 06 Apr 2021 01:47:28 +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 1lTaoM-001BsQ-IC
for [email protected]; Tue, 06 Apr 2021 01:47:24 +0000
Received: by mo-csw.securemx.jp (mx-mo-csw1114) id 1361lEZu007326;
Tue, 6 Apr 2021 10:47:15 +0900
X-Iguazu-Qid: 2wGrVoOlx8DnQbNBFY
X-Iguazu-QSIG: v=2; s=0; t=1617673634; q=2wGrVoOlx8DnQbNBFY;
m=cxnfJ9M8PQa+u2t3Lsdd5XtJDQNRyDNPmrSjk1uyn14=
Received: from imx12-a.toshiba.co.jp (imx12-a.toshiba.co.jp [61.202.160.135])
by relay.securemx.jp (mx-mr1110) id 1361lCF1023749
(version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT);
Tue, 6 Apr 2021 10:47:13 +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 B48231000A4;
Tue, 6 Apr 2021 10:47:12 +0900 (JST)
Received: from hop101.toshiba.co.jp ([133.199.85.107])
by enc02.toshiba.co.jp with ESMTP id 1361lC8k012997;
Tue, 6 Apr 2021 10:47:12 +0900
From: Yoshio Furuyama <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH v2 1/2] Fix corner case in bad block table handling.
Date: Tue, 6 Apr 2021 10:47:08 +0900
X-TSB-HOP: ON
Message-Id:
<774a92693f311e7de01e5935e720a179fb1b2468.1616635406.git.ytc-mb-yfuruyama7@kioxia.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <[email protected]>
References: <[email protected]>
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20210406_024723_281362_8D47CF4B
X-CRM114-Status: GOOD ( 13.02 )
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: From: "Doyle, Patrick" <[email protected]> In the unlikely event that both blocks 10 and 11 are marked as bad (on a 32 bit machine), then the process of marking block 10 as bad stomps on cached entry for block
11. There are (of course) other e [...]
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: [email protected]
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>
List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mtd>,
<mailto:[email protected]?subject=unsubscribe>
List-Archive: <http://lists.infradead.org/pipermail/linux-mtd/>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mtd>,
<mailto:[email protected]?subject=subscribe>
MIME-Version: 1.0
Sender: "linux-mtd" <[email protected]>
Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org
From: "Doyle, Patrick" <[email protected]>
In the unlikely event that both blocks 10 and 11 are marked as bad (on a 32 bit machine), then the process of marking block 10 as bad stomps on cached entry for block 11. There are (of course) other examples.
--- drivers/mtd/nand/bbt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/bbt.c +1 -1
@@ -123,7 +123,7 @@ int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry,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_block - rbits); }return 0 ;
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/