From patchwork Tue Apr 12 02:52:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Xu X-Patchwork-Id: 1616035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=rvKw89U7; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=eGFSdEGA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kcr034zGxz9sBy for ; Tue, 12 Apr 2022 12:53:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e/YyRCeDlFeJgk4gLazkqQOOOfAk5notKjLdboVU34A=; b=rvKw89U7x8lhW7 yRBoYdfkjMySTgibUhYSLPAAa3goWC1yQsH6cVGdfXezIj2/2jGo+EvkubkCiKEggeRupNPC1ooWp yJ+X1yTdF3EOOACil/P8BxC/I+4eoQypAnv8gcCCYf0PSY/lwj1L1iiVLR/o8BDohrcqObSE8f+w2 zf4kZrl5AtIz+3yVHd8vdASh1r6wknOyywXksZWRcIiDWrIDWPiWUvIVAMbs4i+x85bLzvypRe6oQ VCqEMOURlJd1WAq5N9b8rXUTMtI1XHvvo0RinpxTIffjc1YcecL1z0RQ5JeHVnZVPDbgU2x7kfnzi FlgVge9QXbgE/1Dg2/bA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ne6eb-00BLSh-5V; Tue, 12 Apr 2022 02:53:17 +0000 Received: from mail-am6eur05on20607.outbound.protection.outlook.com ([2a01:111:f400:7e1b::607] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ne6eV-00BLRL-Uf for linux-mtd@lists.infradead.org; Tue, 12 Apr 2022 02:53:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B63Qm7B5f9zMKIOLLCJnQguu2paGH7ghBv08fud6BBNXNOTqyYQG32Ypw8+znrSTYcFZrW/UNElCbsslauR95/yBcHTUB4t78u/Ay1COsBQ9VOCl1RbuKMIBN4kPr5QuHvb6F/zXax48YfkgbPRYNQmHrxMJ+R5GhmEQXyMbhuLqnjjS1a2fF+kQhhA+MYkLJNgVWRxWSxZx7fafPEDRg2kKM8z90nziCbEt3l7vQ5fp+alnAhoys07mFWB7A54qSNZ4kAoZ1TnSp/CucpLcqHCyqOiyX8gSV099M9ReaGmFHfarFLvtEXsuTJjaYXJs4f3ZUGJIsgKPYb0ifstQdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DslrKGcn9zxlSU2fnen8v1GasJH1zDIgTD3Vicc06lw=; b=SdzS3Q2j3W8FjD8glNrO7Minx18opdLAAYSd0JMWPwa/OfHb7C/9WSav4IlieCSagDQPDnN+pwcJVfYsAZuzOvSusAgVjyF3PcyYc3m4MZKjs2sZhguSyqtb/5iiqKEXS3XfEp/CV6Yva8bCwpk6itFi9FjqYjnZjYB5RZqGJlzkcQUlQ+WSuSpEvJ/JvTdv0whEQqyAjkGmvzbobvvufaGl7Vj8eFqhCpwHr+do5l7h5/d4ZL1tpL4VVKFjVYxXn0d8tmPS7gMwijw/neysSaTQLpCRwXcLPFycWhoMPkHBh4Q9Tb02SQ2Z4XBqzPGYzDHrKqanuKIQfZryc9LbNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DslrKGcn9zxlSU2fnen8v1GasJH1zDIgTD3Vicc06lw=; b=eGFSdEGAPhFud3rQrYKseLtQI22uzQh76vhNOZCRvWUPMXWExTFkX60IhRPyg/ktDoNIo6nUll7qA5Yr8JIeJscF6B3qaNObATaq7M8k+0+c/nqdXbanlQEy35y/9jUtqjRk12fZC6EhlnxSuZmOwoLCLIYooN/A5Z5Dq8Txmx0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8774.eurprd04.prod.outlook.com (2603:10a6:10:2e1::21) by VI1PR04MB3229.eurprd04.prod.outlook.com (2603:10a6:802:e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.30; Tue, 12 Apr 2022 02:53:06 +0000 Received: from DU2PR04MB8774.eurprd04.prod.outlook.com ([fe80::644f:b22f:2f4:d69d]) by DU2PR04MB8774.eurprd04.prod.outlook.com ([fe80::644f:b22f:2f4:d69d%3]) with mapi id 15.20.5144.030; Tue, 12 Apr 2022 02:53:06 +0000 From: Han Xu To: sean@geanix.com, frieder.schrempf@kontron.de, festevam@gmail.com Cc: ye.li@nxp.com, peng.fan@nxp.com, han.xu@nxp.com, miquel.raynal@bootlin.com, linux-mtd@lists.infradead.org Subject: [PATCH v4 1/5] mtd: rawnand: gpmi: Refactor bch geometry settings function Date: Mon, 11 Apr 2022 21:52:42 -0500 Message-Id: <20220412025246.24269-2-han.xu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220412025246.24269-1-han.xu@nxp.com> References: <20220412025246.24269-1-han.xu@nxp.com> X-ClientProxiedBy: BYAPR05CA0016.namprd05.prod.outlook.com (2603:10b6:a03:c0::29) To DU2PR04MB8774.eurprd04.prod.outlook.com (2603:10a6:10:2e1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce91f19e-6238-4e81-0f26-08da1c2f9204 X-MS-TrafficTypeDiagnostic: VI1PR04MB3229:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mHj3TWOdQspsnHfchEqDIrJYUYQkeeQNIJfqFcD4qmyPGW7Q6YKpkL+/bjfbznP3snjWo2NB/Qp/9/o2sR9sEASu0qRSxx7cWy46PM1+g47upembr36fI53/iov3qESEOvNlhpjm/+0SXR8+XUoB2G1qxrDbr8y6bN39Fmqnsj8/bojBCzgESDhFzeyRW3S4Qb8HwX5xBSsWsZYnkCm33W6Z1dFJVPOiHKFG4S5GGtgFNWxMGrB3jj8LllkjTFt3OFhwfwvDGNKAwc6Tx6qxraWvHBrKQwYjH4dcbC3YrDk8PtJgYMJ95IfPusx4xNzfPQA77Lpra5MINneYhaciwgF8sJ7DjYUzvz3WYBx36SzjaE7jFU/5saKHQuQa6ITla7LnDf8ETmxoaAvT/4nv6pczpioxCvkUEhA8S0bC8wgY6As0n0UdeeEfDfJ4+J6aNzXS1TTXk+76uoFJi2UeSfNFTDDdYo+/fS2afIQifuAaVna2wzmT/41c9aJBPo2TMLIaIBlUqLTINyKgvnrL6E1M5p1t1AaBA5JmrkYDOG9eHHIdybmf7Kr/77dSwGUcPumG5sbmVZyYanfcE1425jZpL3ImFWR9dlVuYe/5HAp5R7iI1lrfl+NY9w760CF9iFeVIFymhMl/ktoDGs1WCAO+5NpEcZc8n2kOb9bIeQjvxZoj51Hx+oaQbQvj6ksc/Qs0gDBHFHMvZ8tyboxrgg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8774.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(26005)(186003)(6666004)(2906002)(5660300002)(6512007)(44832011)(316002)(2616005)(66476007)(66946007)(6506007)(66556008)(8676002)(6486002)(8936002)(1076003)(4326008)(38100700002)(38350700002)(36756003)(52116002)(83380400001)(508600001)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GwWEwqEZgT7pv6fhJKe5R8YmOTar0j5Jb5agVoD27kF98dlgLEXallHZNVOqhOUEvtDv9wW3csQBKRO3gc2ntQ7J08mjGoLIKi+ymEWjDHDqTyosSQ955M0LmkwOh+WjVKqVNEaAGSqm5w6N8C9ka7oiWWabOJ88arKyBwoPLx70h/M9dpZbxlwQ0SqqAyyndRF+WD8xg6jPqTHqdPo+qegvCKAJgYt0X86Uk+MEy8bQ+vuJHla/jh4w6pLAJNLsuLzEv4C8c4Lbzwh09Kv0eSjI1naG91yCmK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Gp2gl4+Rmh7rix9kFQC3CelBs+ENWik9JvWFQC40FNh24ZJOvtSQt7AIuiQWeJnqjUjmiJJdNhoN7wmjYetZFm9Bvppux7o6dROKR+4alPfmiXmf77wbK7jZMTQnUJRHSPVGrYwFCmhPcntuyrdXp9VLBaup7Gc93i5YbKZ5+o5kaQk/7bH8tgulQZxe2r2KEcxvbRvjqGWrypSkrSJXTvIjaTnqdefGzlHMgFTw0AgMNDkWcM9cHz/87S/sbX6xj6yibBrxIP0LinlOf1UTYAlu4vWTlEG2q5Srk/xzC58G+44oGK4mSFeOYJqoR7EcKy3RMjPdMMyFE+yDBx0TjMBAXd8g4WlPE48Cu5ya+WEe0bnpVPL+XYrwaw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce91f19e-6238-4e81-0f26-08da1c2f9204 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8774.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2022 02:53:06.7158 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GH3Ow6/1rGvfmW6YQYtoUfa3aUphYiFcMe8na9OTo5dAqUEMTJGXXB0w9jhCRAOa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3229 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220411_195312_008097_F595593D X-CRM114-Status: GOOD ( 21.89 ) X-Spam-Score: 0.8 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The code change refactor the bch geometry setting function, which doesn't change the default behavior, while user may choose to use chips required minimum ecc strength by DT flag "fsl,use-minimum-ecc" [...] Content analysis details: (0.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a01:111:f400:7e1b:0:0:0:607 listed in] [list.dnswl.org] 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 1.0 FORGED_SPF_HELO No description available. X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The code change refactor the bch geometry setting function, which doesn't change the default behavior, while user may choose to use chips required minimum ecc strength by DT flag "fsl,use-minimum-ecc". The default way to set bch geometry need to set the data chunk size(step_size) larger than oob size to make sure BBM locates in data chunk, then set the maximum ecc strength oob can hold. It always use unbalanced ECC layout, which ecc0 will cover both meta and data0 chunk. But the default bch setting is deprecated for large oobsize NAND (oobsize >1KB), so in the patch set, there is a split commit that introduces a new way to set bch geometry for large oob size NAND. For all other cases,set the bch geometry by chip required strength and step size, which uses the minimum ecc strength chip required. It can be explicitly enabled by DT flag "fsl,use-minimum-ecc", but need to be en/disabled in both u-boot and kernel at the same time. Signed-off-by: Han Xu Tested-by: Sean Nyekjaer --- Changes since v3: - don't use the term legacy in commit log - mention the split commit for large oob NAND Changes since v2: - split the ecc check to a single patch Changes since v1: - split the patch to two parts - change the commit log - add test tag --- --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 44b14c9dc9a7..66ebd569858d 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -514,24 +514,32 @@ static int legacy_set_geometry(struct gpmi_nand_data *this) static int common_nfc_set_geometry(struct gpmi_nand_data *this) { struct nand_chip *chip = &this->nand; + struct mtd_info *mtd = nand_to_mtd(&this->nand); const struct nand_ecc_props *requirements = nanddev_get_ecc_requirements(&chip->base); + bool use_minimun_ecc; + int err; - if (chip->ecc.strength > 0 && chip->ecc.size > 0) - return set_geometry_by_ecc_info(this, chip->ecc.strength, - chip->ecc.size); - - if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) - || legacy_set_geometry(this)) { - if (!(requirements->strength > 0 && requirements->step_size > 0)) - return -EINVAL; + use_minimun_ecc = of_property_read_bool(this->dev->of_node, + "fsl,use-minimum-ecc"); - return set_geometry_by_ecc_info(this, - requirements->strength, - requirements->step_size); + /* use legacy bch geometry settings by default*/ + if ((!use_minimun_ecc && mtd->oobsize < 1024) || + !(requirements->strength > 0 && requirements->step_size > 0)) { + dev_dbg(this->dev, "use legacy bch geometry\n"); + err = legacy_set_geometry(this); + if (!err) + return 0; } - return 0; + /* otherwise use the minimum ecc nand chip required */ + dev_dbg(this->dev, "use minimum ecc bch geometry\n"); + err = set_geometry_by_ecc_info(this, requirements->strength, + requirements->step_size); + if (err) + dev_err(this->dev, "none of the bch geometry setting works\n"); + + return err; } /* Configures the geometry for BCH. */