From patchwork Mon Oct 24 11:30:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp531442wru; Mon, 24 Oct 2022 09:06:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59Oz7GL2ggiu1zWtsEONSsgKCtmfp860JCmjRwCynMxF4ZxP/rhIpKFh/dgQo7PDuVbpTK X-Received: by 2002:a17:906:2681:b0:783:6a92:4c38 with SMTP id t1-20020a170906268100b007836a924c38mr28735259ejc.75.1666627590121; Mon, 24 Oct 2022 09:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627590; cv=none; d=google.com; s=arc-20160816; b=IPtRZM3Su9qpNsZZvGWx7umHnZFcLzY8rAe5wquNOCq4iBAMRvV071KybDz1ytmaK6 dqzf93q22QegxjTP5mnZ/VzbfJxsmAM6eMIfx2ilclNl+d0pIB+XaU8LIHmek1Sb/Fle VjIf0BMcL8n8Yg+JZ+BJbhjw+DVhlh2YJICyl93Gqf2/2XxJDSDyqpLMmf4L5zOS5+gR MhOXLsyAUEfBcz+Y/Hd1wWFIm5w8yD11BRdrw5ndBfZewKiUmGAaLLkADuEqQTEgxBfW tQhxXWOdje5wA3/sZXVG4jtnZk+eXKpm0KJ6WfquXUfRXQjHrO3U0JC1ASpyfEwoUSfU fmdw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mglh/NUed9myl8jdwUehfJ6DkTvRvl5AvZOUPV4XBok=; b=Nd+16Cac/J2KX1McSeOuHY8d3NGM2n++bpEGqRr20Sc7JQbemuvZ3ruA50W038UlXm Jlcaekb1iyv/CipVysSdhLn71xyojH68o6lZF429d+YI7MLskJK05XLCVJA38nGr5oZV GD9bf/EOUluH8ZmA9vn8jEf1+HIvOAw5YEUyBICS680weqkUf+lfc6FFZWS16nxM/5Uf tkAKuqqYuaT1TPJGGzzS74szVmjSDO88PIaeLpAwPOSB3iMTuU3osW4Riso0/8XTKDVX czcya+QZa3bE99uv3ZGTsy2dqailc3s2zwsrotLYzgrbjmiq0Q0OllnZX2Xldu1FjK2n GrCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T0pAjQzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he6-20020a1709073d8600b007820e1a4302si142271ejc.675.2022.10.24.09.06.01; Mon, 24 Oct 2022 09:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T0pAjQzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232458AbiJXQFZ (ORCPT + 99 others); Mon, 24 Oct 2022 12:05:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232473AbiJXQCs (ORCPT ); Mon, 24 Oct 2022 12:02:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9375E18BE1A; Mon, 24 Oct 2022 07:55:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 41BBCB8167E; Mon, 24 Oct 2022 12:26:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FA35C433D7; Mon, 24 Oct 2022 12:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614415; bh=NKs2j46xrycp+rC2BkWY1EBoIVk7nyn2lYjtSNXnOnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0pAjQzO++oqmjacpOqrZsXD/p1I3RxPN/OVAkMMdFCugOXoIQYMS68NNiWiTpTHY w56M8UU20zzJ9ChUUBUsm///NlXL71KrZ5rWpQmqKYZckgwpKCpNe6Q7+mnpoKR17R 3ewcFGhTw/lmtB2VuspkGTrSKWddBg559WXcCgwA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Miquel Raynal , Sasha Levin Subject: [PATCH 5.10 222/390] mtd: rawnand: fsl_elbc: Fix none ECC mode Date: Mon, 24 Oct 2022 13:30:19 +0200 Message-Id: <20221024113032.224298131@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747585691878791703?= X-GMAIL-MSGID: =?utf-8?q?1747585691878791703?= From: Pali Rohár [ Upstream commit 049e43b9fd8fd2966940485da163d67e96ee3fea ] Commit f6424c22aa36 ("mtd: rawnand: fsl_elbc: Make SW ECC work") added support for specifying ECC mode via DTS and skipping autodetection. But it broke explicit specification of HW ECC mode in DTS as correct settings for HW ECC mode are applied only when NONE mode or nothing was specified in DTS file. Also it started aliasing NONE mode to be same as when ECC mode was not specified and disallowed usage of ON_DIE mode. Fix all these issues. Use autodetection of ECC mode only in case when mode was really not specified in DTS file by checking that ecc value is invalid. Set HW ECC settings either when HW ECC was specified in DTS or it was autodetected. And do not fail when ON_DIE mode is set. Fixes: f6424c22aa36 ("mtd: rawnand: fsl_elbc: Make SW ECC work") Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Marek Behún Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20220707184328.3845-1-pali@kernel.org Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/fsl_elbc_nand.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/raw/fsl_elbc_nand.c b/drivers/mtd/nand/raw/fsl_elbc_nand.c index b2af7f81fdf8..c174b6dc3c6b 100644 --- a/drivers/mtd/nand/raw/fsl_elbc_nand.c +++ b/drivers/mtd/nand/raw/fsl_elbc_nand.c @@ -727,36 +727,40 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip) struct fsl_lbc_regs __iomem *lbc = ctrl->regs; unsigned int al; - switch (chip->ecc.engine_type) { /* * if ECC was not chosen in DT, decide whether to use HW or SW ECC from * CS Base Register */ - case NAND_ECC_ENGINE_TYPE_NONE: + if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_INVALID) { /* If CS Base Register selects full hardware ECC then use it */ if ((in_be32(&lbc->bank[priv->bank].br) & BR_DECC) == BR_DECC_CHK_GEN) { - chip->ecc.read_page = fsl_elbc_read_page; - chip->ecc.write_page = fsl_elbc_write_page; - chip->ecc.write_subpage = fsl_elbc_write_subpage; - chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST; - mtd_set_ooblayout(mtd, &fsl_elbc_ooblayout_ops); - chip->ecc.size = 512; - chip->ecc.bytes = 3; - chip->ecc.strength = 1; } else { /* otherwise fall back to default software ECC */ chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; chip->ecc.algo = NAND_ECC_ALGO_HAMMING; } + } + + switch (chip->ecc.engine_type) { + /* if HW ECC was chosen, setup ecc and oob layout */ + case NAND_ECC_ENGINE_TYPE_ON_HOST: + chip->ecc.read_page = fsl_elbc_read_page; + chip->ecc.write_page = fsl_elbc_write_page; + chip->ecc.write_subpage = fsl_elbc_write_subpage; + mtd_set_ooblayout(mtd, &fsl_elbc_ooblayout_ops); + chip->ecc.size = 512; + chip->ecc.bytes = 3; + chip->ecc.strength = 1; break; - /* if SW ECC was chosen in DT, we do not need to set anything here */ + /* if none or SW ECC was chosen, we do not need to set anything here */ + case NAND_ECC_ENGINE_TYPE_NONE: case NAND_ECC_ENGINE_TYPE_SOFT: + case NAND_ECC_ENGINE_TYPE_ON_DIE: break; - /* should we also implement *_ECC_ENGINE_CONTROLLER to do as above? */ default: return -EINVAL; }