Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp58978pxb; Tue, 28 Sep 2021 15:25:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydfFrc5QhpMQFFdxxpwi1f1u1ojfhv7w/qgzKP7FfIatcinPtcHWI3phGS8U8antXAOdEw X-Received: by 2002:a63:215c:: with SMTP id s28mr6718622pgm.99.1632867919524; Tue, 28 Sep 2021 15:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632867919; cv=none; d=google.com; s=arc-20160816; b=skT/t3knUefdhQDAUyetlxapbU64Meoqb5Azu2nwuF1KECGQ1M3ffnSGIQ3/+mIsVQ EgmUIVH8Y+RYK+sElUnSWe/W1mNIW1gT0z0uqs3o8k1fT/4UaGyWUXadWXBIi+XqlNo9 BQOdHU1zIQZy4Yrh9xHbhZuKMVcGsq3MWZM/YAg01Yn6WfVhv5KWeA+tFctRyy5QTciS k0ECtKaEnHtMRkIpAhwiUVzvG32CZs1KzPyks9skl/T8Kv4Ulu3W74jdlY34RxHMKY8W vV8gjMdSoWvBtp/5x3jF+TQV4cji+BIoeIukH9S1Tbatj7XOIi2d15WCWsBcenGssx+T f3Hw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AF2qQw3MgWiDmLDTc1DLOSiPvsesnI1DX3teCnbyl+U=; b=hFSr/PAFvfMZlffrQVDnZxPRY6fyfaZZOa2BWv5rz7fMuBhf2RjAb47adlelT3o7tv PbRv2zhxA5zYc4YemsvxsVShy2H+r/iJIP7hxAPB0YBoULXd2VasPBt/7qGo4Yj1LtPc Y21jhymBqjhBpXS1oPopTJ6n0QVXTdkByTUJedqNfTu2j8V+I+8r+J37Uk4Ee6eLDl5d 4Y0FdbD8dWK7+WrCckloZ9Pb50RCDfaCkxHqKekRu4ewUI4J9CiyoiKgYvPSPn1wKpPq esr2+scaVs8ZwmauhaC5uc3v/++NYe1N5fljYCjQBySS1T7mMjsIhZLGLlVe/nailBZX dgjQ== 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 d11si294356pls.183.2021.09.28.15.25.07; Tue, 28 Sep 2021 15:25:19 -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 S243282AbhI1WZF (ORCPT + 99 others); Tue, 28 Sep 2021 18:25:05 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:35167 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243162AbhI1WYv (ORCPT ); Tue, 28 Sep 2021 18:24:51 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id F1CEC100007; Tue, 28 Sep 2021 22:23:09 +0000 (UTC) From: Miquel Raynal To: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus Cc: , , Miquel Raynal , stable@vger.kernel.org Subject: [PATCH 3/9] mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines Date: Wed, 29 Sep 2021 00:22:52 +0200 Message-Id: <20210928222258.199726-14-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210928222258.199726-1-miquel.raynal@bootlin.com> References: <20210928222258.199726-1-miquel.raynal@bootlin.com> 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 Following the introduction of the generic ECC engine infrastructure, it was necessary to reorganize the code and move the ECC configuration in the ->attach_chip() hook. Failing to do that properly lead to a first series of fixes supposed to stabilize the situation. Unfortunately, this only fixed the use of software ECC engines, preventing any other kind of engine to be used, including on-die ones. It is now time to (finally) fix the situation by ensuring that we still provide a default (eg. software ECC) but will still support different ECC engines such as on-die ECC engines if properly described in the device tree. There are no changes needed on the core side in order to do this, but we just need to leverage the logic there which allows: 1- a subsystem default (set to Host engines in the raw NAND world) 2- a driver specific default (here set to software ECC engines) 3- any type of engine requested by the user (ie. described in the DT) As the raw NAND subsystem has not yet been fully converted to the ECC engine infrastructure, in order to provide a default ECC engine for this driver we need to set chip->ecc.engine_type *before* calling nand_scan(). During the initialization step, the core will consider this entry as the default engine for this driver. This value may of course be overloaded by the user if the usual DT properties are provided. Fixes: f6341f6448e0 ("mtd: rawnand: gpio: Move the ECC initialization to ->attach_chip()") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/gpio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/gpio.c b/drivers/mtd/nand/raw/gpio.c index fb7a086de35e..fdf073d2e1b6 100644 --- a/drivers/mtd/nand/raw/gpio.c +++ b/drivers/mtd/nand/raw/gpio.c @@ -163,9 +163,8 @@ static int gpio_nand_exec_op(struct nand_chip *chip, static int gpio_nand_attach_chip(struct nand_chip *chip) { - chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; - - if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN) + if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT && + chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN) chip->ecc.algo = NAND_ECC_ALGO_HAMMING; return 0; @@ -365,6 +364,13 @@ static int gpio_nand_probe(struct platform_device *pdev) if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) gpiod_direction_output(gpiomtd->nwp, 1); + /* + * This driver assumes that the default ECC engine should be TYPE_SOFT. + * Set ->engine_type before registering the NAND devices in order to + * provide a driver specific default value. + */ + chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; + ret = nand_scan(chip, 1); if (ret) goto err_wp; -- 2.27.0