Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp883666pxt; Fri, 6 Aug 2021 16:55:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjqQ9/Lv5HB4IyCxOv9xZ1WQVpO9OQz7cNo1WDDNREFsps0Afg6vAaBwEOUXnsqGzGcMrR X-Received: by 2002:a92:2809:: with SMTP id l9mr713840ilf.159.1628294126477; Fri, 06 Aug 2021 16:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628294126; cv=none; d=google.com; s=arc-20160816; b=HxBeR1CFbHkx8j9zUOCpsnOA/Dw2jWQ1Az/AyjQyoYORCp5FsTznLiMhYROpPGNHz0 HPXgmJym1g1jRGXQZMLhC9a8Wwffd6mUy/15W0Eo4ZwpWe1uJ8LQW2yX6KZqhjJXJyoc 7+iLHwpbt9krJmFx6fMjVnZAMvjVJrgdBKbOzmO+uGJkaipsgjz3BIh+4ZzfZ8TJmCFz QA6jssgQyn+IBEaVVEj0Nu9Mx/8t5I+PmcOgLFLInHobtKPmJhI+qQxm17m5xz1i7JhM 3uy/sOp2gDg466BvkI4cdfc8mXmxHo13vZnHS/NqtYyQpoMx/BAVmpqTjEa0F8L0jJKm crZQ== 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=sAWe1ZqG2W+A8RT/RCAUyVgmcI+gNmD+C3gxEJQ2MTI=; b=LZrRr5+iVcCLfQNYo+iIw1mqH20oIFo4erPbY4+TDSZzFr0u7TVveQZjIhCRf/UlKu xy4J3iif+thB1SaP4SZbB6cUScKgH/yMINMOWRDd2mRN+cZrz8A1YRRIcXUVtwqrvJsE 3wNuLdgoN9z+8brw7TCx3LEapT+Rfrq9ObS5x9IzBcINULYBZ+Q+Uj3tkHe5I3TXSx7+ N/4Az84bUZmx21+eA7qKE52iDQeDfHD72pvHCK2fHWhALYp6DL2Pvlv/fhDG3aAGF/0G rQzXns9Ie1U3zCwZ+zVKSHtYFBko8ysolXIO0g052PVzS43Vtxpn0+NTDc9edtsWHkBt dA8Q== 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 k14si11741727jad.34.2021.08.06.16.55.15; Fri, 06 Aug 2021 16:55:26 -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 S238718AbhHFQ5S convert rfc822-to-8bit (ORCPT + 99 others); Fri, 6 Aug 2021 12:57:18 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:60533 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238146AbhHFQ5S (ORCPT ); Fri, 6 Aug 2021 12:57:18 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id C23B4C0003; Fri, 6 Aug 2021 16:56:59 +0000 (UTC) Date: Fri, 6 Aug 2021 18:56:58 +0200 From: Miquel Raynal To: Daniel Kestrel Cc: Richard Weinberger , Vignesh Raghavendra , Boris Brezillon , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: rawnand: xway: No hardcoded ECC engine for Micron Chips Message-ID: <20210806185658.5b4772a7@xps13> In-Reply-To: <20210803143256.GA5209@ubuntu> References: <20210803143256.GA5209@ubuntu> 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 Daniel, Daniel Kestrel wrote on Tue, 3 Aug 2021 16:32:56 +0200: > Some lantiq xway 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. > Removing the hardcoded settings would break a number of devices that > work with those settings. > Adding a DTB property was considered, but did not work, because devices > of the same type but from different manufacture dates have different > NAND chips and as such it is not possible to determine the NAND chip > in advance or device specific. I understand the problem and it is a very crappy situation. > > Signed-off-by: Daniel Kestrel > --- > drivers/mtd/nand/raw/xway_nand.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/raw/xway_nand.c b/drivers/mtd/nand/raw/xway_nand.c > index 26751976e502..20cb5ce2f3b0 100644 > --- a/drivers/mtd/nand/raw/xway_nand.c > +++ b/drivers/mtd/nand/raw/xway_nand.c > @@ -10,6 +10,7 @@ > #include > > #include > +#include "internals.h" > > /* nand registers */ > #define EBU_ADDSEL1 0x24 > @@ -148,7 +149,8 @@ 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->manufacturer.desc->id != NAND_MFR_MICRON) > + chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; Could we make this a little bit clever with something like this: https://elixir.bootlin.com/linux/v5.13-rc7/source/drivers/mtd/nand/raw/nand_micron.c#L434 This is far from ideal, there should definitely be a change in the DT. But given your initial comments I guess it is not possible. Anyway I don't find a better way as, during the attach() call, we don't yet ran the manufacturer code, hence we don't know if on-die ECC is actually available or not. Thanks, Miquèl