Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1951496pxb; Mon, 23 Aug 2021 08:25:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUjLvWkishROMffbEWKGqMfnr7PHD4gRwKMWWThlxQ4y3QiRem7jV5arnLyph5mKTWEGWS X-Received: by 2002:a92:c80e:: with SMTP id v14mr24432762iln.57.1629732332146; Mon, 23 Aug 2021 08:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629732332; cv=none; d=google.com; s=arc-20160816; b=IKrPHQVrwWr0SjxKPqUstbeenZN06yiiqmztaQiC2h7HVQtW/ZbUtGtp0HG60iQYYd zHoQVCviqcEG8wu6ShTOHo3AAp4IdM2lZq5QOm6bs5O53f5otJ7V56QL7UFSe5V3S3xj hFJMDPK86Ls5XSYP8T2ctDw4OJmXAfqFD1k41Vl/paHYMUT8uvhv9WEuqMmKhayIKnW7 +vhywNxdvFRURB4w+8m9KxhN04BqAPX9oZS2g8hRcta/czlHntkUUdBjnz0l+Mq6NtJB Ep/cPil6jdbBF6/kZ2bkAMysrBIZ2I6TwPuRTbKGfrVbVR4ifxkmbtig+fRLOE4z8lL7 EWIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=KZ3zd/QBgVQw2TraQQ3My4QM6tKuy27HCvGB0zsrF4M=; b=I19dVZxcCJzmfpHyLGKZYgOnoNREaEdfjl6JFoK+FpZ92rPzHYur1zMqLtAawsYOB5 4Hj4dCsx+Nq2PCBb+XKWwlzx6yXvLCEBFOOrEZtKwSD9muKrwwURFPQW3wWdj3dryo8H 3R5jf0XvbU877s36zhRD+F8P3K1/l3RF/aJBbVLXp7qvvlUyqz9PfYI2nEnY7vPTZx8k DFyUiNvVWiHS0uj1DUXP7sgLcW+anZHC3HHB6M1aqlhUi5aiqzwAwNW31/40O1/vesWp 2IRHkw/uyW4afF8wHCLUnOAZTGF0H8acFChSd+ns8/bOMUn3MKGIquNIjtKbG4YFsKh6 qyag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si14815992iow.102.2021.08.23.08.25.20; Mon, 23 Aug 2021 08:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbhHWPZB convert rfc822-to-8bit (ORCPT + 99 others); Mon, 23 Aug 2021 11:25:01 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:35105 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbhHWPZA (ORCPT ); Mon, 23 Aug 2021 11:25:00 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 4D2206000C; Mon, 23 Aug 2021 15:24:14 +0000 (UTC) Date: Mon, 23 Aug 2021 17:24:13 +0200 From: Miquel Raynal To: Kestrel seventyfour Cc: Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mtd: rawnand: xway: No hardcoded ECC engine, use device tree setting Message-ID: <20210823172413.0bc4ab3a@xps13> In-Reply-To: References: <20210808072643.GA5084@ubuntu> <20210816093126.442f74a1@xps13> <20210819100334.6af2d86e@xps13> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kestrel, Kestrel seventyfour wrote on Mon, 23 Aug 2021 13:19:43 +0200: > Hi Miquèl, > > Am Do., 19. Aug. 2021 um 10:03 Uhr schrieb Miquel Raynal > : > > > > Hello, > > > > Kestrel seventyfour wrote on Thu, 19 Aug > > 2021 09:21:42 +0200: > > > > > Hi Miquèl > > > > > > Am Mo., 16. Aug. 2021 um 09:31 Uhr schrieb Miquel Raynal > > > : > > > > > > > > Hi Daniel, > > > > > > > > Daniel Kestrel wrote on Sun, 8 Aug 2021 > > > > 09:26:43 +0200: > > > > > > > > > Some devices use Micron NAND chips, which use on-die ECC. The hardcoded > > > > > setting of NAND_ECC_ENGINE_TYPE_SOFT makes them unusable, because the > > > > > software ECC on top of the hardware ECC produces errors for every read > > > > > and write access, not to mention that booting does not work, because > > > > > the boot loader uses the correct ECC when trying to load the kernel > > > > > and stops loading on severe ECC errors. > > > > > This patch requires the devices that currently work with the hard coded > > > > > setting to set the nand-ecc-mode property to soft in their device > > > > > tree. > > > > > > > > > > > > > Please add a Fixes: and Cc: stable tags, you will also need to send to > > > > stable@vger.kernel.org a different version of the patch for the kernel > > > > 5.4 IIUC. > > > > > > > > > Signed-off-by: Daniel Kestrel > > > > > Tested-by: Aleksander Jan Bajkowski # tested on BT Home Hub 5A > > > > > --- > > > > > drivers/mtd/nand/raw/xway_nand.c | 2 -- > > > > > 1 file changed, 2 deletions(-) > > > > > > > > > > diff --git a/drivers/mtd/nand/raw/xway_nand.c b/drivers/mtd/nand/raw/xway_nand.c > > > > > index 26751976e502..0a4b0aa7dd4c 100644 > > > > > --- a/drivers/mtd/nand/raw/xway_nand.c > > > > > +++ b/drivers/mtd/nand/raw/xway_nand.c > > > > > @@ -148,8 +148,6 @@ static void xway_write_buf(struct nand_chip *chip, const u_char *buf, int len) > > > > > > > > > > static int xway_attach_chip(struct nand_chip *chip) > > > > > { > > > > > - chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; > > > > > - > > > > > if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN) > > > > > chip->ecc.algo = NAND_ECC_ALGO_HAMMING; > > > > > > > > You also need to only set the Hamming algorithm when engine_type is > > > > TYPE_SOFT. > > > > > > > > Thanks, > > > > Miquèl > > > > > > I am really struggling with what to do. For one of the affected > > > devices, they created two device > > > trees, one for Micron and one for all others. Which obviously had no > > > effect due to the > > > hardcoded settings, which led me to Patch 2 and I thought, so be it. > > > But the process to figure > > > out if ones device has Micron Chips is essentially flashing an image > > > and if it does not work, > > > use the stock OEM recovery and try the other image. > > > However, since Micron is the only chip that is treated differently, I wonder > > > if your first proposal, even though it is hacky, is the better > > > approach to solve the issue > > > for the Micron devices not booting and throwing ECC errors. What do you think? > > > Follow up first patch or this one? > > > > I am not sure we understood each other, your patch is fine, but you > > need to do something like: > > > > static int xway_attach_chip(struct nand_chip *chip) > > { > > if (chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT && > > chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN) > > chip->ecc.algo = NAND_ECC_ALGO_HAMMING; > > > > In the DT you should not force any ECC engine (drop the nand-ecc-xxx > > properties) and let the core handle it. It will probably choose the > > most suitable engines for you. > > > > Thanks, > > Miquèl > > thank you for your response. > If I remove the nand-ecc-xxx properties in the device tree, the device with > the Toshiba NAND chip is working. However, the device with the Micron > NAND fails with NO ECC functions supplied; hardware ECC not possible, > seems to be at line 5367 or equivalent. > https://elixir.bootlin.com/linux/latest/source/drivers/mtd/nand/raw/nand_base.c#L5367 > > It looks like the micron nand driver supports on die only if its > specified int the > Device tree: > https://elixir.bootlin.com/linux/latest/source/drivers/mtd/nand/raw/nand_micron.c#L511 > The Micron NAND driver probably needs to set the ECC type to ON DIE if the > variable ondie contains the supported attribute?! You're right but I don't see any easy upstream-able solution here. Changing the behavior in the Xway driver would certainly break users, changing the behavior in the Micron driver would certainly break even more users. The root cause being an absence of proper description (the integration changed). Honestly I feel stuck, maybe you can try to register your device, if it fails, change the integration in the driver (to an ondie ecc engine) then retry? Thanks, Miquèl