From patchwork Mon Dec 30 12:40:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 305775 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B3B072C00D3 for ; Mon, 30 Dec 2013 23:41:54 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VxcA7-0002tI-B8; Mon, 30 Dec 2013 12:41:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VxcA5-0006KN-Mi; Mon, 30 Dec 2013 12:41:37 +0000 Received: from mo6-p05-ob.smtp.rzone.de ([2a01:238:20a:202:5305::8]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VxcA2-0006Jp-3S for linux-mtd@lists.infradead.org; Mon, 30 Dec 2013 12:41:36 +0000 X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohdvpEkce+Ub40Q/uAFj+9EbzcWT+D2e8= X-RZG-CLASS-ID: mo05 Received: from ubuntu-2012.fritz.box (pD9FF8D0A.dip0.t-ipconnect.de [217.255.141.10]) by smtp.strato.de (RZmta 32.17 DYNA|AUTH) with ESMTPA id 2006b8pBUCf0207 ; Mon, 30 Dec 2013 13:41:00 +0100 (CET) From: Stefan Roese To: linux-mtd@lists.infradead.org Subject: [RFC/PATCH] mtd: mtd_read: Fix bitflips_threshold comparison to allow max bitflips Date: Mon, 30 Dec 2013 13:40:57 +0100 Message-Id: <1388407257-6557-1-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.8.5.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131230_074134_403626_756B261E X-CRM114-Status: GOOD ( 12.59 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Brian Norris , Pekon Gupta X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 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 On a custom AM335x based platform with a Toshiba NAND device (TC58NVG1S3H) we are currently seeing quite a few of these UBI messages: [ 18.044967] UBI: fixable bit-flip detected at PEB 50 [ 18.050252] UBI: schedule PEB 50 for scrubbing ... After a bit debugging I found that those messages are only printed when the OMAP NAND driver has detected 8 (corrected) bitflips / 512 bytes on a read. We're using HW BCH8 and the Toshiba chip supports 8 bit ECC for each 512Byte. I was wondering why 8 bitflips resulted in these UBI messages and e.g. 7 bitflips didn't. Hence I discovered the comparison "ret_code >= mtd->bitflip_threshold" in mtd_read(). With this patch applied all tests (UBIFS) I've done so far didn't produce any of these "UBI: fixable bit-flip" messages any more. Note that I'm sending this patch as RFC for now. To get some feedback from other MTD / NAND developers on this issue. The main question is: Should mtd_read() return -EUCLEAN if the corrected bitflips are equal to the bitflip-threshold value? Or should it return 0 since the bitflips have been corrected? Signed-off-by: Stefan Roese Cc: Brian Norris Cc: Pekon Gupta --- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 92311a5..28500a1 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -824,7 +824,7 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, return ret_code; if (mtd->ecc_strength == 0) return 0; /* device lacks ecc */ - return ret_code >= mtd->bitflip_threshold ? -EUCLEAN : 0; + return ret_code > mtd->bitflip_threshold ? -EUCLEAN : 0; } EXPORT_SYMBOL_GPL(mtd_read);