Received: by 10.192.165.148 with SMTP id m20csp3978994imm; Tue, 8 May 2018 00:22:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrSwa8SWJR8LIC6K6hr74KmmLTNdYBq7RFZ8FUySDpY/8czPM01wumo6fDGJWviEGZLlpWp X-Received: by 2002:a63:b94a:: with SMTP id v10-v6mr31953243pgo.372.1525764166567; Tue, 08 May 2018 00:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525764166; cv=none; d=google.com; s=arc-20160816; b=Eow64IKKZcLfvB9S5t04YlOOfWTOrDRbuQ4Q11AnhLuFbZR6rj990JI+lIq1sD5iHR T1WS541qWg3T9L2sVFhy0uQUJDsxQCo9voyOD87+QTByhhM0ORoHKXe84LH80XUnAKTc 0AanTvcQ3+q4a45cxsqh1q05XbjyH2o5Ntzb3imFjrk/y6jhcs9ZfkeAt2+/94ZgDXYJ rzraePAnu6WHcmkvD2ZUChXkyWGoyhv+XMFYwj3b+tLDtSD5aFzRIS6zgN3B3aVI998a asEbByaTMT5RE7RVnqBVL4qOXwXpK1VGf4Q0XokTdVonyZkhnVniRIl7dESGMG+XXltt 8xpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=sP5pq3S0+nPoEGnCrl2yphpwE6ffTwL8qxAplQvjYIE=; b=Y2OqMVaIskucWu8vwMnjc/xxETRxfUmuf92nZkoeS41cN05yunIzSlj4u+/m5S2XJD VLRDIVkW7Lr8Cxa9kIpoJhz6NhaMLT4VQSzzRyXGj+Z9m8EgkDIUu8t7Q+JOyCgHzP80 jh6lWZqCL8aoMtYjr/LDv9a0+JhIB9Hww1G34FPSBPJx6LIeDh0coB7GYLhRKOgGcn6q W5vT0JERdUU0Tu72BiFIE4Ur5H7gTPDCwnqDAm7au3OnVsiIc6Omaz7pkz3clFgbiycp 1xhkZ+c1FwE1A5Shg/9Cil2LSfvjC5Dw9SnefKvFlUHckigcHZyQbGIUcyhX4/OlvzpF LB1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=X/1wGcem; dkim=pass header.i=@codeaurora.org header.s=default header.b=ALhzvOm7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9-v6si19345085pgr.342.2018.05.08.00.22.31; Tue, 08 May 2018 00:22:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=X/1wGcem; dkim=pass header.i=@codeaurora.org header.s=default header.b=ALhzvOm7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754636AbeEHHVM (ORCPT + 99 others); Tue, 8 May 2018 03:21:12 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:60664 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754154AbeEHHVJ (ORCPT ); Tue, 8 May 2018 03:21:09 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9D8F3601A8; Tue, 8 May 2018 07:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525764068; bh=I9Xam4GPry0CZfIQefcXThWrfhSIhjbVKcVI1+LWyog=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=X/1wGcemHwNEa6dWnU2+0EXvR85GvOhr425S1xBWoQsYwqRmsY7GLmpj4VxwIvbHp GVWOI3iDLT07dVUejEVBwB/H54+G4gjmQwbq37xb9PncW+kPGar6AEY9W8qtXrvN2M SCNrfOojEFDJ6axAMAm39cFOFm6iRAlNQ12+VnzM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 0EE2B601A8; Tue, 8 May 2018 07:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525764067; bh=I9Xam4GPry0CZfIQefcXThWrfhSIhjbVKcVI1+LWyog=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ALhzvOm7MhhZPKlBB7TmMoApb3nQ1xQPMt+eEM+i+0PKZP3QV714wkzw61TRRTDle 4h7SUe7AaJCkSRmrxMO6o8jW6/HSyq7FICIfwP8rvRE3iNEehB+KPUjkHFyjIQm1Ob bo2eNQNJGCttN5ovoyNbGvSXrvxgKJb24IlZjPUc= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 08 May 2018 12:51:07 +0530 From: Abhishek Sahu To: Masahiro Yamada Cc: Boris Brezillon , Archit Taneja , Richard Weinberger , linux-arm-msm , Linux Kernel Mailing List , Marek Vasut , linux-mtd , Miquel Raynal , Andy Gross , Brian Norris , David Woodhouse Subject: Re: [PATCH v2 01/14] mtd: rawnand: helper function for setting up ECC parameters In-Reply-To: References: <1525350041-22995-1-git-send-email-absahu@codeaurora.org> <1525350041-22995-2-git-send-email-absahu@codeaurora.org> <20180507093933.393964b7@bbrezillon> Message-ID: <70c4cc5396a4e62a3422298478f33329@codeaurora.org> X-Sender: absahu@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-08 11:44, Masahiro Yamada wrote: > 2018-05-07 16:39 GMT+09:00 Boris Brezillon > : >> On Mon, 7 May 2018 12:40:39 +0900 >> Masahiro Yamada wrote: >> >>> 2018-05-03 21:20 GMT+09:00 Abhishek Sahu : >>> > commit 2c8f8afa7f92 ("mtd: nand: add generic helpers to check, >>> > match, maximize ECC settings") provides generic helpers which >>> > drivers can use for setting up ECC parameters. >>> > >>> > Since same board can have different ECC strength nand chips so >>> > following is the logic for setting up ECC strength and ECC step >>> > size, which can be used by most of the drivers. >>> > >>> > 1. If both ECC step size and ECC strength are already set >>> > (usually by DT) then just check whether this setting >>> > is supported by NAND controller. >>> > 2. If NAND_ECC_MAXIMIZE is set, then select maximum ECC strength >>> > supported by NAND controller. >>> > 3. Otherwise, try to match the ECC step size and ECC strength closest >>> > to the chip's requirement. If available OOB size can't fit the chip >>> > requirement then select maximum ECC strength which can be fit with >>> > available OOB size with warning. >>> > >>> > This patch introduces nand_ecc_param_setup function which calls the >>> > required helper functions for the above logic. The drivers can use >>> > this single function instead of calling the 3 helper functions >>> > individually. >>> > >>> > CC: Masahiro Yamada >>> > Signed-off-by: Abhishek Sahu >>> > --- >>> > * Changes from v1: >>> > >>> > NEW PATCH >>> > >>> > drivers/mtd/nand/raw/nand_base.c | 42 ++++++++++++++++++++++++++++++++++++++++ >>> > include/linux/mtd/rawnand.h | 3 +++ >>> > 2 files changed, 45 insertions(+) >>> > >>> > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c >>> > index 72f3a89..dd7a984 100644 >>> > --- a/drivers/mtd/nand/raw/nand_base.c >>> > +++ b/drivers/mtd/nand/raw/nand_base.c >>> > @@ -6249,6 +6249,48 @@ int nand_maximize_ecc(struct nand_chip *chip, >>> > } >>> > EXPORT_SYMBOL_GPL(nand_maximize_ecc); >>> > >>> > +/** >>> > + * nand_ecc_param_setup - Set the ECC strength and ECC step size >>> > + * @chip: nand chip info structure >>> > + * @caps: ECC engine caps info structure >>> > + * @oobavail: OOB size that the ECC engine can use >>> > + * >>> > + * Choose the ECC strength according to following logic >>> > + * >>> > + * 1. If both ECC step size and ECC strength are already set (usually by DT) >>> > + * then check if it is supported by this controller. >>> > + * 2. If NAND_ECC_MAXIMIZE is set, then select maximum ECC strength. >>> > + * 3. Otherwise, try to match the ECC step size and ECC strength closest >>> > + * to the chip's requirement. If available OOB size can't fit the chip >>> > + * requirement then fallback to the maximum ECC step size and ECC strength >>> > + * and print the warning. >>> > + * >>> > + * On success, the chosen ECC settings are set. >>> > + */ >>> > +int nand_ecc_param_setup(struct nand_chip *chip, >>> > + const struct nand_ecc_caps *caps, int oobavail) >>> > +{ >>> > + int ret; >>> > + >>> > + if (chip->ecc.size && chip->ecc.strength) >>> > + return nand_check_ecc_caps(chip, caps, oobavail); >>> > + >>> > + if (chip->ecc.options & NAND_ECC_MAXIMIZE) >>> > + return nand_maximize_ecc(chip, caps, oobavail); >>> > + >>> > + if (!nand_match_ecc_req(chip, caps, oobavail)) >>> > + return 0; >>> > + >>> > + ret = nand_maximize_ecc(chip, caps, oobavail); >>> >>> >>> Why two calls for nand_maximize_ecc()? >> >> As long as the code does the same thing, I don't care that much. >> >>> >>> My code is simpler, >> >> and I don't see how your code is simpler. Mainly a matter of taste >> AFAICS. >> >>> and does not display >>> false-positive warning. >> >> I agree on the false-positive warning though, this should be avoided. >> >>> >>> >>> > + if (!ret) >>> > + pr_warn("ECC (step, strength) = (%d, %d) not supported on this controller. Fallback to (%d, %d)\n", >>> > + chip->ecc_step_ds, chip->ecc_strength_ds, >>> > + chip->ecc.size, chip->ecc.strength); >>> >>> >>> This is annoying. >>> >>> {ecc_step_ds, ecc_strength_ds} are not provided by Non-ONFi devices. >>> >>> So, >>> ECC (step, strength) = (0, 0) not supported on this controller. >> >> Well, if you have a chip that requires ECC but exposes 0bits/0bytes >> then this should be fixed. 0,0 should only be valid when the chip does >> not require ECC at all (so, only really old chips). For all other >> chips, >> including non-ONFI ones, we should have a valid value here. > > > Sorry, it was my misunderstanding. > > My NAND chip is Toshiba. > > If I remember correctly, Toshiba chips were not set > with ECC requirements in the past, > but as far as I tested the latest kernel now, > the ECC requirement was set by > drivers/mtd/nand/raw/nand_toshiba.c > > > > > >>> >>> will be always displayed. >>> >>> >>> The strength will be checked by nand_ecc_strength_good() anyway. >> >> True. So, I agree that the pr_warn() is unneeded, but I still think we >> should fix all cases where ECC reqs are missing, so if you have such a >> setup, please add some code to nand_.c to initialize >> ->ecc_xxx_ds properly. >> > > If we decide to not display pr_warn(), > I think the code like denali_ecc_setup() should work, and simple. Thanks Boris and Masahiro. I will remove this print and then we can use code like denali_ecc_setup. Regards, Abhishek