From patchwork Tue Apr 19 11:22:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 8878901 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CC9419F1D3 for ; Tue, 19 Apr 2016 11:22:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDAD42027D for ; Tue, 19 Apr 2016 11:22:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A99082026D for ; Tue, 19 Apr 2016 11:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752929AbcDSLWS (ORCPT ); Tue, 19 Apr 2016 07:22:18 -0400 Received: from down.free-electrons.com ([37.187.137.238]:46817 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752113AbcDSLWQ (ORCPT ); Tue, 19 Apr 2016 07:22:16 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 4A80C22B; Tue, 19 Apr 2016 13:22:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bbrezillon (LMontsouris-657-1-184-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 45D9C8A; Tue, 19 Apr 2016 13:22:07 +0200 (CEST) Date: Tue, 19 Apr 2016 13:22:06 +0200 From: Boris Brezillon To: Roger Quadros Cc: David Woodhouse , Brian Norris , , Richard Weinberger , , Krzysztof Kozlowski , Harvey Hunt , Nicolas Ferre , Stefan Agner , , Alexandre Belloni , punnaiah choudary kalluri , Robert Jarzmik , , Archit Taneja , , Kamal Dasu , Josh Wu , Chen-Yu Tsai , Kukjin Kim , , Ezequiel Garcia , Huang Shijie , Jean-Christophe Plagniol-Villard , Haojian Zhuang , Han Xu , , Priit Laes , Greg Kroah-Hartman , , Ralf Baechle , Wenyou Yang , Kyungmin Park , , Maxime Ripard , Daniel Mack Subject: Re: [PATCH v5 39/50] mtd: nand: omap2: switch to mtd_ooblayout_ops Message-ID: <20160419132206.5d909f7e@bbrezillon> In-Reply-To: <57160862.90603@ti.com> References: <1459354505-32551-1-git-send-email-boris.brezillon@free-electrons.com> <1459354505-32551-40-git-send-email-boris.brezillon@free-electrons.com> <5714F011.5080409@ti.com> <20160418170518.363f732d@bbrezillon> <57160862.90603@ti.com> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Roger, On Tue, 19 Apr 2016 13:28:50 +0300 Roger Quadros wrote: > > @@ -1921,6 +1927,9 @@ static int omap_nand_probe(struct platform_device *pdev) > > nand_chip->ecc.correct = omap_correct_data; > > mtd_set_ooblayout(mtd, &omap_ooblayout_ops); > > oobbytes_per_step = nand_chip->ecc.bytes; > > + > > + if (nand_chip->options & NAND_BUSWIDTH_16) > > + min_oobbytes = 1; > > Shouldn't this have been > if (!(nand_chip->options & NAND_BUSWIDTH_16) > min_oobbytes = 1; > ? Yep. > > > break; > > > > case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW: > > @@ -2038,10 +2047,8 @@ static int omap_nand_probe(struct platform_device *pdev) > > } > > > > /* check if NAND device's OOB is enough to store ECC signatures */ > > - min_oobbytes = (oobbytes_per_step * > > - (mtd->writesize / nand_chip->ecc.size)) + > > - (nand_chip->options & NAND_BUSWIDTH_16 ? > > - BADBLOCK_MARKER_LENGTH : 1); > > + min_oobbytes += (oobbytes_per_step * > > + (mtd->writesize / nand_chip->ecc.size)); > > if (mtd->oobsize < min_oobbytes) { > > dev_err(&info->pdev->dev, > > "not enough OOB bytes required = %d, available=%d\n", > > > > After the above changes BCH with HW ECC worked fine but BCH with SW ECC still failed. > I had to fix it up with the below patch. This is mainly because chip->ecc.steps wasn't > yet initialized before calling nand_bch_init(). > > After the below patch it worked fine with bch4 (hw & sw), bch8 (hw & sw) and ham1. > I couldn't yet verify bch16 though. Thanks for the fix, but I'd prefer fixing the bug for all soft BCH users. Could you try this patch? --->8--- --- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mtd/nand/nand_bch.c b/drivers/mtd/nand/nand_bch.c index ca9b2a4..3ca3d39 100644 --- a/drivers/mtd/nand/nand_bch.c +++ b/drivers/mtd/nand/nand_bch.c @@ -177,6 +177,16 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) goto fail; } + /* + * ecc->steps and ecc->total might be used by mtd->ooblayout->ecc(), + * which is called by mtd_ooblayout_count_eccbytes(). + * Make sure they are properly initialized before calling + * mtd_ooblayout_count_eccbytes(). + * FIXME: we should probaly rework the sequencing in nand_scan_tail() + * to avoid setting those fields twice. + */ + nand->ecc.steps = eccsteps; + nand->ecc.total = eccsteps * eccbytes; if (mtd_ooblayout_count_eccbytes(mtd) != (eccsteps*eccbytes)) { printk(KERN_WARNING "invalid ecc layout\n"); goto fail;