From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1583AC433ED for ; Tue, 11 May 2021 02:17:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E538C616E8 for ; Tue, 11 May 2021 02:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229995AbhEKCSo (ORCPT ); Mon, 10 May 2021 22:18:44 -0400 Received: from twhmllg3.macronix.com ([211.75.127.131]:47984 "EHLO TWHMLLG3.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230455AbhEKCSg (ORCPT ); Mon, 10 May 2021 22:18:36 -0400 Received: from TWHMLLG3.macronix.com (localhost [127.0.0.2] (may be forged)) by TWHMLLG3.macronix.com with ESMTP id 14B1fatk037045 for ; Tue, 11 May 2021 09:41:36 +0800 (GMT-8) (envelope-from ycllin@mxic.com.tw) Received: from localhost.localdomain ([172.17.195.95]) by TWHMLLG3.macronix.com with ESMTP id 14B1esOa036551; 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 2/2] mtd: nand: ecc-hamming: Fix the double counting of ECC stat Date: Tue, 11 May 2021 09:40:35 +0800 Message-Id: <1620697235-7829-3-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 14B1esOa036551 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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-hamming.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-hamming.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/ecc-sw-hamming.c b/drivers/mtd/nand/ecc-sw-hamming.c index a7655b6..e8a30cf 100644 --- a/drivers/mtd/nand/ecc-sw-hamming.c +++ b/drivers/mtd/nand/ecc-sw-hamming.c @@ -625,11 +625,12 @@ static int nand_ecc_sw_hamming_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); -- 1.9.1