Received: by 10.223.176.5 with SMTP id f5csp4305389wra; Tue, 30 Jan 2018 05:25:18 -0800 (PST) X-Google-Smtp-Source: AH8x225FDH2/xI+1uRAUIjebfMdtI2tT7WhpQ9xpP9cNkpMqwa3Z59lSjWD4ybKsFE7n7O119atJ X-Received: by 2002:a17:902:8d88:: with SMTP id v8-v6mr25955110plo.47.1517318718796; Tue, 30 Jan 2018 05:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517318718; cv=none; d=google.com; s=arc-20160816; b=yavSKAU8ZwTqb/s3IzUit06Veqx3cUIGtzSONPVb77obq7ury1C0gbssLNAMCOJGvB NR5+vK6agZZMeG9jbOypyfBWChXK3B956BJLByrzvaoihb0htZEw6gyKTJCtOWgLThbQ M1JskYvQoEx3nEJvjgxIVDaY+IYYV5mAMFu29FhV4r+8o2efjNIt0uVuq5ecbEffyy0I xXTDLJil6hoMeTXLOAvyDLHzI2AQpadYuJUt7wR0UYD8MOjioZ/kiXWxt3eVF09ad9Kx oobW+V+OK6mbaQv5Tm3Lh9ulDEb2mYPe2MBVqRqWWaPOzZ8mAjIUke5sS87sFGsa/1zN 9RpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=/gtvHSE2zGKwP/5sP9RgytmQ9meMTLMzNjmvH7CbQuA=; b=ZNnYfFRfioEuYIoA6vYLukFmulSdf4vEk4BrGQoFx2LiF8B9zLCPKu3dIS1D+o7BtV E52jRtghdqiZJuG41T9tNXS/4GxCVA/lbLx/jJE98EQfwEXp6uRADGaKhoiG04okHEkN 0jpHGa+54brBa+4AEGvxDCd/MlnBx1GtUT+sB0KZ8td3xt67uKiFX4ZR/tgiYIMXX5Bi rGv1OfD0/evMZRup9oRhcTONYFgQb1gWyx/jP0Bh0XTaiut9MuXhe7KVnDgjFQolyGJX B9uapAB5l24NxBFGzHX88Wn1Z+t7d0BVgwvjs3N+wyOEqEXfWOmPGgHMdr2kFcCn17FW SRAQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v6-v6si1873093plg.575.2018.01.30.05.25.03; Tue, 30 Jan 2018 05:25:18 -0800 (PST) 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; 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 S1752463AbeA3NYC (ORCPT + 99 others); Tue, 30 Jan 2018 08:24:02 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:41853 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbeA3NYA (ORCPT ); Tue, 30 Jan 2018 08:24:00 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 598C1219D7; Tue, 30 Jan 2018 14:23:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 06E19219FA; Tue, 30 Jan 2018 14:23:49 +0100 (CET) Date: Tue, 30 Jan 2018 14:23:48 +0100 From: Boris Brezillon To: Stefan Agner Cc: han.xu@nxp.com, max.oss.09@gmail.com, richard@nod.at, linux-kernel@vger.kernel.org, marek.vasut@gmail.com, linux-mtd@lists.infradead.org, cyrille.pitchen@wedev4u.fr, dwmw2@infradead.org Subject: Re: [PATCH] mtd: nand: gpmi: fall back to legacy mode if no ECC information present Message-ID: <20180130142348.35f1bce3@bbrezillon> In-Reply-To: <20180129144440.13648-1-stefan@agner.ch> References: <20180129144440.13648-1-stefan@agner.ch> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stefan, On Mon, 29 Jan 2018 15:44:40 +0100 Stefan Agner wrote: > In case fsl,use-minimum-ecc is set, the driver tries to determine > ECC layout by using the ECC information provided by the MTD stack. > However, in case the NAND chip does not provide any information, > the driver currently fails with: > nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 > nand: Macronix NAND 128MiB 3,3V 8-bit > nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 > gpmi-nand 1806000.gpmi-nand: Error setting BCH geometry : 1 > gpmi-nand: probe of 1806000.gpmi-nand failed with error 1 > > Fall back to implementation specific default mode if no ECC > information are provided by the NAND chip and fsl,use-minimum-ecc > is specified. Hm, this sounds a bit fragile: if we ever fix the Macronix driver (which should be done BTW) to set the appropriate ECC requirements, it will break all platforms that were relying on this 'fall back to legacy logic'. So, if what you really want is legacy_set_geometry(), don't specify "fsl,use-minimum-ecc" in your DT and you should be good. Otherwise, fix the Macronix driver to initialize ->ecc_{strength,step_size}_ds appropriately. Regards, Boris > > This is more in line with what the device tree binding documentation > promises: > "However, note that if this strength is not > discoverable or this property is not enabled, > the software may chooses an implementation-defined > ECC scheme." > > Signed-off-by: Stefan Agner > --- > drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c > index 50f8d4a1b983..7b8e8c629081 100644 > --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c > +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c > @@ -206,7 +206,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this) > unsigned int block_mark_bit_offset; > > if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0)) > - return -EINVAL; > + return -ENOTSUPP; > > switch (chip->ecc_step_ds) { > case SZ_512: > @@ -423,11 +423,15 @@ static int legacy_set_geometry(struct gpmi_nand_data *this) > > int common_nfc_set_geometry(struct gpmi_nand_data *this) > { > - if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) > - || legacy_set_geometry(this)) > - return set_geometry_by_ecc_info(this); > + int ret = -ENOTSUPP; > > - return 0; > + if (of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) > + ret = set_geometry_by_ecc_info(this); > + > + if (ret == -ENOTSUPP) > + return legacy_set_geometry(this); > + > + return ret; > } > > struct dma_chan *get_dma_chan(struct gpmi_nand_data *this)