From patchwork Sun Sep 13 04:05:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3303 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 204071C2CE2 for ; Sun, 13 Sep 2026 06:11:16 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-25852-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-25852-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 9B6EC3E701 for ; Sun, 13 Sep 2026 04:05:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92420393DE2; Sun, 13 Sep 2026 04:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="elavoB/a" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 658F1390610 for ; Sun, 13 Sep 2026 04:05:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789272329; cv=none; b=taYurhwQ/q3H8yxH1sNBddtfuayXu0ev4usak5cn9SNlQb/c+KJ9K6SstZB++xoyftJ1/5JUfX799rESrimFnaxPmhvfmoRdf93bgskXjmIGltbPonLYaKKC0+mQuEFxfWyeTXp+LYNXR8MvH8W2Z3FFnWGq9PX6YCUkiMRYGfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789272329; c=relaxed/simple; bh=z2BPI/pmixq5cvuOueHRhY4+nASimyd7pRom7zs4YWM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hztKR4nB8p16WJ2RH9yP0W6luKF3+CuWGWkcDe+zjYdSliDrGhS67lmtYTkFOHvsJXe198RfkizBJUAwwnoYR2sop1tnT1k+2HZl0vMzWtGWgDm3bkMhsbNosgBbqvmbYskPtohPwlRO+9JdxPDzLg9YgqXvkmGyuAQQAzwxXPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=elavoB/a; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-4c3eeefdf2bso2093890b6e.1 for ; Sat, 12 Sep 2026 21:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789272326; x=1789877126; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4QAhKpDJSEoLKbSmhwyQO7+fj2kwJfhM4m0kCMZtpNg=; b=elavoB/aHDOTrYHjnJ+WZumbOV+J4O7dsh7oMdnaF5LjdPUW88ydIOhAmoi+X+G/XB k69v+aBXAiyRCT7aBntSLay6vbf/Q0C+RlAMuQpOsLzQdniNDhhoj49LF76tL9Jamm8W 8wxa+l9SZPYZxqXpvvu3nBgeRxy98yy5BXg+wWWeOgpA2+P+KTaEkPLb8OqNOCMPwwX2 m+4jL+Wlz880OQJBJblZkrW7yqhwmwrqOycSR9xu1U2rSM+he9nYSulYugldOB9kZMg4 VqCk4HL4qzk9gBuh962n75NtXTFaqMu7mrsCRYE62DFPNVMGEBgiKVxSOG/SZN2KNooi enBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789272326; x=1789877126; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4QAhKpDJSEoLKbSmhwyQO7+fj2kwJfhM4m0kCMZtpNg=; b=UMYk58qwI+i9Ew3I8Wv1gfn1LWW3KfaYQK5W1EWhRW506HSaEC6CpudHhf+SnVhHdu lSfuZxxk3kzxEC4VzCGWSdVvr3kn6pQ4Te2oOZ5zIH0M7X3VFUmu5zGOrjU6pfSmFpJU YQQkekk/gx+vAncfMzucYZuFC5yXyDd8Qd+SmIOecOAj4ggxQZydU9auoDeVSsat3rYL C+LD5HLO0eI4VLjEQxBH/QOqU8yc2Ag+b46QYLGlyzO30H3CJBNvGIIwBL8aTo/JLK4f g6snXkSZVu/91htRPU48Mds6r1+dHO+Pr8r9kMzM3sSDTvcTlJQL2UK+BR5QpbFL2/+Q Z9uw== X-Forwarded-Encrypted: i=1; AKwUvBygtDmmdkdXGB736m0iTpovYkjH/etmN3CHiGiEs+k2I9keQzgu6BcwCLX3xgd/odlb1AiqW8bx60XAMw==@lists.linux.dev X-Gm-Message-State: AFuF++k29eEuquzu33PFrdnXCEmuSHhb6iHKiGNHnkRLMq7+awwYx4i3 yEEwX8IynjFM23XQMwunPQoDi0liUjaE5sYCJzI90XJJ2qaAEGy+PD42 X-Gm-Gg: AYBFou2KT2mXEiw01mV4sXF6HiBl3jkiX4SAqcHWn72rPHXOm3fy2tJPLmrfQkFe0hx RjXCG+SG5NnczZApuO85SSIdUCbw0P6lPPvYN0tQHxJjT67yqvjK4b3OWzVe7pyWNzYpOhk15NZ E6NlVUz8o3PT5Eis7+7kJ+48xEbnzsqrRHq32TkZ/SVzPB+kiP/oBQS0lhkvU72nXU1Lekl9S0W yar+7W5aBdnu5SIUPeDqfiqxiXyWfb7PuBq55pSIaaEjTmOADUvc0bA/ae49InKq7BWy1veYti7 +mfp9BuBaxjJEIDgR+8qiBSEsYejnMzIJAy/ybbzmi9fEqJ9ARqGXo5FKDfHP2z4JPb8YtWZEnq gYaRkOrPcYLrJiHP9UmL4akXsGCxnZcPi3L7R7D3O4+5NbMaqBl1QnXNHn4AzURhIwiBWzLzWQS Id7k0TUuJn5OMVOxGWKe8FdPwFbq5Z9xC/O1WKMr3KnfSpKv2rCewonj8XAK+JL6eMcZOTDO7Lo g0k88pJDZtVH+gV+z/NbWYGZPD3wucBnG0xnutVm9e6EvwgnGmoP4GNOFfLNU20+AdWHkPzpEDx NOf62etCvMq5wq3uSQpK1X3urL8mBq13hq6xOEz9OuXAZTC2pNQLs7eUey+0mkuXM9UGO3+0FDF AJuaWfzHYFzTIoyX/ynbFCaB1KeusQQ== X-Received: by 2002:a05:6871:4082:b0:479:a30d:60e5 with SMTP id 586e51a60fabf-47deb6b21a2mr8028318fac.37.1789272326342; Sat, 12 Sep 2026 21:05:26 -0700 (PDT) Received: from [127.0.1.1] (184-96-157-145.hlrn.qwest.net. [184.96.157.145]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-47df8699647sm6011535fac.5.2026.09.12.21.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2026 21:05:26 -0700 (PDT) From: James Hilliard Date: Sat, 12 Sep 2026 22:05:04 -0600 Subject: [PATCH v4 13/17] mtd: rawnand: sunxi: combine contiguous unprotected OOB reads Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260912-submit-sunxi-nand-vendor-oob-layout-v1-v4-13-4a64bed94229@gmail.com> References: <20260912-submit-sunxi-nand-vendor-oob-layout-v1-v4-0-4a64bed94229@gmail.com> In-Reply-To: <20260912-submit-sunxi-nand-vendor-oob-layout-v1-v4-0-4a64bed94229@gmail.com> To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Ripard , Richard Genoud , Masahiro Yamada , Boris Brezillon , Brian Norris Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.16 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; FREEMAIL_CC(0.00)[lists.infradead.org,vger.kernel.org,lists.linux.dev,gmail.com]; FORGED_SENDER_MAILLIST(0.00)[]; RCPT_COUNT_TWELVE(0.00)[20]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[dt]; PRECEDENCE_BULK(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; TAGGED_FROM(0.00)[bounces-25852-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FREEMAIL_TO(0.00)[bootlin.com,nod.at,ti.com,kernel.org,gmail.com,sholland.org,socionext.com]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 204071C2CE2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The randomized-format OOB reader fetches each parity region and the unprotected tail separately. H6/H616 pack protected user data before the first ECC step, leaving a contiguous range of parity bytes and tail data. Combine adjacent parity regions without crossing protected user data, and include the tail in the final transfer. Keep software de-randomization separate so each ECC step and the tail retain their existing seed phases and PIO/DMA representations. The NAND operation parser splits transfers which exceed the controller SRAM size. This reduces column commands for OOB reads without changing erased-page classification, data-only reads or the plain-marker paths. Signed-off-by: James Hilliard --- drivers/mtd/nand/raw/sunxi_nand.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 97a4b4470dad..5fba3c111a4b 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1424,15 +1424,28 @@ static int sunxi_nfc_hw_ecc_read_unprotected_oob(struct nand_chip *nand, int ret, i; for (i = 0; i < ecc->steps; i++) { - len = sunxi_nfc_user_data_sz(sunxi_nand, i); off = sunxi_get_ecc_offset(sunxi_nand, ecc, i); + len = ecc->bytes; + /* Keep decoded user data, but combine adjacent parity regions. */ + while (i + 1 < ecc->steps && + !sunxi_nfc_user_data_sz(sunxi_nand, i + 1)) { + len += ecc->bytes; + i++; + } + if (i + 1 == ecc->steps) + len = mtd->oobsize - off; + ret = nand_change_read_column_op(nand, mtd->writesize + off, - nand->oob_poi + off, - ecc->bytes, false); + nand->oob_poi + off, len, false); if (ret) return ret; - /* Preserve each path's normal representation of ECC bytes. */ - if (!dma) { + } + + /* Preserve each path's normal representation of ECC bytes. */ + if (!dma) { + for (i = 0; i < ecc->steps; i++) { + len = sunxi_nfc_user_data_sz(sunxi_nand, i); + off = sunxi_get_ecc_offset(sunxi_nand, ecc, i); state = sunxi_nfc_randomizer_state(nand, page, true); state = sunxi_nfc_randomizer_step(state, len * 8 + 15); sunxi_nfc_randomize_buf(state, nand->oob_poi + off, @@ -1443,10 +1456,6 @@ static int sunxi_nfc_hw_ecc_read_unprotected_oob(struct nand_chip *nand, off = sunxi_get_oob_offset(sunxi_nand, ecc, ecc->steps); len = mtd->oobsize - off; if (len) { - ret = nand_change_read_column_op(nand, mtd->writesize + off, - nand->oob_poi + off, len, false); - if (ret) - return ret; /* The unprotected tail uses the page seed and its 15-bit advance. */ state = sunxi_nfc_randomizer_state(nand, page, false); state = sunxi_nfc_randomizer_step(state, 15);