From patchwork Tue May 11 01:40:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YouChing Lin X-Patchwork-Id: 1477083 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=AoJpGZqX; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=z78sint2; 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 4FfZtz0847z9sVt for ; Tue, 11 May 2021 21:09:31 +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=xsHloYUvukVTGWY3PIs167QNwYyIocizUVfLeNBKc6U=; b=AoJpGZqX+lKPbw/MBk6VIJw4ns RY+9iLHoOeVowXwAmc9ebnnc9+JGDcz9ZZTiY99E4C17XEOKP9Q2oExkcgnETGVBRKUm7iUF+tWz0 aXc7bKbe70FiElXYx3tKfI9Rumwjra2bgHijzzSCdQnhWeaaZEAUVblbrRwPe8L51towzgYAwOQ0g 2lEPMnzjYsIBbs9cHpGsl3jzKd2YFCDogeBS1JxrPA2DMTQsVyuY8QrayB6PFPv8O+hEZohe9OXDt /Nd0daklptdzBGyqfIF8LrQ5L3Fzn+HUjfUm2HXb5U75buVA7S/MTzuouo4VwC8MQ1+D1B3EbJE5Z dpfAD6ww==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgQFA-00H4cJ-QX; Tue, 11 May 2021 11:08:04 +0000 Received: from [2607:7c80:54:e::133] (helo=bombadil.infradead.org) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgHOd-00G3ZJ-SO for linux-mtd@desiato.infradead.org; Tue, 11 May 2021 01:41:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kdcyc97ehzsx1qGVMsxL+g/Aq4a2oX+1MyVVJC81qrM=; b=z78sint2MJeCPa3hjlvWRWJPOw WxlNUJPS7N974+FsLRO16CqEKkC525pU8UUiXFAsQt/6UKrGimjXQBTHhIB7JxwDGlIyXJosG7neu SKNSjYm2B9Yf3Y+MNrjF5NlCOqyuTxT8iPcFExNq102C1afuLDp9sKg4V9pBVzsGydW2jqIppVcpU QyrVjUJCjEQeaO5iWLe/nFIfwsm42XDW61jJjhuaQQGbY82M5VAZpprf+Q1t7RI+ac3qvJquBIqm2 ncZkODEusJNXilzlLWN5eSqVUR4EbtTtrlmsF1yLfiPOvuQ06dMe6K81E6SDaBcY7IFhTidovprAs wCuYscUQ==; Received: from twhmllg3.macronix.com ([211.75.127.131]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgHOY-009F88-4e for linux-mtd@lists.infradead.org; Tue, 11 May 2021 01:41:11 +0000 Received: from localhost.localdomain ([172.17.195.95]) by TWHMLLG3.macronix.com with ESMTP id 14B1esOZ036551; Tue, 11 May 2021 09:40:54 +0800 (GMT-8) (envelope-from ycllin@mxic.com.tw) From: YouChing Lin To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, juliensu@mxic.com.tw, YouChing Lin Subject: [PATCH 1/2] mtd: nand: ecc-bch: Fix the double counting of ECC stat Date: Tue, 11 May 2021 09:40:34 +0800 Message-Id: <1620697235-7829-2-git-send-email-ycllin@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1620697235-7829-1-git-send-email-ycllin@mxic.com.tw> References: <1620697235-7829-1-git-send-email-ycllin@mxic.com.tw> X-MAIL: TWHMLLG3.macronix.com 14B1esOZ036551 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_184110_446820_ED5715D3 X-CRM114-Status: UNSURE ( 8.73 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.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: If you use SPI-NAND with SW-ECC engine, the ECC related statistics (ecc_stats.failed & ecc_stats.corrected) will be doubled, because those numbers will be double-counted in ecc-sw-bch.c and drivers/mt [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [211.75.127.131 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_184110_446820_ED5715D3 X-CRM114-Status: UNSURE ( 4.18 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.1 (/) 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: If you use SPI-NAND with SW-ECC engine, the ECC related statistics (ecc_stats.failed & ecc_stats.corrected) will be doubled, because those numbers will be double-counted in ecc-sw-bch.c and drivers/mt [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2607:7c80:54:e:0:0:0:133 listed in] [list.dnswl.org] 0.0 T_SPF_HELO_TEMPERROR SPF: test of HELO record failed (temperror) 0.9 SPF_FAIL SPF: sender does not match SPF record (fail) [SPF failed: Please see http://www.openspf.org/Why?s=mfrom; id=ycllin%40mxic.com.tw; ip=2607%3A7c80%3A54%3Ae%3A%3A133; r=desiato.infradead.org] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS 0.1 DKIM_INVALID DKIM or DK signature exists, but is not valid 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 If you use SPI-NAND with SW-ECC engine, the ECC related statistics (ecc_stats.failed & ecc_stats.corrected) will be doubled, because those numbers will be double-counted in ecc-sw-bch.c and drivers/mtd/nand/spi/core.c. This can be found by using nandtest/nandbiterrs validation. Signed-off-by: YouChing Lin --- drivers/mtd/nand/ecc-sw-bch.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/ecc-sw-bch.c b/drivers/mtd/nand/ecc-sw-bch.c index 405552d..aade381 100644 --- a/drivers/mtd/nand/ecc-sw-bch.c +++ b/drivers/mtd/nand/ecc-sw-bch.c @@ -372,11 +372,12 @@ static int nand_ecc_sw_bch_finish_io_req(struct nand_device *nand, &ecccode[i], &ecccalc[i]); if (stat < 0) { - mtd->ecc_stats.failed++; - } else { - mtd->ecc_stats.corrected += stat; - max_bitflips = max_t(unsigned int, max_bitflips, stat); + nand_ecc_restore_req(&engine_conf->req_ctx, req); + + return -EBADMSG; } + + max_bitflips = max_t(unsigned int, max_bitflips, stat); } nand_ecc_restore_req(&engine_conf->req_ctx, req);