Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3427757pxb; Mon, 30 Aug 2021 01:43:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza4g/UuoLh3idXVbUTRb8zqCZb5z/E0xuSYu0xVim34oJk9O6pst4LHT9MPSdURCk0wk+U X-Received: by 2002:a05:6e02:10d0:: with SMTP id s16mr16099067ilj.275.1630313011248; Mon, 30 Aug 2021 01:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630313011; cv=none; d=google.com; s=arc-20160816; b=V881K9juUokhcVpdeAfPh/KdZmTg8OvmU/Q/9PxIPtu4Su5+khvFoQkOtj/bu/hRje Gc0ugu6clNMaewu2+CY7efkErGH08k3qkXWiV6dy/OwzO+7U9b46dbon+n4a833Sx2mD I8gIv+KU3nNb3pan17NJbOR4QrzbXwrHkQk+nLzLhxydkPzcU8/Gz+oSr120yeU8N+yH VeZk2J0O2m/3txBGAubkL9sqvBFv8tyNkX/UcFzeLIlHY5uH7bAOHWj5xScmQ4lwP25D qARLi9bpiojZSGWEHE2e1BJ1JLXxkklhB2X33mB36QlKHbV77wRrBAZThXheiP6StVZx 3aFA== 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=m9l9CFeCrOHf68HhSoaaRZOCEt45kmCOMoHOSoXappc=; b=fQ0ePpl8QhZBzc3EjgIBiUbjRFM0LIXJBg49FYiJpOD/z4dTh0OPUB9Rj5QN9yFTvD h53dAVWU41tBsk7Kyd+Wzd54JGEfAJBXmLIxTYcco58PwoiOJ57ov0wzzf84bYPa/eZU v5FtGFc3AMerxXX093hYo4hEtXEKNKUJUbo1YOtbVgO5gX55JcRh+xBeD1HpJVbFbMX4 PhDEQ7bxLlLVkFhAiwTOJ9ZKniQVaHUf6gYCmkK5TSDK66KcKcuA3E48W3DvTF5whOfp normZIoUceMEOcAhtgtsJx/uugGZUBNthBNNrtXh/g+SW/te5cLoI1oYS1D2GYN9gNBb fQDA== 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 10si14405862ilz.71.2021.08.30.01.43.19; Mon, 30 Aug 2021 01:43:31 -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 S234880AbhH3ImV convert rfc822-to-8bit (ORCPT + 99 others); Mon, 30 Aug 2021 04:42:21 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:43889 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233162AbhH3ImU (ORCPT ); Mon, 30 Aug 2021 04:42:20 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id A8274240012; Mon, 30 Aug 2021 08:41:23 +0000 (UTC) Date: Mon, 30 Aug 2021 10:41:22 +0200 From: Miquel Raynal To: Frieder Schrempf Cc: Frieder Schrempf , stable@vger.kernel.org, voice INTER connect GmbH , Alexander Lobakin , Felix Fietkau , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Richard Weinberger , YouChing Lin Subject: Re: [RESEND PATCH 5.10.x] mtd: spinand: Fix incorrect parameters for on-die ECC Message-ID: <20210830104122.58f9cdaf@xps13> In-Reply-To: <20210830072108.13770-1-frieder@fris.de> References: <20210830072108.13770-1-frieder@fris.de> 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 Frieder, Frieder Schrempf wrote on Mon, 30 Aug 2021 09:21:07 +0200: > From: Frieder Schrempf > > The new generic NAND ECC framework stores the configuration and requirements > in separate places since commit 93ef92f6f422 (" mtd: nand: Use the new generic ECC object "). > In 5.10.x The SPI NAND layer still uses only the requirements to track the ECC > properties. This mismatch leads to values of zero being used for ECC strength > and step_size in the SPI NAND layer wherever nanddev_get_ecc_conf() is used and > therefore breaks the SPI NAND on-die ECC support in 5.10.x. > > By using nanddev_get_ecc_requirements() instead of nanddev_get_ecc_conf() for > SPI NAND, we make sure that the correct parameters for the detected chip are > used. In later versions (5.11.x) this is fixed anyway with the implementation > of the SPI NAND on-die ECC engine. > > Cc: stable@vger.kernel.org # 5.10.x > Reported-by: voice INTER connect GmbH > Signed-off-by: Frieder Schrempf Why not just reverting 9a333a72c1d0 ("mtd: spinand: Use nanddev_get_ecc_conf() when relevant")? I think using this "new" nanddev_get_ecc_requirements() helper because it fits the purpose even if it is wrong [1] doesn't bring the right information. I know it is strictly equivalent but I would personally prefer keeping the old writing "nand->eccreq.xxxx". [1] We don't want the requirements but the actual current configuration here, which was the primary purpose of the initial patch which ended being a mistake at that point in time because the SPI-NAND core was not ready yet. Thanks, Miquèl > --- > Resending this with an improved subject prefix and because the > previous mail wasn't delivered to some of the lists. > --- > drivers/mtd/nand/spi/core.c | 6 +++--- > drivers/mtd/nand/spi/macronix.c | 6 +++--- > drivers/mtd/nand/spi/toshiba.c | 6 +++--- > 3 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c > index 558d8a14810b..8794a1f6eacd 100644 > --- a/drivers/mtd/nand/spi/core.c > +++ b/drivers/mtd/nand/spi/core.c > @@ -419,7 +419,7 @@ static int spinand_check_ecc_status(struct > spinand_device *spinand, u8 status) > * fixed, so let's return the maximum possible value > so that > * wear-leveling layers move the data immediately. > */ > - return nanddev_get_ecc_conf(nand)->strength; > + return nanddev_get_ecc_requirements(nand)->strength; > > case STATUS_ECC_UNCOR_ERROR: > return -EBADMSG; > @@ -1090,8 +1090,8 @@ static int spinand_init(struct spinand_device > *spinand) mtd->oobavail = ret; > > /* Propagate ECC information to mtd_info */ > - mtd->ecc_strength = nanddev_get_ecc_conf(nand)->strength; > - mtd->ecc_step_size = nanddev_get_ecc_conf(nand)->step_size; > + mtd->ecc_strength = > nanddev_get_ecc_requirements(nand)->strength; > + mtd->ecc_step_size = > nanddev_get_ecc_requirements(nand)->step_size; > return 0; > > diff --git a/drivers/mtd/nand/spi/macronix.c > b/drivers/mtd/nand/spi/macronix.c index 8e801e4c3a00..cd7a9cacc3fb > 100644 --- a/drivers/mtd/nand/spi/macronix.c > +++ b/drivers/mtd/nand/spi/macronix.c > @@ -84,11 +84,11 @@ static int mx35lf1ge4ab_ecc_get_status(struct > spinand_device *spinand, > * data around if it's not necessary. > */ > if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr)) > - return nanddev_get_ecc_conf(nand)->strength; > + return > nanddev_get_ecc_requirements(nand)->strength; > - if (WARN_ON(eccsr > > nanddev_get_ecc_conf(nand)->strength || > + if (WARN_ON(eccsr > > nanddev_get_ecc_requirements(nand)->strength || !eccsr)) > - return nanddev_get_ecc_conf(nand)->strength; > + return > nanddev_get_ecc_requirements(nand)->strength; > return eccsr; > > diff --git a/drivers/mtd/nand/spi/toshiba.c > b/drivers/mtd/nand/spi/toshiba.c index 21fde2875674..6fe7bd2a94d2 > 100644 --- a/drivers/mtd/nand/spi/toshiba.c > +++ b/drivers/mtd/nand/spi/toshiba.c > @@ -90,12 +90,12 @@ static int tx58cxgxsxraix_ecc_get_status(struct > spinand_device *spinand, > * data around if it's not necessary. > */ > if (spi_mem_exec_op(spinand->spimem, &op)) > - return nanddev_get_ecc_conf(nand)->strength; > + return > nanddev_get_ecc_requirements(nand)->strength; > mbf >>= 4; > > - if (WARN_ON(mbf > > nanddev_get_ecc_conf(nand)->strength || !mbf)) > - return nanddev_get_ecc_conf(nand)->strength; > + if (WARN_ON(mbf > > nanddev_get_ecc_requirements(nand)->strength || !mbf)) > + return > nanddev_get_ecc_requirements(nand)->strength; > return mbf; >