From patchwork Wed Jan 18 04:13:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar Kushwaha X-Patchwork-Id: 136548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CD69DB6EFF for ; Wed, 18 Jan 2012 15:15:15 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RnMtp-0007Bs-Nf; Wed, 18 Jan 2012 04:13:25 +0000 Received: from tx2ehsobe002.messaging.microsoft.com ([65.55.88.12] helo=TX2EHSOBE004.bigfish.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RnMtn-0007BH-GV for linux-mtd@lists.infradead.org; Wed, 18 Jan 2012 04:13:24 +0000 Received: from mail184-tx2-R.bigfish.com (10.9.14.235) by TX2EHSOBE004.bigfish.com (10.9.40.24) with Microsoft SMTP Server id 14.1.225.23; Wed, 18 Jan 2012 04:13:14 +0000 Received: from mail184-tx2 (localhost [127.0.0.1]) by mail184-tx2-R.bigfish.com (Postfix) with ESMTP id F40BD4802B5; Wed, 18 Jan 2012 04:13:15 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bh8275dhz2dhc1ahc1bh2a8h668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail184-tx2 (localhost.localdomain [127.0.0.1]) by mail184-tx2 (MessageSwitch) id 1326859995774024_6193; Wed, 18 Jan 2012 04:13:15 +0000 (UTC) Received: from TX2EHSMHS035.bigfish.com (unknown [10.9.14.244]) by mail184-tx2.bigfish.com (Postfix) with ESMTP id B397D640090; Wed, 18 Jan 2012 04:13:15 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS035.bigfish.com (10.9.99.135) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 18 Jan 2012 04:13:13 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.355.3; Tue, 17 Jan 2012 22:13:19 -0600 Received: from b32579-VirtualBox.ap.freescale.net (b32579-VirtualBox-010232132074.ap.freescale.net [10.232.132.74]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id q0I4DFSc019426; Tue, 17 Jan 2012 22:13:16 -0600 (CST) From: Prabhakar Kushwaha To: , Subject: [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command Date: Wed, 18 Jan 2012 09:43:11 +0530 Message-ID: <1326859991-7469-1-git-send-email-prabhakar@freescale.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [65.55.88.12 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 SUBJ_OBFU_PUNCT_FEW Possible punctuation-obfuscated Subject: header 1.7 SUBJ_OBFU_PUNCT_MANY Punctuation-obfuscated Subject: header Cc: Scott Wood , Poonam Aggrwal , Prabhakar Kushwaha X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Freescale IFC NAND Machine calculates ECC on 512byte sector and same is used in fsl_ifc_run_command() during ECC status verification. Also this sector is passed to is_blank() for blank checking. It is wrong at first place because is_blank()'s implementation checks for Page size and OOB area size. is_blank() should be called per page for main and OOB area verification. Variables name are redefined to avoid confusion between buffer and ecc sector. Signed-off-by: Poonam Aggrwal Signed-off-by: Scott Wood Signed-off-by: Prabhakar Kushwaha --- git://git.kernel.org/pub/scm/linux/kernel/git/galak/powerpc.git (branch next) Tested on P1010RDB This patch is created on top of IFC driver patch (already floated in mailing list). Please find their link: http://patchwork.ozlabs.org/patch/133315/ http://patchwork.ozlabs.org/patch/133316/ This patch is replacement of my earlier patch "mtd/nand:Fix wrong address read in is_blank()" drivers/mtd/nand/fsl_ifc_nand.c | 52 +++++++++++++++++++++------------------ 1 files changed, 28 insertions(+), 24 deletions(-) diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index 854fe95..33b55d2 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -1,7 +1,7 @@ /* * Freescale Integrated Flash Controller NAND driver * - * Copyright 2011 Freescale Semiconductor, Inc + * Copyright 2011,2012 Freescale Semiconductor, Inc * * Author: Dipen Dudhat * @@ -216,24 +216,11 @@ static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl, u32 *eccstat, unsigned int bufnum) { u32 reg = eccstat[bufnum / 4]; - int errors = (reg >> ((3 - bufnum % 4) * 8)) & 15; + int errors; - if (errors == 15) { /* uncorrectable */ - /* Blank pages fail hw ECC checks */ - if (is_blank(mtd, bufnum)) - return 1; + errors = (reg >> ((3 - bufnum % 4) * 8)) & 15; - /* - * We disable ECCER reporting in hardware due to - * erratum IFC-A002770 -- so report it now if we - * see an uncorrectable error in ECCSTAT. - */ - ctrl->nand_stat |= IFC_NAND_EVTER_STAT_ECCER; - } else if (errors > 0) { - mtd->ecc_stats.corrected += errors; - } - - return 0; + return errors; } /* @@ -273,16 +260,33 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) dev_err(priv->dev, "NAND Flash Write Protect Error\n"); if (nctrl->eccread) { - int bufperpage = mtd->writesize / 512; - int bufnum = (nctrl->page & priv->bufnum_mask) * bufperpage; - int bufnum_end = bufnum + bufperpage - 1; + int errors; + int bufnum = nctrl->page & priv->bufnum_mask; + int sector = bufnum * chip->ecc.steps; + int sector_end = sector + chip->ecc.steps - 1; - for (i = bufnum / 4; i <= bufnum_end / 4; i++) + for (i = sector / 4; i <= sector_end / 4; i++) eccstat[i] = in_be32(&ifc->ifc_nand.nand_eccstat[i]); - for (i = bufnum; i <= bufnum_end; i++) { - if (check_read_ecc(mtd, ctrl, eccstat, i)) + for (i = sector; i <= sector_end; i++) { + errors = check_read_ecc(mtd, ctrl, eccstat, i); + + if (errors == 15) { + /* + * Uncorrectable error. + * OK only if the whole page is blank. + * + * We disable ECCER reporting due to... + * erratum IFC-A002770 -- so report it now if we + * see an uncorrectable error in ECCSTAT. + */ + if (!is_blank(mtd, bufnum)) + ctrl->nand_stat |= + IFC_NAND_EVTER_STAT_ECCER; break; + } + + mtd->ecc_stats.corrected += errors; } nctrl->eccread = 0;