Received: by 10.213.65.68 with SMTP id h4csp3498606imn; Mon, 9 Apr 2018 23:13:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+AqarLdqiOP359SqLjKGuJz1nzbPuTMkS64uG4xI6WXTB6FNw6Uzg3AlOGLH38YN4MBykr X-Received: by 2002:a17:902:6a81:: with SMTP id n1-v6mr41564606plk.342.1523340823100; Mon, 09 Apr 2018 23:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523340823; cv=none; d=google.com; s=arc-20160816; b=M32NVcBQwJrAqzewYCfkFiSZ8yRhGB/nFuBhLc4oFPlTv6kzHmyO53uGYBHYcc9Eed rIGZJ1+3chb/2q/BmxD8zXN1rhSHyKMj/DAHf6k5c9mM6uTgEsi/FJ5TWjGBpp4YjDJm Cn4+NFijnITeFkaOcYzbjbhv28FE6WqtrT2D/NEEXKmojHKPN3d3uvHBJ4jKNPqaE7JQ QvyVB3CtIKO8kL9mBsajhGts0XW2JmYMDWh744nEQhatHZUbpmxz8n/E2cfVk8H4cYeG icW8jr42kaY17hoLsn3pVbJEQvl9aD5PdMQDBlTFD4A2WlEBbO53qHbnb/lpvK/Fzq9Q Eyhw== 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=rDF3TtVnR0Aw3xJ0sury2henSQrlumdd4hz1lPjLOmg=; b=NE+OdGjHOb6hNC6nBOuKU578ozqWAkw0z4Zepow7wkDpAmv++zHkUVU8pbsxE/xYc1 PrDxswZ8HPwzlS8ImDJPJkrlpKIE1laMov/o/ZYiU0RW4RDkfTGxgGPGfICfQe+O2K2P zzICJp2xr7R34i9/dMKEbSlJUgqY6ZC26Ju6DbnAM7Wt3yxZuVih6RWyvvues2l/2h9/ RYLdPKi2VPQ2ABMOHAXudhHt1FCInscxE/vQ2ZhQZ/fZej0wrisSq+yYSKpQyP/s7C6g Mgfw1hnQdtY63XdmFSSVhHTUc3JUTa4/chVMNrwaypfUARVF1w13X9WCnm0PSXT3Zusl zeXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GZCFFGDE; dkim=pass header.i=@codeaurora.org header.s=default header.b=nrc3DVZQ; 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 g8-v6si1886498plt.254.2018.04.09.23.12.55; Mon, 09 Apr 2018 23:13:43 -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=GZCFFGDE; dkim=pass header.i=@codeaurora.org header.s=default header.b=nrc3DVZQ; 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 S1751856AbeDJGJj (ORCPT + 99 others); Tue, 10 Apr 2018 02:09:39 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49262 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751490AbeDJGJi (ORCPT ); Tue, 10 Apr 2018 02:09:38 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9B54A60F6C; Tue, 10 Apr 2018 06:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523340577; bh=R5xAPb4yynu0U+tyxM0M+9IVFdP5L3661GEpVsAMQ4c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GZCFFGDE4xQFHzMMhSRUcjiC1QXvMURS7kbcfsQV1Dh6EhZ7ojbhkVnLsxM0qWVFz JihkKmQUTxXTOkR7tSAgEGv9idHFqF+0cIkHdJtd65J+JsZPdDXk15CiFnIsahsOI3 d5tKgTSQH99OsHBBuXFDcY8RyJ1nWCU8anneFK34= 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 BE0B360AE0; Tue, 10 Apr 2018 06:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523340575; bh=R5xAPb4yynu0U+tyxM0M+9IVFdP5L3661GEpVsAMQ4c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nrc3DVZQp8He1/LimZmmsp1Xl3rFv2oxrtVwSHmKzIoSAjKRiip119CDG+4UxiatP CbGymQd4sV95cu3Ham2jxF7kVbZy823wFpeJdN+E9pm4LrcB7/TUSikshKjzu29su1 Kpr+kM9u2QtNyV7tuu4ELn6Hb28JKQ5Uj1rULfoE= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 10 Apr 2018 11:39:35 +0530 From: Abhishek Sahu To: Miquel Raynal Cc: Boris Brezillon , Archit Taneja , Richard Weinberger , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Cyrille Pitchen , Andy Gross , Brian Norris , David Woodhouse Subject: Re: [PATCH 1/9] mtd: nand: qcom: use the ecc strength from device parameter In-Reply-To: <20180406143133.67f33d33@xps13> References: <1522845745-6624-1-git-send-email-absahu@codeaurora.org> <1522845745-6624-2-git-send-email-absahu@codeaurora.org> <20180406143133.67f33d33@xps13> Message-ID: <23c8330d00d4d9b62c4c1ab597cbb22b@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-04-06 18:01, Miquel Raynal wrote: > Hi Abhishek, > > On Wed, 4 Apr 2018 18:12:17 +0530, Abhishek Sahu > wrote: > >> Currently the driver uses the ECC strength specified in >> device tree. The ONFI or JEDEC device parameter page >> contains the ‘ECC correctability’ field which indicates the >> number of bits that the host should be able to correct per >> 512 bytes of data. > > This is misleading. This field is not about the controller but rather > the chip requirements in terms of minimal strength for nominal use. > Thanks Miquel. Yes. Its NAND chip requirement. I have used the description for NAND ONFI param page 5.6.1.24. Byte 112: Number of bits ECC correctability This field indicates the number of bits that the host should be able to correct per 512 bytes of data. >> The ecc correctability is assigned in >> chip parameter during device probe time. QPIC/EBI2 NAND >> supports 4/8-bit ecc correction. The Same kind of board >> can have different NAND parts so use the ecc strength >> from device parameter (if its non zero) instead of >> device tree. > > That is not what you do. > > What you do is forcing the strength to be 8-bit per ECC chunk if the > NAND chip requires at least 8-bit/chunk strength. > > The DT property is here to force a strength. Otherwise, Linux will > propose to the NAND controller to use the minimum strength required by > the chip (from either the ONFI/JEDEC parameter page or from a static > table). > The main problem is that the same kind of boards can have different NAND parts. Lets assume, we have following 2 cases. 1. Non ONFI/JEDEC device for which chip->ecc_strength_ds will be zero. In this case, the ecc->strength from DT will be used 2. ONFI/JEDEC device for which chip->ecc_strength_ds > 8. Since QCOM nand controller can not support ECC correction greater than 8 bits so we can use 8 bit ECC itself instead of failing NAND boot completely. > IMHO, you have two solutions: > 1/ Remove these properties from the board DT (breaks DT backward > compatibility though); - nand-ecc-strength: This is optional property in nand.txt and Required property in qcom_nandc.txt. We can't remove since if the device is Non ONFI/JEDEC, then ecc strength will come from DT only. > 2/ Create another DT for the board. > Its not about board but about part. We have IPQ8074 HK01 board with 4 bit ECC chip/8 bit ECC chip/non ONFI/JEDEC chip. > However, there is something to do in this driver: the strength chosen > should be limited to the controller capabilities (8-bit/512B if I > understand correctly). In this case you have two options: either you > limit the strength like the size [1] if (ecc->strength > 8); Limiting the strength will make all the boards with ecc strength > 8 to fail completely > just limit the maximum strength to 8 like this [2] and the core will > spawn a warning in the dmesg telling that the ECC strength used is > below the NAND chip requirements. Yes its good idea. I can update the patch with dmesg warning. Thanks, Abhishek > > Thanks, > Miquèl > > [1] > https://elixir.bootlin.com/linux/latest/source/drivers/mtd/nand/qcom_nandc.c#L2332 > [2] http://code.bulix.org/nyf63w-315268 > > >> >> Signed-off-by: Abhishek Sahu >> --- >> drivers/mtd/nand/qcom_nandc.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/drivers/mtd/nand/qcom_nandc.c >> b/drivers/mtd/nand/qcom_nandc.c >> index 563b759..8dd40de 100644 >> --- a/drivers/mtd/nand/qcom_nandc.c >> +++ b/drivers/mtd/nand/qcom_nandc.c >> @@ -2334,6 +2334,14 @@ static int qcom_nand_host_setup(struct >> qcom_nand_host *host) >> return -EINVAL; >> } >> >> + /* >> + * Read the required ecc strength from NAND device and overwrite >> + * the device tree ecc strength for devices which require >> + * ecc correctability bits >= 8 >> + */ >> + if (chip->ecc_strength_ds >= 8) >> + ecc->strength = 8; >> + >> wide_bus = chip->options & NAND_BUSWIDTH_16 ? true : false; >> >> if (ecc->strength >= 8) {