Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp58584pxb; Tue, 28 Sep 2021 15:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygXz5Jl/MLeDkAIu4r4gQczTPygub+M6sjbe527q8SoPyJypxW5jfHsXum5sELTzQPDcbD X-Received: by 2002:a17:906:4310:: with SMTP id j16mr9651098ejm.48.1632867889374; Tue, 28 Sep 2021 15:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632867889; cv=none; d=google.com; s=arc-20160816; b=uhNQZpJ+3eKyFtkFgeqU0oAOi8jd0eTRNwJWYfIBAnNDV5w1TZcTdp/25FwJU7cPCz 594o2XDPDZlD1x4TTEbRY79PAjWgAXFsRCmTB8UQqcVWQeT4mYlVHV+tZvtcOnTVWxd/ U+H/mXeVlE/lol/EbUCZxY0t8Cgs+1dP37E3owpbpCP/e/JTO0eVKRGBJjw6WQBd0iAQ oKmsvTlQr6R/K0WFNpsQRrfcbnXIZ5nix0lqCP+NYGTasSkqM4pn2qOPZVH1hUuMvg3G VBuFWgueOULuRpiaaYlN8vX/dSNQ9FPT+saU4xFPuz2w5fC7TY8H4g018VzONYoVqU+/ j/kQ== 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=idCXG5a8aXYhKt7JOZebp2QcFb0c8Qft3QVoURPADRQ=; b=RMcT+DoZwv2koavYqljBJ7OOYCfxBKGgzPyddEioxEUMC8N3yZMJaqmSKbpLAJactV l4yoj09NfdgeLBb3Di2T3DpMSqI6ANZ4xzxNzxzas8Nnqt3i4zCUNBcnL6to1i/9D4M8 p48oc+ca6igkm9Qq2QH4d6zBztHzJEGltHnH1yyc8hE6/2CkHmPEUqL7EgVThjDl9kcv tqGaJlfvdA3cihzmjOPwmD2kqbFUoxh0Yn4HCKtlxNMa0VnBkwSj197smZuVKhCB9jWH 9l5lseza3KiaYTcVtVG9GSciTvxwQrbdcbKkBMaA7MGlXRMDNF1+HqGogc8RElUH3+PK WJCQ== 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 ne41si495830ejc.135.2021.09.28.15.24.25; Tue, 28 Sep 2021 15:24:49 -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 S243096AbhI1WYo (ORCPT + 99 others); Tue, 28 Sep 2021 18:24:44 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:45117 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243058AbhI1WYm (ORCPT ); Tue, 28 Sep 2021 18:24:42 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id C4D8D100006; Tue, 28 Sep 2021 22:23:00 +0000 (UTC) From: Miquel Raynal To: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus Cc: , , Miquel Raynal , stable@vger.kernel.org Subject: [PATCH 2/9] mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines Date: Wed, 29 Sep 2021 00:22:41 +0200 Message-Id: <20210928222258.199726-3-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: dbffc8ccdf3a ("mtd: rawnand: au1550: Move the ECC initialization to ->attach_chip()") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/au1550nd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/au1550nd.c b/drivers/mtd/nand/raw/au1550nd.c index 99116896cfd6..5aa3a06d740c 100644 --- a/drivers/mtd/nand/raw/au1550nd.c +++ b/drivers/mtd/nand/raw/au1550nd.c @@ -239,9 +239,8 @@ static int au1550nd_exec_op(struct nand_chip *this, static int au1550nd_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; @@ -310,6 +309,13 @@ static int au1550nd_probe(struct platform_device *pdev) if (pd->devwidth) this->options |= NAND_BUSWIDTH_16; + /* + * 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; + ret = nand_scan(this, 1); if (ret) { dev_err(&pdev->dev, "NAND scan failed with %d\n", ret); -- 2.27.0