Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp58858pxb; Tue, 28 Sep 2021 15:25:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7dD9yk5ooKeKmh2cWYYtQqP6nSUPJQT7QW212rFqnqPTSOpIOwH/f4kHkKbVHk0mhX4Zj X-Received: by 2002:a17:906:f6c5:: with SMTP id jo5mr9870848ejb.162.1632867911963; Tue, 28 Sep 2021 15:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632867911; cv=none; d=google.com; s=arc-20160816; b=kx/oyhDTReggG4iRr/6cMhkpJkZyO+/SH8dWLoLLSnDbWIHAezXa5s1PO8/2zxGO3V MPnyXVgpCCYkm4scfOQ3mBnPFNdWLOu/NvdU1P51weJT1a1UEBstRKdOQkzoRT4rHmCn jXPmXywcB3XdsN7DHMaHAG4eX7Y0ISkGU/byHMDQ8R5aueQWIeU63wGFF7mMPqx1ikY9 QCiYFQO7xPtn17DTRO5iUG+aVAIAPYX8qSSlsB2Xa4oOQ8NxeUvkNeWr8XK8iFoZX49w PSN1y5bVjvjNA9DGLBxCBnJqwHwKlRSWeu23/F0ikqXTyyyhdfnsj+FDnZFzHPFbymH2 +8gQ== 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=h7CrvUS5ezW2NWh+BW27qjARaitUvKD1rCrIsB5rEB0=; b=u0xZbuhOgHiC2c4RHCvTCkXa5ZC0rQUSqK8sl2IzgXDfS0Xkff/jtfYZSvIKAo7WX/ r6IITs3CPwgGwUtwGUE1GAavLa2Iu0lBRp7EPh7qum/CiVSKXYRxt8BLeA/QXlA96uI2 AVl8yyf0mccuGQQcDXgpRWMDFZ8kEnfo4csy1adbW5HYUol8t4+X1p3s5j9Nv8XNhq6u 7Rwtq3uDCMDFH5pjLjig89yrI37VgKLCC7iSIUs8DgWvam1PS90d9v/gOJWfwlKDRsXP wzjhWhOZgw1HefdrX0WdIttG4oA81A+En3TpOsje+5IJ9aL+Z3bL7PfuL5G1IaJrJrQn kzBA== 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 c19si566797ede.102.2021.09.28.15.24.48; Tue, 28 Sep 2021 15:25:11 -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 S243216AbhI1WY4 (ORCPT + 99 others); Tue, 28 Sep 2021 18:24:56 -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 S243058AbhI1WYq (ORCPT ); Tue, 28 Sep 2021 18:24:46 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id EFA8110000B; Tue, 28 Sep 2021 22:23:04 +0000 (UTC) From: Miquel Raynal To: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus Cc: , , Miquel Raynal , stable@vger.kernel.org Subject: [PATCH 7/9] mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines Date: Wed, 29 Sep 2021 00:22:46 +0200 Message-Id: <20210928222258.199726-8-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: 612e048e6aab ("mtd: rawnand: plat_nand: Move the ECC initialization to ->attach_chip()") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/plat_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/plat_nand.c b/drivers/mtd/nand/raw/plat_nand.c index 7711e1020c21..0ee08c42cc35 100644 --- a/drivers/mtd/nand/raw/plat_nand.c +++ b/drivers/mtd/nand/raw/plat_nand.c @@ -21,9 +21,8 @@ struct plat_nand_data { static int plat_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; @@ -94,6 +93,13 @@ static int plat_nand_probe(struct platform_device *pdev) goto out; } + /* + * 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. + */ + data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; + /* Scan to find existence of the device */ err = nand_scan(&data->chip, pdata->chip.nr_chips); if (err) -- 2.27.0