Message ID | 20221229181526.53766-7-samuel@sholland.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2530100wrt; Thu, 29 Dec 2022 10:17:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGy03TnrRNoyf9X3I/4/HC2OtEXEaMOX8XPI0pqu1KpuXYrxouSkQK2K/pTJCWsMI96vdY X-Received: by 2002:a17:90a:a012:b0:219:5888:3ecc with SMTP id q18-20020a17090aa01200b0021958883eccmr32115979pjp.8.1672337839198; Thu, 29 Dec 2022 10:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672337839; cv=none; d=google.com; s=arc-20160816; b=w4jLy4Xo3IhQ1KwP7xz4LUevs46DJ+XJ1JXbkvA8g5gqY47ZgQeI49WvOXgrL/CmyE 3jSxp4uejhtr2DW0+2mZ/OagLYOdq1Jic/XtaRdU8PXH1rpSHyTYgqyQqwUvin2IivbG WqG5xndfcTUHo7dME+mJrmtmspxVuWHQfi6Y8m3tQwzLdiJL1rnzLJaoP8UK4TfSV/J2 bdN1C6BOoAna9bWyrETdooIgn+Xy/QWrr44z7TlImzXuk9rs1anpd3CYqypTuMzXwVTl /SYsW1FcE8KirqP+mR7uIwADZgWFr3SJGK2P+hreprLDbWRSnKymVPvirtyZgmEfJwx2 bPJw== 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 :feedback-id:dkim-signature:dkim-signature; bh=+9bUzxjZZvUZxKDoetxLqlF5Y2GGvm4/vcpqx17W7w8=; b=c0swUmoIkQCiqpLPgbS1GGnr+pE/alD9bLkVLvDxEPqaU1ALQgzRmpAU0XbrBvQ/EO Y16RZoOE5tm1MOQXnoitPKALK8T9jo3wLQsD484pysXcLGsW4M08xFThlmKYk587b2aD s4LSexm5kzCnwf8zGuzKh5ZgehzeHUTdUK1qqhm8Pot2V9yZcWS8fMP2n1n7qzRvlvGH 48Qk3glAXZhSx0ssrEqiDXRn63tzV3RDfRYIc/8t/gHxgFVtJ9Yha7N7FGFOqs7hOpCr PNseKPdbH4DfB9NZ+4p9zkE8j/68R0Kii25KUCI16VrEaiGFk8pIMUgizpkt/wyt9Xx5 bsdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=JZtCisfL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=CL32CpCk; 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=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc15-20020a17090b1c0f00b0022638d96fccsi1283754pjb.11.2022.12.29.10.17.07; Thu, 29 Dec 2022 10:17:19 -0800 (PST) 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=@sholland.org header.s=fm3 header.b=JZtCisfL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=CL32CpCk; 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=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233997AbiL2SQI (ORCPT <rfc822;eddaouddi.ayoub@gmail.com> + 99 others); Thu, 29 Dec 2022 13:16:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233915AbiL2SPz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Dec 2022 13:15:55 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19777DFA8 for <linux-kernel@vger.kernel.org>; Thu, 29 Dec 2022 10:15:47 -0800 (PST) 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: <xms:UdmtY6x9b-55UlUBvzP6Un47_qYffyaJ9mRQEY9OxCgXrkzuGtIG1w> <xme:UdmtY2Qm5_orAnhrTcuzBEoJVP0Rg1KP8j4RQAKDKcP9tJCyTKdv5dORgNEBhdfx4 f0WHfy57Ulgro6etw> X-ME-Received: <xmr:UdmtY8WIeZSJYRGbmyWzqPkGlQFWo6jwEQSXRNhnZQZ0fQjLOY_S-ZSY4eK3oLiA8H7arpsmfSwdvzBxhOfnQdN1Qmh7VCO17VgNyiNawb4fsM1bzZemAJKSsXczU2dD3TL8iw> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: <xmx:UdmtYwimH5l_E3jhm33R9oQDPij5QPt32GrDx_TGy9WewPfgrTQPtA> <xmx:UdmtY8ClSN2qg_0Gqqgj0cvLVzEX5VaHMR4UGiIV-CJ9baKjjtWrxw> <xmx:UdmtYxKvv0pOBhhI6O-gvQ4Cv7i7OzMNqkQGt-qbij5eL-CiefBOnQ> <xmx:UdmtYw4oJGxu7iekD3QONDx7AQNG-r7WzxxSIPGSY_ahepSsILFEjA> Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:44 -0500 (EST) From: Samuel Holland <samuel@sholland.org> To: Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com> Cc: Boris Brezillon <bbrezillon@kernel.org>, Samuel Holland <samuel@sholland.org>, Brian Norris <computersforpeace@gmail.com>, 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753573322302877476?= X-GMAIL-MSGID: =?utf-8?q?1753573322302877476?= |
Series |
mtd: rawnand: sunxi: Bug fixes and cleanup
|
|
Commit Message
Samuel Holland
Dec. 29, 2022, 6:15 p.m. UTC
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 <samuel@sholland.org>
---
drivers/mtd/nand/raw/sunxi_nand.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
Hi Samuel, samuel@sholland.org wrote on Thu, 29 Dec 2022 12:15:25 -0600: > 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 <samuel@sholland.org> > --- > > 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; Again, I am sorry but I cannot take this change, it would typically break jffs2 users (if any?) :( > oobregion->offset = section * (ecc->bytes + 4); > > if (section < ecc->steps) Thanks, Miquèl
Hi Miquèl, On 1/2/23 03:21, Miquel Raynal wrote: > Hi Samuel, > > samuel@sholland.org wrote on Thu, 29 Dec 2022 12:15:25 -0600: > >> 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 <samuel@sholland.org> >> --- >> >> 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; > > Again, I am sorry but I cannot take this change, it would typically > break jffs2 users (if any?) :( Considering the bug I fixed in the previous patch, and the fact that mtd_ooblayout_free() zeroes out the structure before calling the .free callback, that region was being reported with a length of zero already. So I don't think anyone could have been using those bytes anyway. I am looking for a solution here because the ECC/scrambling engine really provides no way to access these bytes. Reading them requires turning off the ECC engine, performing another read command, and then descrambling in software. So we are sort of lying when we claim those bytes are available with hardware ECC enabled. If this change cannot be made as-is, is there any way the user could opt in to the new layout, to get the improved performance? Regards, Samuel >> oobregion->offset = section * (ecc->bytes + 4); >> >> if (section < ecc->steps) > > > Thanks, > Miquèl
Hi Samuel, samuel@sholland.org wrote on Mon, 2 Jan 2023 10:26:48 -0600: > Hi Miquèl, > > On 1/2/23 03:21, Miquel Raynal wrote: > > Hi Samuel, > > > > samuel@sholland.org wrote on Thu, 29 Dec 2022 12:15:25 -0600: > > > >> 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 <samuel@sholland.org> > >> --- > >> > >> 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; > > > > Again, I am sorry but I cannot take this change, it would typically > > break jffs2 users (if any?) :( > > Considering the bug I fixed in the previous patch, and the fact that > mtd_ooblayout_free() zeroes out the structure before calling the .free > callback, that region was being reported with a length of zero already. > So I don't think anyone could have been using those bytes anyway. > > I am looking for a solution here because the ECC/scrambling engine > really provides no way to access these bytes. Reading them requires > turning off the ECC engine, performing another read command, and then > descrambling in software. So we are sort of lying when we claim those > bytes are available with hardware ECC enabled. > > If this change cannot be made as-is, is there any way the user could opt > in to the new layout, to get the improved performance? Actually that's true, you fixed the reporting of the free area which was set to 0 until then, which means there cannot be any upstream user. So knowing that, preventing the accesses to the end of the area seems acceptable when using HW ECC. Please mention it in the commit log. Thanks, Miquèl
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)