Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp59406pxb; Tue, 28 Sep 2021 15:26:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0ZujdAa7iYj+MZCCmRe4Q4dP5kltdLhYQscpjCo3XgseGsXaJ0gxjtyjmDWkykxbiKUpf X-Received: by 2002:a17:90a:7d05:: with SMTP id g5mr2638523pjl.14.1632867964248; Tue, 28 Sep 2021 15:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632867964; cv=none; d=google.com; s=arc-20160816; b=Z+85kdhyYwnPBMUpBbH+zPzDLLNRntc+6Pvs9Drwi9+ZZ0GKKA0LZrplioaYAz3EFm VxG3lLM43CJ3qea/cz9e3ZN2dfJV3eCXEWSYT8rlczKKm8nA/8tWDHSKKsAp5A5c3rbU ZFS6yYRx5QwUUQUx328ZE9sA+i0TvhDgR4EhJHjlGErVZ6QfFArHcyc88WdhGcnRNqiX uSUrVMlkDBbZHvTndwNY5aMeCqJ+xf/OPgzmLRQhAan2l1NH/81QajC021mZMLx120BQ WBlioWUCJpBtkMUKSse2f/8G/j3200dDIlGEqU5zZR5vqAH/sbI9i1zCU2dy0jDjcSN1 rwVA== 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=+Lnj6+OqNhOVLviLHaOzE6Ba9ikn4+2fNdCJSiA4mCQ=; b=nfJxDQ0y1Wx1pEw7nEUKHa9jNyd5L6W2k4B+Y9c/WnU6sA9UCqFY6OaOtzgwWW7cII /pB+BAb+wRAySYPfHXws4Fk/oQrDCVNOPzrZCn6TFLUOafzF4hb0J89QdMbB+kR+akhX J3EFfBEJZ7gvCQVKB+3jwW61qCl5JpE06TLaAmJAogBeoTgQvsbyr8CTxxtr97AmmFDa ZDkSaGVLUnHY/96vIPeQJn7rTz4DN7UutwHfgVnEEGhf/LcqWUDG3FNHFYGAQPDjwmu1 zK7W5e4kDSwHxqMxqiczmzj05iTzkAnDr8IxZs2v3FvgNnE0Ak7a/IEusMxvHUU4Uyk8 D15Q== 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 p8si278624plb.408.2021.09.28.15.25.51; Tue, 28 Sep 2021 15:26:04 -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 S243256AbhI1WZC (ORCPT + 99 others); Tue, 28 Sep 2021 18:25:02 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:36219 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243109AbhI1WYt (ORCPT ); Tue, 28 Sep 2021 18:24:49 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 4F89F100005; Tue, 28 Sep 2021 22:23:08 +0000 (UTC) From: Miquel Raynal To: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus Cc: , , Miquel Raynal , stable@vger.kernel.org Subject: [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Date: Wed, 29 Sep 2021 00:22:50 +0200 Message-Id: <20210928222258.199726-12-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: 59d93473323a ("mtd: rawnand: ams-delta: Move the ECC initialization to ->attach_chip()") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/ams-delta.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index ff1697f899ba..13de39aa3288 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -217,9 +217,8 @@ static int gpio_nand_setup_interface(struct nand_chip *this, int csline, 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; @@ -370,6 +369,13 @@ static int gpio_nand_probe(struct platform_device *pdev) /* Release write protection */ gpiod_set_value(priv->gpiod_nwp, 0); + /* + * 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. + */ + this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; + /* Scan to find existence of the device */ err = nand_scan(this, 1); if (err) -- 2.27.0