From patchwork Thu Dec 29 18:15:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE8D7C4332F for ; Thu, 29 Dec 2022 18:17:33 +0000 (UTC) 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=5bWIdtMJIuXmenCYX59m8OqOlHgZM6e3weG8Rl/IUVk=; b=hE1YHjUam8GDUR PK1nKJubao+bFxgxo5tgIaCmk01GQeO8WgFoiwEOK0mt+sSIpl/uCGt+BiyY7GBxYzyrDDzMLhzDM n6qfaquSzZprt8SZ79An6B5dzdjAclEDEy2pKLKzgevnM06lT9VWpCbI6+mfnMYLFW8/Uma3XcWnU WFKJglrwV33Xd7fUaZ0aEQEZtnezE/OMR7OjbwbInl1d2hFoepuWdrEYkymBtFp00fe1EnFWjfXwE g3ktufOXA1lrqag2Jf2OPkBU2o7D7O0CVeIYI/1utlwcqHbStVG3qwnwpWaRYenT9ufZDXjsZxWb+ 8FIH/SR11P8MnR968DeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRw-000hB2-7c; Thu, 29 Dec 2022 18:16:16 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRF-000gtj-1a; Thu, 29 Dec 2022 18:15:34 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B62D532005C1; Thu, 29 Dec 2022 13:15:31 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 29 Dec 2022 13:15:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337731; x=1672424131; bh=aL V0CF57edhnO+Yi0RAt5gJKhT87LHNREaBPsrajes0=; b=lVS9wWbnizn7DCDLlF kqtb1fNKzGtDRNaw88SgtTv7qoUOabeOED3pTdtOl3EKHB9F+t5v1yVxKtd4MM6y zHOOzbgyw3AzZ2XSnGyE8WHKG/378kYNYjIFDIR7gzNTb/jfows+KKPjyGs/o7EJ 5XHoy+1MxJf4Xr3UgyyonAOoVCjzHvKmUw50B9osRzseWj1S+2zLjWmRfIalvs39 PdYsXt/palbh5QSTlbypCs7Mn1M59ZDaeVxHYtb5lgrA8kprAC4Ed+U6Zk9QFVk2 GnF8LTZTBgtDPifo4vqARHwad5cYV8MIuTI9+4EIKEPDZCM4TLwyjuyo43iGf62V OWNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337731; x=1672424131; bh=aLV0CF57edhnO +Yi0RAt5gJKhT87LHNREaBPsrajes0=; b=I5Fxbe/f1E3aeiherKYnPEQqP5X55 01qxSmqNL41L7LoJehF6WRrFp9hZryspQhILe0KqnniduAoDQf6alzostp9pJEBt NZWBCalt8xrc0OQwZ00fSAp8w+LUErLzJb3tCy+b15suTXDLdVEh5tTkfGNJljRo 60oSUBoMEKugNSgUOkgo/11ksb92SMAhJNR3jOD+mHnO82rY4jdSdc/jiP2DNgOb iy5xrOeuAFkwU6wRg6zmpr4z7MB2R6HEtBMyKiZ+C1dQzBAE7AW4P5IZsusEghBZ h9ubWknVHnWbFFbpBzETvHxHvsLV6PtvhO+CX4UwQcOkYwoSYo72ZO7Og== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:30 -0500 (EST) From: Samuel Holland To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec Cc: Boris Brezillon , Samuel Holland , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 1/7] mtd: rawnand: sunxi: Clean up chips after failed init Date: Thu, 29 Dec 2022 12:15:20 -0600 Message-Id: <20221229181526.53766-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_101533_157770_D33CFA81 X-CRM114-Status: GOOD ( 11.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If a chip fails to initialize, we need to clean up any chips that were already initialized/registered. Fixes: 1fef62c1423b ("mtd: nand: add sunxi NAND flash controller support") Signed-off-by: Samuel Holland --- drivers/mtd/nand/raw/sunxi_nand.c | 39 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index ea953e31933e..2ee86f7b0905 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1950,6 +1950,25 @@ static const struct nand_controller_ops sunxi_nand_controller_ops = { .exec_op = sunxi_nfc_exec_op, }; +static void sunxi_nand_chips_cleanup(struct sunxi_nfc *nfc) +{ + struct sunxi_nand_chip *sunxi_nand; + struct nand_chip *chip; + int ret; + + while (!list_empty(&nfc->chips)) { + sunxi_nand = list_first_entry(&nfc->chips, + struct sunxi_nand_chip, + node); + chip = &sunxi_nand->nand; + ret = mtd_device_unregister(nand_to_mtd(chip)); + WARN_ON(ret); + nand_cleanup(chip); + sunxi_nand_ecc_cleanup(sunxi_nand); + list_del(&sunxi_nand->node); + } +} + static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, struct device_node *np) { @@ -2053,6 +2072,7 @@ static int sunxi_nand_chips_init(struct device *dev, struct sunxi_nfc *nfc) ret = sunxi_nand_chip_init(dev, nfc, nand_np); if (ret) { of_node_put(nand_np); + sunxi_nand_chips_cleanup(nfc); return ret; } } @@ -2060,25 +2080,6 @@ static int sunxi_nand_chips_init(struct device *dev, struct sunxi_nfc *nfc) return 0; } -static void sunxi_nand_chips_cleanup(struct sunxi_nfc *nfc) -{ - struct sunxi_nand_chip *sunxi_nand; - struct nand_chip *chip; - int ret; - - while (!list_empty(&nfc->chips)) { - sunxi_nand = list_first_entry(&nfc->chips, - struct sunxi_nand_chip, - node); - chip = &sunxi_nand->nand; - ret = mtd_device_unregister(nand_to_mtd(chip)); - WARN_ON(ret); - nand_cleanup(chip); - sunxi_nand_ecc_cleanup(sunxi_nand); - list_del(&sunxi_nand->node); - } -} - static int sunxi_nfc_dma_init(struct sunxi_nfc *nfc, struct resource *r) { int ret; From patchwork Thu Dec 29 18:15:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74ED8C4332F for ; Thu, 29 Dec 2022 18:18:07 +0000 (UTC) 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=MFoHNQNMQn2nJQgkK6qBDjGvuEjAhBFWm913E1Yp5p0=; b=qbje9YXwnNjUKD kYaasL+SbhSNLfmKmpi127i17hZ/csNqsnvf/AtGzQqa6DG82gZ6LNBr0PFAzCavdCRC/xWer5dJB tme7/mpI7m21TcEBzlbszObQvRMY5obQmtp8Z4S48lEgSAWMRkvMp9b6sVEW3sjOHWfGU7Ok23Zyh KFaAuGOvE65KZeYfBYREmf1cQsCoc1mzh1RJqYTkUnqL2Fq3Slj5+NPfewYA6fVI05XtLJgKhHZAE pni4QXtoK7bpK2rQudf1D6vBt6x2D0a8Ta8Y2tk/y7Z1v0uTlC8aMefzDT6ngKZ2cxAf3F3TMo3qm ucWFrE/gXKsB+kzjHPXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxSe-000hQS-6O; Thu, 29 Dec 2022 18:17:00 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRH-000gul-Ks; Thu, 29 Dec 2022 18:15:37 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 4F4A332005CA; Thu, 29 Dec 2022 13:15:34 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 29 Dec 2022 13:15:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337733; x=1672424133; bh=3a V9z+StwyUFCb1KZIw5zw5sA5TC8rfeKpSt342iQA4=; b=HCBLmtxDaRLWjQ3PmO RVtpnl8hUWpGTShjJs0fljEtjovO6DS8XAT+6ra5CXO2d1PQnu4ZG7pDuXEMnQOq jyEsK6GyqmPM5XDNG38WWYsnkoGUPRIURz0sOil0hRAzPCWUXzX/6hlQ85JwZ5t/ mUjJpvTmCxCHeN+vkBpMYHiUef7i2qoYl4IKVxmlq3aegGxne6zmiuxB5bf3pgGf WbhzSmW0NemXiv4OsGvPe52s3ByQ9o1Y0FoEZpaWl4VgNVEHHWSv56/Vd8BUgazx RmV3zS2PbTXyKRlY2nQW6eK1kzfwV/nTruunpZj2NmBX1o+CzXXPXA3oxDfWve02 U/Hw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337733; x=1672424133; bh=3aV9z+StwyUFC b1KZIw5zw5sA5TC8rfeKpSt342iQA4=; b=NQsllsGthY0N7C5kKLbuJsdd3tqax BX6Mn48lGvTqhk+9mYSiSLXTkw+2LpYChus4TU6Tdo/UzbMVJ3CsiT4wyMZNLF9W 5jEsCeWmABfvh5MuyJvx6CBA3OzIrXD2XxjSRFcMLNZOVlb5QFIvRrmXWy/Curgc FrSgLVpYiyA1BOHaPIi+P33YTEC84FV8VaBqv6a0UZAzahRliXwPEgCGeJq5jFuA s4TJNEC9JXWc0G33dzgzIZqJc7nkL/o3xu3aA4MYd+mitKpZYtYgn8WtRrStOev9 VSTjJxiBJg4rVTOD1OwU7alPwXVelFYAq8+F+D/cHUi41eSRATBoTKFrw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:33 -0500 (EST) From: Samuel Holland To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec Cc: Boris Brezillon , Samuel Holland , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 2/7] mtd: rawnand: sunxi: Remove an unnecessary check Date: Thu, 29 Dec 2022 12:15:21 -0600 Message-Id: <20221229181526.53766-3-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_101535_780251_AC8ACA9A X-CRM114-Status: GOOD ( 10.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org sunxi_nand->nsels cannot be zero, so the second check implies the first. Signed-off-by: Samuel Holland --- drivers/mtd/nand/raw/sunxi_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 2ee86f7b0905..8b221f9f10a7 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -421,7 +421,7 @@ static void sunxi_nfc_select_chip(struct nand_chip *nand, unsigned int cs) struct sunxi_nand_chip_sel *sel; u32 ctl; - if (cs > 0 && cs >= sunxi_nand->nsels) + if (cs >= sunxi_nand->nsels) return; ctl = readl(nfc->regs + NFC_REG_CTL) & From patchwork Thu Dec 29 18:15:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE9D8C4332F for ; Thu, 29 Dec 2022 18:19:03 +0000 (UTC) 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=5EdKyNvanHTQgRacaSTZOLKEyHUcbQh4BDF8LEOA7zY=; b=hxYF5VohP7osZO xH/5u8097nE1VcisagcBPlWuuYJjKhR1aECG6/yh6NMhJP3+qbD1mtY7+3kgl+ZDmbCxWZMQlGGKk bF9HnlBtv+ObRX2YaEDkD9997gqsSG9hvAaB6nf/pc/lm82CEtwJnbAe5Vbk5srYYV1Yya9Bi/zXc tfiUrgEjx4LYgPTGdD5jPdTPWP3vkDprNPw9os7ck9DoS8IMGC0iQB7Fv3dvWfahCc+wChZOJjTfq lnoh51tKgr2K/iZTDZPMzoOi/8Z6x/1dWI8UaJS4ufCX/1pHKmQDDrQWKZNJZUMKv/mZ81Bnh0aUJ qgOF06Bk0l+6QkdVszOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxTO-000hqk-4u; Thu, 29 Dec 2022 18:17:47 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRK-000gwO-6i; Thu, 29 Dec 2022 18:15:39 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id DC4383200909; Thu, 29 Dec 2022 13:15:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 29 Dec 2022 13:15:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337736; x=1672424136; bh=2t sBIXORATjAZKv1+cfGVeLshq6JEsC7gla2AnZEybo=; b=fh1RYumAS9X7eYRhei C65sJt4y89btRu8tKd7ito5an3dh+TTDfrWQVEoD+4FsRjvfJ02mGnKl5Kh24B55 lHcZe9lk8Md/DMiwOnMgf0c2heXSIz/yNqgKbbqaIxSnpAwASYYIF8WJbveV/ceX nedGcIpbiGKUNHy1sYyQkPA2i40lAaGOESD4hZcDIjZBUmRWiidyzmgcN9iWtlFr J7hd1ry8wVhvnJ2X9gYzUJlJNg++EEKxmNlNtPYqmTouLhIVAo8SNZ06wtal4UpO NwRIUJpRa9ttVaRyi4rTtMxzTrgS998Po6TXN8KNMTN67X0SAXkayOlmqqVsb7U6 BEAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337736; x=1672424136; bh=2tsBIXORATjAZ Kv1+cfGVeLshq6JEsC7gla2AnZEybo=; b=QX397Uypyc5ERHvNfuUiyerBrpDqQ wTIr2Vlf8apX1gSTCsT6fzwkeuXxQnVkyNZwDSwPMyVoXY5eNaF+irs4ja363Ld+ UmfSnSSVeOmlgs8fWHaPkgd78PoSRgIkuI3Js4pwUaTMZrdTYuaCoPsP8qtH9UzZ hViAM8RC2zyDwx3QNOD/Yot8VtdBad3UK8AbQ4CaI0b2ti/12ezjL530fOwIGqRj HV7FKNhdTq3Gce2QrCLP/2DSIBd7CeNa0bAy14cJluBfaRLV84h1BlpA9YqGxrHl wAV8gl1QCQwj1sPuPQBKAmvxQ+2Ezp/pZOAxppeUPsdOQX2+FtSFl2xCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:35 -0500 (EST) From: Samuel Holland To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec Cc: Boris Brezillon , Samuel Holland , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 3/7] mtd: rawnand: sunxi: Remove an unnecessary check Date: Thu, 29 Dec 2022 12:15:22 -0600 Message-Id: <20221229181526.53766-4-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_101538_331321_A4A68067 X-CRM114-Status: UNSURE ( 9.26 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Each chip is required to have a unique CS number ("reg" property) in the range 0-7, so there is no need to separately count the number of chips. Signed-off-by: Samuel Holland --- drivers/mtd/nand/raw/sunxi_nand.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 8b221f9f10a7..1bddeb1be66f 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -2060,14 +2060,8 @@ static int sunxi_nand_chips_init(struct device *dev, struct sunxi_nfc *nfc) { struct device_node *np = dev->of_node; struct device_node *nand_np; - int nchips = of_get_child_count(np); int ret; - if (nchips > 8) { - dev_err(dev, "too many NAND chips: %d (max = 8)\n", nchips); - return -EINVAL; - } - for_each_child_of_node(np, nand_np) { ret = sunxi_nand_chip_init(dev, nfc, nand_np); if (ret) { From patchwork Thu Dec 29 18:15:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDA9FC4332F for ; Thu, 29 Dec 2022 18:20:36 +0000 (UTC) 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=75NtKcwEqeI30CZdGD0lMdlpWsrK1qqrKTh/5qNtLSg=; b=jgCNRWUwUdG03X tN4i8rj1s8MvIm8orNdGQCAPmwcP+iXhtgYruwFqlFcQTRBymET7/K5w5PyMdctIwxSxGY7PmRS6C 3buc834MN+KiQyj/Vv0TLi2s3qeHtvHcZJ8PhHfK+gBoPUpbhLmtmK6copb8Hyfvqtd2U8Rsb1YKC NBtaD9oVAjhaBgUwi7HWiclfce2MMEyIqVpW5d0e/j5lNwqGxs60E6zvB51RNdPfBBiWaAAqjDMz/ tp6LWKcMUvDpRjOpRbZAPpGA3HhDzf5nZ8qL80GonYIC9mLJldv/oWm43+YVSy+tAszon/ClOO5a2 tn9RNqw5AZZpi6M2sOBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxUS-000iPt-D7; Thu, 29 Dec 2022 18:18:52 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRN-000gxd-2e; Thu, 29 Dec 2022 18:15:42 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id B11983200900; Thu, 29 Dec 2022 13:15:39 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 29 Dec 2022 13:15:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337739; x=1672424139; bh=+y owLKRJXG5KC8guU+L3zS9PmXyXPUwHqs5jAcrH1n8=; b=NjMFxRZ+QZD9UGucgT 3k9PuEN2/mDP+IB9eAtBS4ykWeu3aXi6YvfZnOxMtUnM1k7dgBKbNZizRiniCreK mPgqELgFWGEJClE7k5a87NVie2KGW6aAQx40LpRKUqa+kzRcsIBF23tlE774DSi4 cZMcDQqCclZaElXyCMWYL3wVALtaHcsN/YDTCd959c934SQbP4LFWvtyc6oy09Oo v89h0GCKI0H7jlEALyIbgE2JSjFVr0yL7ys6pPfMh9tw81UI3OI9rDhzRttOsqgd sGw4Wre5b8ZronJeofJjKupxEyPgIfYzOiJ7UDD7d+YtSguUM7XH1PGI9S5WF3KP JDnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337739; x=1672424139; bh=+yowLKRJXG5KC 8guU+L3zS9PmXyXPUwHqs5jAcrH1n8=; b=HsRR2B5aqf2cMTQNa8s3obOULDCwU bI7/qnGSV02TRSrCAgVe0N4/6UQ8h4pFful0gd4Wqyeg9+p+huQOvV9XziiHe112 F4xzeVVR2DMMxF6PARc5xNGmRwBpt2y5I1e4ZZPalrc1AtF4ntbp8tZYIx4v2a/e rF7HBzuUW907QMkL+f3PHYX8EYs8HSMl7NZBm89ofI33eD4e7d2Ixi17/i6CwCNQ 3csDvmhGvWlNn+dd0gY1HbSdeZHL7PHak6q8tfoJZvbzrVqRRqA+dX02KXwYR/V+ MDF/WNpCxdZ7JfOTgruRnXw7smsOMFdaIL70xsFVsBEPqqpKVRkixbinQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:38 -0500 (EST) From: Samuel Holland To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec Cc: Boris Brezillon , Samuel Holland , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 4/7] mtd: rawnand: sunxi: Fix ECC strength maximization Date: Thu, 29 Dec 2022 12:15:23 -0600 Message-Id: <20221229181526.53766-5-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_101541_190099_429314F8 X-CRM114-Status: UNSURE ( 9.93 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is already accounted for in the subtraction for OOB, since the BBM overlaps the first OOB dword. With this change, the driver picks the same ECC strength as the vendor driver. Fixes: 4796d8655915 ("mtd: nand: sunxi: Support ECC maximization") Signed-off-by: Samuel Holland --- drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 1bddeb1be66f..1ecf2cee343b 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1643,8 +1643,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ecc->size = 1024; nsectors = mtd->writesize / ecc->size; - /* Reserve 2 bytes for the BBM */ - bytes = (mtd->oobsize - 2) / nsectors; + bytes = mtd->oobsize / nsectors; /* 4 non-ECC bytes are added before each ECC bytes section */ bytes -= 4; From patchwork Thu Dec 29 18:15:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69D1CC4332F for ; Thu, 29 Dec 2022 18:21:59 +0000 (UTC) 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=cFckm9X/xS0Tgz3HoRsaAeLfx/9zqtJow0HGWOHdYag=; b=Hdwo3CGvH823AR dCsTjtGkn+U/PnccfJoDxgL7fNktcvq0FHVZbBNEOMtaQCpzcWZ4/1B7lTHXw0BIrbwHrSYE1s1R6 9pwpYFJtgD23YvgQheqVWCFgKid16i2QlAmGsHa7ViW/iEsBKbNR9qy60xy+kyFoaXhmvvr6hCN+9 rbyn3Je8kkqoQ36brlqexvr07CCVCjmvMqVfed36sBE7KtmWklzjp1e4EbsUYkGg6KsoQNpdNYvrX /e9ebHSMdb3BsgNZT5NceL+FoF0ZyYgUuKeB/+UrdFzce+wFM6x2+nj1IpBeQJ3LPzDEk0BXDt4HT BF/WuowMdJILP64Oq7RQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxWB-000j7y-Lz; Thu, 29 Dec 2022 18:20:42 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRQ-000gzK-JB; Thu, 29 Dec 2022 18:15:46 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 46E033200909; Thu, 29 Dec 2022 13:15:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 29 Dec 2022 13:15:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337741; x=1672424141; bh=pV PQa7Oa9NfFrWw4kM0RTohv+m63gRRiGiW2YrMQGls=; b=T7T2dv2FzNpv6Y1oXC VKoZn8SgpVp7BdsTqlXkXUv5qY/hBC5D3CZl9W4ooEO2TTbdtcMVCl9h+t8DfOjl kHGs0eX+YSAFhbiybAd1wi4dy+2EKQ3+TmJiV1m/hMB7E/mEmoNRqjkprPDuVvbV sAOOUo22SPTyJRJGVTs4Ih1HeK6VA2ZnOlai3givXQDoeZlbimA8nMaYYPS1lBzf LenoTfnBO2Yn0/Umez2HX4QNk6SJ3TuUBCl7WpWh8Nu9BLDr6vmQfzAgs+8B8f0D gSbPcZBmya/vPN/TZg50jhy1XctvhHPehiK3QLpy/KbGy7Ivu6O/fiiJ79zGf4e6 Q6GQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337741; x=1672424141; bh=pVPQa7Oa9NfFr Ww4kM0RTohv+m63gRRiGiW2YrMQGls=; b=rqn5MVdneV1TUbiOZC/jhWTOKZcSB Ru9uu0CwSsZHbzL6UabABW1+oWuwz+awkLUfbI8wG1DixZseEBmIszlAsOBNeJQt +NypcQy+Hv3+tS8vo1X3YFwpQTQDbNegHQMEozKXa5Qcr/GFTG5ABzp0EHDevjYD 9NceDBOPUY2i5Y1VTFSuL9AsLk/J67E+DRSpgDMUdirj248v1AM5BQMRWUqb+GdJ AjciLSO+87PYviJOz4B+djZGKSqIeekBuJToXYQztdvqWkg0GS3RVvGAxDMpgDDm 833MgTiUfDzLuoXj5CgQ/wMK2XIPE+cOed+wqM6KyH6BDgRd+eXclVpLg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:41 -0500 (EST) From: Samuel Holland To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec Cc: Boris Brezillon , Samuel Holland , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 5/7] mtd: rawnand: sunxi: Fix the size of the last OOB region Date: Thu, 29 Dec 2022 12:15:24 -0600 Message-Id: <20221229181526.53766-6-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_101544_696408_8A7CA848 X-CRM114-Status: GOOD ( 11.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The previous code assigned to the wrong structure member. Fixes: c66811e6d350 ("mtd: nand: sunxi: switch to mtd_ooblayout_ops") Signed-off-by: Samuel Holland Acked-By: Dhruva Gole --- drivers/mtd/nand/raw/sunxi_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 1ecf2cee343b..8e873f4fec9a 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1609,7 +1609,7 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section, if (section < ecc->steps) oobregion->length = 4; else - oobregion->offset = mtd->oobsize - oobregion->offset; + oobregion->length = mtd->oobsize - oobregion->offset; return 0; } From patchwork Thu Dec 29 18:15:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97DA7C4167B for ; Thu, 29 Dec 2022 18:24:12 +0000 (UTC) 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=HoQRedGZ/yO3gt97N1SKfYjXa/v4brmgQfXiWBiHIA8=; b=d+/bMJz2e2phx0 Epa0TJcJ9oOMzKoaiTLrxLTWMd6Y7+yv5OQwL/PYSEniUhNNk56YyT7QhB8lp4xPDgcS1MXfWq7Bo eMjFHT7k1NQ0iHNxdsUk6HFun71tvDFI7VaCI4JZ93P2p3Sr+2NHd6QLGZ67oTEYrhljIz2EByKq7 QP4GqCsT9YP4TVWK5MV8vx8dTtpRECDIul5X2V9+0kf/eTfJv4UYI3z2zKX/Uy7vIikbop8uF8xXC B0qgQWtrTZ1yuPszz9TF7Qj8fM5mhc4BWjAmJ0Z5OmEdv7Phzs3jRhTCyUPibnKnWLqpbj1BWJC3S JexdYL4gGLXEoSIUIfgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxY4-000jxc-5a; Thu, 29 Dec 2022 18:22:39 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRT-000h0K-4i; Thu, 29 Dec 2022 18:15:48 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id C78A13200908; Thu, 29 Dec 2022 13:15:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 29 Dec 2022 13:15:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337745; x=1672424145; bh=+9 bUzxjZZvUZxKDoetxLqlF5Y2GGvm4/vcpqx17W7w8=; b=JZtCisfL3NacHn39+p vu2PzPs1eTU7wxsQulhC8spek/2T+EY1IZvc+ZwSNINSFCUVs/52FHONaI4JGvIh SpXIz6y3O2oDrMpIfRPjfchA9XwQnVP4r+FRA3Fzypik0DhSlH2HC0Wpd6MlEkEY GGahWBBo02ZkwtxSma2pt+WdvOp09Bbg4ZwzffkS0229qwAoTM9S1HR7hvL+89gC /LlCnVzSC/DIuh040IkQyoiBdRf+sacFJNrryWmjIybJz9sJzkaPJmBUAHqx574B PQjGCh0ppF8CUgOhVMn1MVUEDwGWJ6GYbuOtkIUDvf8uB7+rh0aB9oED8bPvLHij ySRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337745; x=1672424145; bh=+9bUzxjZZvUZx KDoetxLqlF5Y2GGvm4/vcpqx17W7w8=; b=CL32CpCkwfMFoRvVq27PsDrZo+9wj kTu0i/znVDfPD5jKBz6jMKO84lA2gYR8auy5pf7r/k6pJ6oUNjbPqwslpUTyGFXy HUes1LXluzRe7ZAixBCXH8eKLw6p0MqwOHCRuAdaQH6msr4yJpxbvNG47JkITqjW i8QWansl6wSylP9MJzACigtvxJr2AlfDFtd4QGbk4j7Sd4nM1omfs6q8R8x/pQf4 PlCucH2NTVoZN/mlZU9waD5EGTzXgUwc/LKXfFeE/x9Jiq7lQrY1gtgURRYPdfv8 zN/62pEgNlvM1gU/lzlZO8W3ztGGtwuxDFHcvuoem4GXUhF1diCT3pTfg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:44 -0500 (EST) From: Samuel Holland To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec Cc: Boris Brezillon , Samuel Holland , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 6/7] mtd: rawnand: sunxi: Update OOB layout to match hardware Date: Thu, 29 Dec 2022 12:15:25 -0600 Message-Id: <20221229181526.53766-7-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_101547_344165_77D6462D X-CRM114-Status: GOOD ( 12.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When using the hardware ECC engine, the OOB data is made available in the NFC_REG_USER_DATA registers, one 32-bit word per ECC step. Any additional bytes are only accessible through raw reads and software descrambling. For efficiency, and to match the vendor driver, ignore these extra bytes. Signed-off-by: Samuel Holland --- drivers/mtd/nand/raw/sunxi_nand.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 8e873f4fec9a..a3bc9f7f9e5a 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1604,6 +1604,13 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section, return 0; } + /* + * The controller does not provide access to OOB bytes + * past the end of the ECC data. + */ + if (section == ecc->steps && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) + return -ERANGE; + oobregion->offset = section * (ecc->bytes + 4); if (section < ecc->steps) From patchwork Thu Dec 29 18:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45841C4332F for ; Thu, 29 Dec 2022 18:26:29 +0000 (UTC) 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=qHzx4LLu+M7YHLbQEXnvVQ24w30pCFksAGtbq6SLHFc=; b=xeNIaOoDdS4lBB gjesjWhwRmiUTmUFK4JAwL0lTlWDPY25xr9iYiub8lwnMGUtmgFbiV/MMbRfqw/NQ4p5RqX12qu5F UyntZzZ+d1S922iWMm5j19N8wlYJ01OW2DBaDMOPg9MnUEyaoOe5ZkdrUXnYOyFe4igUr48UAvAHl Ev8QZaBcpvVDXE8mbX8pakJW/AI/05vTK9NcKeAS/7lds4oIduTKXu9Y7JohgXGZn4w1AR4QNxLGm ctqoPiZprUwZSNSdu7a4KzP2kKfFeg3VRpi8UTr9BgwmmeMUKCVAXHB4u2vwk65x0Iz+q7eYSshUD WeUzjfQRZlH/HprtuTrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxa2-000ksB-L2; Thu, 29 Dec 2022 18:24:41 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxRV-000h1o-Ts; Thu, 29 Dec 2022 18:16:02 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 5352A32005C1; Thu, 29 Dec 2022 13:15:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 29 Dec 2022 13:15:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337747; x=1672424147; bh=cc VLhMcmGv5G5PBWQJoQHqPqbnjedt1DR07CNYuDpwA=; b=pimmPEMA0ZTHlPQkRY Sv9T3GMud0xar6KGf7/ExMGEvsE+gkLoPoe+4sOT5HAwQiOtWz+/+71stIsLbidu T2UnPPSI48XL7HI2wP78E4aMCVTT1E0oMRZdEXOU6hQhT/xusKadHyMtHoq3loaV wbC65/uq6HB1jVr9jNabrxHJCvAOzAt6UOobwwTyidvW1C6DNPtKoqoxdCi2uQNU FqbZKGEpO55oWcQzpajYQ5uMBX4o1oHJxdhnXci8eM+/j8IndhN9Za74blRDk99V 4oPeYjF3vrkXrtXcrdhwUQVhMxVTVyU/CbGMpjy+RJNmHxhNf8XHN5bM8odYUj0o zDlA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337747; x=1672424147; bh=ccVLhMcmGv5G5 PBWQJoQHqPqbnjedt1DR07CNYuDpwA=; b=ZV3DQMhC1MDoTmBTQY+7NpGmuviZ3 c5+UXM65FJQmUpmCiQUzGlnk6s0Rspk0pI6/HaBhslmUPi44NCalVr0ER/ghgMpB LdMD79+mVdP1V/z6PFAcEfgLjLrWqvk2QaN0SHIwHT9nzIAk+oQgPsAmldugppma nE8P0L9+IsvCN/UslNnD0IvLwH+gJdLrOH9DGqviA0sOXahmGa4/ljVoJ++9HUsh PfYgBGr/Zvh7JBHTTQL0j+77Kp2SLTQjo3EXfjCM06mhu+OAwko/QzH25Qt6pvLP p1MXecAnMr36wY8NGMFh2f/8VB3JjBUyqxIWHeh8bWHSKNiHbZ2j/BMHA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:47 -0500 (EST) From: Samuel Holland To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec Cc: Boris Brezillon , Samuel Holland , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 7/7] mtd: rawnand: sunxi: Precompute the ECC_CTL register value Date: Thu, 29 Dec 2022 12:15:26 -0600 Message-Id: <20221229181526.53766-8-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_101600_844511_D800EDD7 X-CRM114-Status: GOOD ( 17.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This removes an unnecessary memory allocation, and avoids recomputing the same register value every time ECC is enabled. Signed-off-by: Samuel Holland --- drivers/mtd/nand/raw/sunxi_nand.c | 75 ++++++------------------------- 1 file changed, 13 insertions(+), 62 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index a3bc9f7f9e5a..5c5a567d8870 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -169,22 +169,13 @@ struct sunxi_nand_chip_sel { s8 rb; }; -/** - * struct sunxi_nand_hw_ecc - stores information related to HW ECC support - * - * @mode: the sunxi ECC mode field deduced from ECC requirements - */ -struct sunxi_nand_hw_ecc { - int mode; -}; - /** * struct sunxi_nand_chip - stores NAND chip device related information * * @node: used to store NAND chips into a list * @nand: base NAND chip structure - * @ecc: ECC controller structure * @clk_rate: clk_rate required for this NAND chip + * @ecc_ctl: ECC_CTL register value for this NAND chip * @timing_cfg: TIMING_CFG register value for this NAND chip * @timing_ctl: TIMING_CTL register value for this NAND chip * @nsels: number of CS lines required by the NAND chip @@ -193,8 +184,8 @@ struct sunxi_nand_hw_ecc { struct sunxi_nand_chip { struct list_head node; struct nand_chip nand; - struct sunxi_nand_hw_ecc *ecc; unsigned long clk_rate; + u32 ecc_ctl; u32 timing_cfg; u32 timing_ctl; int nsels; @@ -689,26 +680,15 @@ static void sunxi_nfc_hw_ecc_enable(struct nand_chip *nand) { struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); - u32 ecc_ctl; - - ecc_ctl = readl(nfc->regs + NFC_REG_ECC_CTL); - ecc_ctl &= ~(NFC_ECC_MODE_MSK | NFC_ECC_PIPELINE | - NFC_ECC_BLOCK_SIZE_MSK); - ecc_ctl |= NFC_ECC_EN | NFC_ECC_MODE(sunxi_nand->ecc->mode) | - NFC_ECC_EXCEPTION | NFC_ECC_PIPELINE; - - if (nand->ecc.size == 512) - ecc_ctl |= NFC_ECC_BLOCK_512; - writel(ecc_ctl, nfc->regs + NFC_REG_ECC_CTL); + writel(sunxi_nand->ecc_ctl, nfc->regs + NFC_REG_ECC_CTL); } static void sunxi_nfc_hw_ecc_disable(struct nand_chip *nand) { struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); - writel(readl(nfc->regs + NFC_REG_ECC_CTL) & ~NFC_ECC_EN, - nfc->regs + NFC_REG_ECC_CTL); + writel(0, nfc->regs + NFC_REG_ECC_CTL); } static inline void sunxi_nfc_user_data_to_buf(u32 user_data, u8 *buf) @@ -1626,11 +1606,6 @@ static const struct mtd_ooblayout_ops sunxi_nand_ooblayout_ops = { .free = sunxi_nand_ooblayout_free, }; -static void sunxi_nand_hw_ecc_ctrl_cleanup(struct sunxi_nand_chip *sunxi_nand) -{ - kfree(sunxi_nand->ecc); -} - static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, struct nand_ecc_ctrl *ecc, struct device_node *np) @@ -1641,7 +1616,6 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, struct mtd_info *mtd = nand_to_mtd(nand); struct nand_device *nanddev = mtd_to_nanddev(mtd); int nsectors; - int ret; int i; if (nanddev->ecc.user_conf.flags & NAND_ECC_MAXIMIZE_STRENGTH) { @@ -1675,10 +1649,6 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, if (ecc->size != 512 && ecc->size != 1024) return -EINVAL; - sunxi_nand->ecc = kzalloc(sizeof(*sunxi_nand->ecc), GFP_KERNEL); - if (!sunxi_nand->ecc) - return -ENOMEM; - /* Prefer 1k ECC chunk over 512 ones */ if (ecc->size == 512 && mtd->writesize > 512) { ecc->size = 1024; @@ -1699,12 +1669,9 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, if (i >= ARRAY_SIZE(strengths)) { dev_err(nfc->dev, "unsupported strength\n"); - ret = -ENOTSUPP; - goto err; + return -ENOTSUPP; } - sunxi_nand->ecc->mode = i; - /* HW ECC always request ECC bytes for 1024 bytes blocks */ ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * 1024), 8); @@ -1713,10 +1680,14 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, nsectors = mtd->writesize / ecc->size; - if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) { - ret = -EINVAL; - goto err; - } + if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) + return -EINVAL; + + sunxi_nand->ecc_ctl = NFC_ECC_MODE(i) | NFC_ECC_EXCEPTION | + NFC_ECC_PIPELINE | NFC_ECC_EN; + + if (ecc->size == 512) + sunxi_nand->ecc_ctl |= NFC_ECC_BLOCK_512; ecc->read_oob = sunxi_nfc_hw_ecc_read_oob; ecc->write_oob = sunxi_nfc_hw_ecc_write_oob; @@ -1739,25 +1710,6 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ecc->write_oob_raw = nand_write_oob_std; return 0; - -err: - kfree(sunxi_nand->ecc); - - return ret; -} - -static void sunxi_nand_ecc_cleanup(struct sunxi_nand_chip *sunxi_nand) -{ - struct nand_ecc_ctrl *ecc = &sunxi_nand->nand.ecc; - - switch (ecc->engine_type) { - case NAND_ECC_ENGINE_TYPE_ON_HOST: - sunxi_nand_hw_ecc_ctrl_cleanup(sunxi_nand); - break; - case NAND_ECC_ENGINE_TYPE_NONE: - default: - break; - } } static int sunxi_nand_attach_chip(struct nand_chip *nand) @@ -1970,7 +1922,6 @@ static void sunxi_nand_chips_cleanup(struct sunxi_nfc *nfc) ret = mtd_device_unregister(nand_to_mtd(chip)); WARN_ON(ret); nand_cleanup(chip); - sunxi_nand_ecc_cleanup(sunxi_nand); list_del(&sunxi_nand->node); } }