From patchwork Wed Sep 9 08:30:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3243 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 D64641C1C1E for ; Wed, 9 Sep 2026 10:38:34 +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-25741-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-25741-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 0B9D3604F4 for ; Wed, 9 Sep 2026 08:32:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 304A0490C0D; Wed, 9 Sep 2026 08:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ra2FTZ2s" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 51691485CCD for ; Wed, 9 Sep 2026 08:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788942674; cv=none; b=ZYrEa0PWuM4b2L1xOCVcNre9IyPT7myIHo27CVlPlNBzh4ECkk7+IIiLBzz0YjbkQGYDU9cJbM2dP0yDPfA6gMHlRhQLLQ0X72z1/CLJuP9J2ai1JkRC+qnlyYUbbrK6uIZ5SP/KrCGukpCZgGfU6aENqW4mSjNPZyaFosGPI/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788942674; c=relaxed/simple; bh=cGpmPCWk/z4rj5JVkICnW7HVGVcxN3tvIGoYKX6sOJI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=El1gp0CANFN/VAnlxd6/kUw6IQzuL/sz1+NGukCTjsWS9TmwKrYmM3jmvvTzXxd5asRWZE19DBBxUiqFvNuevyyyrK8uab4/99xcznTngzFgx1HgYza9B8tqnJ1d/82Jlrr4f5nm3NlP2K/IcGvBOjIWTNiM8wN6Qp8eDOwN228= 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=ra2FTZ2s; arc=none smtp.client-ip=209.85.210.46 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-ot1-f46.google.com with SMTP id 46e09a7af769-7f57db8b5a4so4284461a34.2 for ; Wed, 09 Sep 2026 01:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788942670; x=1789547470; 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=CID5bvCPjR59lMZ6K1AMRWDV5Xq0pdMdX69zJBV2wqs=; b=ra2FTZ2sQ1DP+mPtx4yo/zk2G+48Z/djLfXjVETkNKoMhA5FQMSrNSZYgyktlp0ltv 4pPEJ+dim2d7FpDlhJHT93AJCkrjzZgKc9aNA8W7b0y8/MaI2kj6HYDIlXUC178TBDNF 8UEsX3ATbtIq4qglQzNmnQQ8ooxkN8zJ7YBs4SipDr7ywPR9A8/aRyJgLbC5+ov71pVF QuDrxU03YosyhG+VYN9fWgvzcP0363asi5RQOjWP0SWzRmQUxwtAtZAfhcrxipC5Er9M iPm6wKk6RN0EO4A9GMKZ0nKpXUWNSc0kVQe3Ttd6gF8EKCocKcvS2SZKfaHTB4MoQL+2 3tbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788942670; x=1789547470; 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=CID5bvCPjR59lMZ6K1AMRWDV5Xq0pdMdX69zJBV2wqs=; b=bWyGNrlzELN/l6gd5Srl6lDq/hvIVm9RHVE5+8kzn1YoBYHCIdjN/YHAXAmbtIh2/j PNUC9nAR5u1Ry7u5Xs2wEtCIdJ5Zg3VCpPdVQnO++aA24kYJgjN2tfgCNsL4QPJY+C+i JiukgP6T3YJVAcXw6BnFJIP4rjf1745yYXnxhVJUo3fqE+ZfBQhNlJ6OPlb9K+ESQWgC iEP9cN7oojb3A0gp8jAZ3nb4cxHStgtSH8BvmzUtWlyigD8lHTtMWU5JLPCHShnkJNr5 Sg5eVR/Wb3le3Ce/EP68ja3XP+O+syIvt4wn7CScp2jLfHLYAHF5dzUlyy0l5Fu59vzl lIvw== X-Forwarded-Encrypted: i=1; AKwUvBy7yFd1RBzSzb9x5jQVZ2gbXRLzqD8WNzcDz2HxGEmlxg8IsQC0ozvnjz4ET7tx79m1qhwYM9/If3YTWg==@lists.linux.dev X-Gm-Message-State: AFuF++mobor7nQgFqoDi2Z7Gem1aCpci4BSB//Iilf+L/mcJPavuo20v 3F9WFbMDkl6AXRRP7BciCC4Qxyn5gqhHliUOtY4UAE5ZX9fVdty2HOH2 X-Gm-Gg: AYBFou3i2lcRMsDqztpgSuQVgDhcwiUp3/ocNdDYeFhnQ8jNHJyh/pFuWrGJ375+/jL v8OE8Lri017E5csbjdZZVyEC51LFvF6O6EOiZiQNIAhlpNelarL6kPtS77G5gaWbxvvHdaZ2bY/ iCIgJ/wYlIRPrqu91HopRHVAi8PKCjGL+JRPD1QG/MWApriarfFmBiGqlv9VT4W1U9cKOtS2CPk v5lWQnTVVQyb5sAjBw/qjKFz8ftBlrBTsL+b25O42gUNc8kcrIjt4A45zya+/jsw2ce0q4OUQ/t nIy8DawWnS+plem1JStT5Q1w6YGZ6E4ZbQwJfgyg1qKujr2r9tE4Xa2XI3KphzfeG5ogyJZedvV y6E0+1vG4ydVPWyLhJxqLWf6BFbPhv7VF61pmzmByPPLPLRGjL7Sy/mRQQq+J5guNbXYC6TBs4l hgEjh5yuwlUxA3hqIUU4t+Kdh3rX9s+JDxroHdr6dggr0ocHEj2L50FGi07OFkwflF+qatxZSx+ nfnO3AYnN81cWwA1DTR5hbSxbuA3qQLcAEPVAUNPR+Bpmfm/Wv6NUj8RfBjIR46IrjWHZsp9c2B qf7kKQlgE3OeTEv6nlqF6BwByRODCPzB0xN73emhLkadej/LbLShXSrb9rurJsbpnyHEX1fhnSt oKonMK8V9GIyh7kiFL4ENeRvTZatGUw== X-Received: by 2002:a05:6820:1891:b0:6be:731b:5544 with SMTP id 006d021491bc7-6be731b5b5amr683141eaf.37.1788942670338; Wed, 09 Sep 2026 01:31:10 -0700 (PDT) Received: from [127.0.1.1] (184-96-151-165.hlrn.qwest.net. [184.96.151.165]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6b6dbedc6a0sm19031004eaf.5.2026.09.09.01.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 01:31:09 -0700 (PDT) From: James Hilliard Date: Wed, 09 Sep 2026 02:30:45 -0600 Subject: [PATCH v3 12/15] 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: <20260909-submit-sunxi-nand-vendor-oob-layout-v1-v3-12-838cb0ba1547@gmail.com> References: <20260909-submit-sunxi-nand-vendor-oob-layout-v1-v3-0-838cb0ba1547@gmail.com> In-Reply-To: <20260909-submit-sunxi-nand-vendor-oob-layout-v1-v3-0-838cb0ba1547@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]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; 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)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[20]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[dt]; PRECEDENCE_BULK(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.90.174.1:received,184.96.151.165:received,209.85.210.46:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; TAGGED_FROM(0.00)[bounces-25741-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FREEMAIL_TO(0.00)[bootlin.com,nod.at,ti.com,kernel.org,gmail.com,sholland.org,socionext.com]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: D64641C1C1E 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 6e54d3a92219..bbfed22640c8 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1412,15 +1412,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, @@ -1431,10 +1444,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);