Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp60843pxb; Tue, 28 Sep 2021 15:28:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTwYVh49nTSgfCVH50BRAuaQgi+b4Y9IkwB3eqI6bee9b9Hn4hneIp6zX8sV4bPCPy3FX8 X-Received: by 2002:a50:d841:: with SMTP id v1mr10522451edj.221.1632868112252; Tue, 28 Sep 2021 15:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632868112; cv=none; d=google.com; s=arc-20160816; b=i1lM9vgRY4H3bHa5ZNRRm56bJwDwVBobFsRWDEKbwhlE8U+sXSkYXlmBDpBOD4FAKR LUfTBADm6PX7rClZQ/gvwk7oVfZFbpG1sssl48yXwNDuJEuYSyjOjRlCHzRqnpJ5FkvH ozDgB5HNtOFAglYeUTuziYq6vPWn1RzaDnN7I+fL9QwUTsobDEZPJR9H5OhB/0GoPQkx wj11M7fl5f4ClL89lucXnVAwgOGkmd1xuF1uXraQQuB/taV844XDRTvNEeWcO1uTWzcA e0oG8SS8mdUm22oDnyra1TdHswnLg+RoDfAxPbzipH84n8/4lD8f7WGbav62OykT5RID o+BQ== 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=6A6Wlz9I9ou2y0lja6T4LX7w69tn4AI1Dp54XWk+ako=; b=TizwtGyKWbxN1QcMjSNzPuZ+sZoaBfRj80/uEZw9VPxGXu3CqHvmejW+wkvgh/+plw uBPjxXZBaiwtTZ8NghSgjogNQ/9zUXgD5HPTuAiOQiQg8XdkYe+cGudj2PPN0yQl/13z edryazryeyotXVaSTKPstCHamP+gZza/OFIZWAXKF7K446SZ0xbdM4F1H5cIIeXdLXp6 A0Ml7FcUSso1MWplBF8mOu8gbAoQWZlokxMvNQ8uyK3cmiPTBdRhvQypCqY/5BTAqZxf nbkO2KrgE45kUQZtHCVtYHXJo/vUBtfwJhEdAbPHbhYqfJQje/y1krKzYOwYybpUrC6r cyRw== 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 j25si375972eje.334.2021.09.28.15.28.08; Tue, 28 Sep 2021 15:28:32 -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 S243167AbhI1WZY (ORCPT + 99 others); Tue, 28 Sep 2021 18:25:24 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:34477 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243209AbhI1WYz (ORCPT ); Tue, 28 Sep 2021 18:24:55 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 417C010000B; Tue, 28 Sep 2021 22:23:14 +0000 (UTC) From: Miquel Raynal To: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus Cc: , , Miquel Raynal , stable@vger.kernel.org Subject: [PATCH 8/9] mtd: rawnand: socrates: Keep the driver compatible with on-die ECC engines Date: Wed, 29 Sep 2021 00:22:57 +0200 Message-Id: <20210928222258.199726-19-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: b36bf0a0fe5d ("mtd: rawnand: socrates: Move the ECC initialization to ->attach_chip()") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/socrates_nand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/socrates_nand.c b/drivers/mtd/nand/raw/socrates_nand.c index 70f8305c9b6e..fb39cc7ebce0 100644 --- a/drivers/mtd/nand/raw/socrates_nand.c +++ b/drivers/mtd/nand/raw/socrates_nand.c @@ -119,9 +119,8 @@ static int socrates_nand_device_ready(struct nand_chip *nand_chip) static int socrates_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; @@ -175,6 +174,13 @@ static int socrates_nand_probe(struct platform_device *ofdev) /* TODO: I have no idea what real delay is. */ nand_chip->legacy.chip_delay = 20; /* 20us command delay time */ + /* + * 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. + */ + nand_chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; + dev_set_drvdata(&ofdev->dev, host); res = nand_scan(nand_chip, 1); -- 2.27.0