Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761371Ab2FHPjS (ORCPT ); Fri, 8 Jun 2012 11:39:18 -0400 Received: from [194.90.113.100] ([194.90.113.100]:35236 "EHLO mx1.jungo.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1761278Ab2FHPjQ (ORCPT ); Fri, 8 Jun 2012 11:39:16 -0400 X-Greylist: delayed 571 seconds by postgrey-1.27 at vger.kernel.org; Fri, 08 Jun 2012 11:39:15 EDT Date: Fri, 8 Jun 2012 18:29:06 +0300 From: Shmulik Ladkani To: David Woodhouse , Artem Bityutskiy Cc: linux-mtd@lists.infradead.org, Mike Dunn , linux-kernel@vger.kernel.org, Sascha Hauer , Ivan Djelic Subject: [PATCH] mtd: nand: Properly initialize 'mtd->bitflip_threshold' prior 'scan_bbt()' is invoked Message-ID: <20120608182906.57b4844a@halley> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.6; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 120227-0, 02/27/2012), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2072 Lines: 50 As of edbc454 [mtd: driver _read() returns max_bitflips; mtd_read() returns -EUCLEAN], 'mtd->bitflip_threshold' must be set for mtd devices having ECC, prior any 'mtd_read()' call. Otherwise, 'mtd_read()' will falsely return -EUCLEAN. Normally, 'mtd->bitflip_threshold' is initialized when the MTD is added. However, this is too late for NAND MTDs, as 'scan_bbt()' is invoked prior the existing initialization of 'mtd->bitflip_threshold'. This is a problem since 'scan_bbt()' calls 'mtd_read()', in the case of a flash-based bad block table. It resulted in a falsely reported bitflips indication during BBT read, which lead to constant scrubbing of the flash BBT blocks. Initialize 'mtd->bitflip_threshold' to its default value (if not already set by the driver), prior invocation of 'scan_bbt()'. Reported-by: Sascha Hauer Signed-off-by: Shmulik Ladkani --- - The issue was introduced in 3.5-rc1 and needs to be merged before 3.5 - Sascha, I've credited you as the reporter, is that ok? - Sascha, care to test and verify it works for your system? diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 61805e7..0a8724e 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3484,6 +3484,13 @@ int nand_scan_tail(struct mtd_info *mtd) /* propagate ecc info to mtd_info */ mtd->ecclayout = chip->ecc.layout; mtd->ecc_strength = chip->ecc.strength; + /* + * Initialize bitflip_threshold to its default prior scan_bbt() call. + * scan_bbt() might invoke mtd_read(), thus bitflip_threshold must be + * properly set. + */ + if (!mtd->bitflip_threshold) + mtd->bitflip_threshold = mtd->ecc_strength; /* Check, if we should skip the bad block table scan */ if (chip->options & NAND_SKIP_BBTSCAN) -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/