Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10855863rwl; Mon, 2 Jan 2023 09:13:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXs7InnMRFe0K1dmfagRTQSB4Y9jX3paSGDhwUYtngF46vltGbuNBQ193rJGK1OOqm1pFOlY X-Received: by 2002:a17:902:e846:b0:189:f990:24af with SMTP id t6-20020a170902e84600b00189f99024afmr62732543plg.20.1672679615522; Mon, 02 Jan 2023 09:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672679615; cv=none; d=google.com; s=arc-20160816; b=NJOLTdNd6K0C5DEhECgaDBnvCg8oXR1xV3QKPBuFC4IxFRz2/Vx5oUEUtab3rXD8Di v8ZKwECMckaX1axOg2T+HBISoivTQkcLd4XccvrPq1Iwj2oInZsN941uKE8l5RRVXEAf AVwdteisrazwj7Mtbx2+yRsGVAhWgY6EXLMdbDi1gnh2GfNUSfs11QB5ksN95I8kTKOE CRYW3GFaKy47BbLFhfijGGPUKVA5PdqmSsFJzeV6c5hF++N0ytkYJicelPG1zGnnxoYD yCZRW1t1vkab6bfmuknRl1LIfn72BySNgggkAKs+57x4XmKVxdHTzgTitWKbQXrfn4wS n0sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:feedback-id:dkim-signature:dkim-signature; bh=ubVMmek62b2FW/lrihLkt+k98Rt0VqU7QHx3G8jOQhs=; b=kW8u4ZTRpZbQkdigolsOnwqAytILPQTZkt1usufnsHOb1PFYM6zixCJ1jreTUHI8Cp SUgCtbLKideshjuczRoOk6nCxQndilDjg2RJmgaWOgJtYC/3jTmp/vJ26RhAt4JU4Ijz WZGIzt1worILCgQK1str9W0aUUxm4o0qUnpyVxfFt2yAOflgFGSghNIqYE5ZJgwxwIpD leCUugf76+AphVH7A2WkDfiWOmKpXHVCWvby3Qvh+5W49vc/QpQtxqk3F4BehFdqWXpe R/TP1d/I6+m9eNIH41zZMU4BbBPUj2oOkMJlvJ5ia2rLkQvdA9yoAxOqG/kfBTBRNLVu 7wJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=TDLBM0Zl; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=SzUpkNhz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 13-20020a170902c10d00b001869347b0besi28716866pli.174.2023.01.02.09.13.27; Mon, 02 Jan 2023 09:13:35 -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=TDLBM0Zl; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=SzUpkNhz; 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 S236457AbjABRGa (ORCPT + 61 others); Mon, 2 Jan 2023 12:06:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236299AbjABRG1 (ORCPT ); Mon, 2 Jan 2023 12:06:27 -0500 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB8964DB for ; Mon, 2 Jan 2023 09:06:26 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 207E45C0096; Mon, 2 Jan 2023 12:06:23 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 02 Jan 2023 12:06:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:content-type: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=1672679183; x= 1672765583; bh=ubVMmek62b2FW/lrihLkt+k98Rt0VqU7QHx3G8jOQhs=; b=T DLBM0ZlpSQ5f13Md/yEmLhdRczLe83CukeKYPEHYQZQrHnwBes+mVchAGa9A6FfD 1b7PAxouNYAjvWhwLFIXNIzZpa97wBI/6tYKcL592zM0kSINNNexh7qwNAE5VvEU dKEWL82+abmQFj8ysaXF98kBjCiL0sbM9DyYpQsQd8vShzzyTTIFaE7s0RuXhh+b BPWNwWW5yvqX9u/TmqFzFwfnbM4zMF7an1Y5zwI9UfkcJN5D/bNV6aJemREN8/7U WCQ648+RHHIR3kxmgPHs06AWRu9XKHSkmyRImL+s72wZggvzSpQydFoWVKPKJojv jcoyLieHnBpZbp1n5brFQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=1672679183; x= 1672765583; bh=ubVMmek62b2FW/lrihLkt+k98Rt0VqU7QHx3G8jOQhs=; b=S zUpkNhzIQneZi19EAmLimcWQzfkUj8LuN2QZQFec/YH2ig1DXjW7S6X51e+UgAhh XbCRfm4Ia7nb7PgBh95W+tHf1Y5wuIBGU7mcuVNBQjfxIhSLd7NUE6acdYgoYC3O OHk0NXSYPsFYY9SGfe1UVHRz0Wh2gHtIRp9VZcm7/ionYqQHCs9XtguuxAV4Sd8C Z5mM4jwUzuEFN9g/m5X8o8nfKFEFzLk5NbP0Fa6IK/HTVRKrJJLlV7cKBOMhkMMp q+zvYWcaSW2fivGJ9pU4z1uDhENbeQVwczqUE1KgVt+fU3dVASn3PE1gLrShW9j7 uVCV/boYenu4dOHhayJlA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrjedvgdelkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfvvehfhffujggtgfesthekredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepgeeikeeufedvvdeuteeivdeiffdtgfdtfeejgfetfeefgeffgfdv ffehjedvueeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 2 Jan 2023 12:06:21 -0500 (EST) Message-ID: <6940e60e-834d-9cc6-c3b8-657b100ea5db@sholland.org> Date: Mon, 2 Jan 2023 11:06:20 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux ppc64le; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Content-Language: en-US To: Miquel Raynal Cc: Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec , Boris Brezillon , Brian Norris , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev References: <20221229181526.53766-1-samuel@sholland.org> <20221229181526.53766-5-samuel@sholland.org> <20230102101132.66aa1a1d@xps-13> <4207d4eb-31d5-31c0-1a7f-67ec00b63f58@sholland.org> <20230102174517.1ccb3654@xps-13> From: Samuel Holland Subject: Re: [PATCH 4/7] mtd: rawnand: sunxi: Fix ECC strength maximization In-Reply-To: <20230102174517.1ccb3654@xps-13> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: X-Mailing-List: linux-kernel@vger.kernel.org Hi Miquèl, On 1/2/23 10:45, Miquel Raynal wrote: >>>> 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; >>> >>> I'm sorry but I don't think we can make this work. This change would >>> break all existing users... >> >> OK, it is not too much of an issue because I can manually specify the >> ECC parameters in the devicetree. Do you think it makes sense to fix >> this when adding new hardware variants/compatible strings? > > Actually, looking at the code again, I don't get how the above diff > could be valid. The "maximize strength" logic (in which this diff is) > looks for the biggest region to store ECC bytes. These bytes cannot > be stored on the BBM, which "mtd->oobsize - 2" tries to avoid, so we > cannot get rid of this. Right, we cannot overlap the BBM, but the BBM is accounted for in the line below: /* 4 non-ECC bytes are added before each ECC bytes section */ bytes -= 4; Normally those 4 bytes are all free OOB, but for the first ECC step, those are split into 2 free bytes and 2 BBM bytes: /* * The first 2 bytes are used for BB markers, hence we * only have 2 bytes available in the first user data * section. */ if (!section && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) { oobregion->offset = 2; oobregion->length = 2; return 0; } So if we subtract 4 bytes for the each free OOB area, including the first one, and also subtract 2 bytes for the BBM, we are double-counting the BBM. I should have made my commit message clearer. But I am going to drop this patch anyway. Regards, Samuel