From: Miquel Raynal <miquel.raynal@bootlin.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Maxime Ripard <mripard@kernel.org>,
Richard Genoud <richard.genoud@bootlin.com>,
Boris Brezillon <bbrezillon@kernel.org>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev, devicetree@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v10 04/26] mtd: rawnand: sunxi: reject pages exceeding the ECC step limit
Date: Thu, 19 Nov 2026 12:58:13 +0100 [thread overview]
Message-ID: <87ik1tdodm.fsf@bootlin.com> (raw)
In-Reply-To: <20261105-submit-sunxi-nand-vendor-oob-layout-v1-v10-4-dca1f6ed29a8@gmail.com> (James Hilliard's message of "Thu, 05 Nov 2026 11:55:20 -0700")
On 05/11/2026 at 11:55:20 -07, James Hilliard <james.hilliard1@gmail.com> wrote:
> The controller has 16 ECC status slots on A10/A23 and 32 on H6/H616.
> Hardware-ECC setup checks the strength and available OOB space, but does
> not check that the page fits those slots. NAND identification can supply
> a larger page size, and the NAND core does not enforce this
> controller-specific limit.
>
> If enough OOB space is available, an unsupported geometry can pass attach
> and reach DMA code that indexes status and user-data registers by ECC
> step. H6/H616 also represent enabled data blocks with a 32-bit mask. The
> number of steps must fit the controller even when their user data fits
> the register bank.
>
> Reject excessive step counts before allocating user-data lengths or
> installing the hardware-ECC callbacks. Check the final step size, after
> strength maximization and the conversion from 512-byte to 1-KiB steps,
> so valid geometries retain their existing layout. This also keeps PIO
> fallback from accepting a page that the controller cannot handle.
>
> Fixes: 1fef62c1423b ("mtd: nand: add sunxi NAND flash controller support")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/r/sashiko-outbox-173724@kernel.org
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> drivers/mtd/nand/raw/sunxi_nand.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 662d96fc2535..1a61f608ad91 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -2223,6 +2223,11 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
> ecc->bytes = ALIGN(ecc->bytes, 2);
>
> nsectors = mtd->writesize / ecc->size;
> + if (nsectors > nfc->caps->max_ecc_steps) {
> + dev_err(nfc->dev, "unsupported number of ECC steps: %d (max %u)\n",
> + nsectors, nfc->caps->max_ecc_steps);
> + return -EINVAL;
> + }
I'm fine with this patch, but if your manual says that the controller
support chips with pages up to 32k and you wire a chip -that does not
exist on earth yet- with a larger page size, screw you? This is again
one of those over defensive approaches...
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-11-19 11:58 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 18:55 [PATCH v10 00/26] mtd: rawnand: sunxi: fix transfers and support randomized OOB James Hilliard
2026-11-05 18:55 ` [PATCH v10 01/26] mtd: rawnand: sunxi: centralize OOB handling James Hilliard
2026-11-05 19:13 ` sashiko-bot
2026-11-05 18:55 ` [PATCH v10 02/26] mtd: rawnand: sunxi: share the buffer transfer chunk size James Hilliard
2026-11-05 18:55 ` [PATCH v10 03/26] mtd: rawnand: sunxi: avoid duplicate chip setup before page commands James Hilliard
2026-11-05 18:55 ` [PATCH v10 04/26] mtd: rawnand: sunxi: reject pages exceeding the ECC step limit James Hilliard
2026-11-19 11:58 ` Miquel Raynal [this message]
2026-11-05 18:55 ` [PATCH v10 05/26] mtd: rawnand: sunxi: use the logical step's OOB length in PIO James Hilliard
2026-11-05 18:55 ` [PATCH v10 06/26] mtd: rawnand: sunxi: propagate page-setup and erased-check errors James Hilliard
2026-11-05 18:55 ` [PATCH v10 07/26] mtd: rawnand: sunxi: drain interrupts before reusing the completion James Hilliard
2026-11-05 18:55 ` [PATCH v10 08/26] mtd: rawnand: sunxi: stop failed program operations and disable ECC James Hilliard
2026-11-05 18:55 ` [PATCH v10 09/26] mtd: rawnand: sunxi: select the pattern ID for the current ECC step James Hilliard
2026-11-05 18:55 ` [PATCH v10 10/26] mtd: rawnand: sunxi: preserve synthesized zero-pattern data and OOB James Hilliard
2026-11-05 18:55 ` [PATCH v10 11/26] mtd: rawnand: sunxi: propagate buffer and column transfer errors James Hilliard
2026-11-05 18:55 ` [PATCH v10 12/26] mtd: rawnand: sunxi: avoid a second program confirm for OOB writes James Hilliard
2026-11-05 18:55 ` [PATCH v10 13/26] mtd: rawnand: sunxi: use page reads to reposition small-page NAND James Hilliard
2026-11-05 18:55 ` [PATCH v10 14/26] mtd: rawnand: sunxi: bound DMA batches by the user-data register bank James Hilliard
2026-11-05 18:55 ` [PATCH v10 15/26] mtd: rawnand: sunxi: send all address cycles in split operations James Hilliard
2026-11-05 18:55 ` [PATCH v10 16/26] mtd: rawnand: sunxi: propagate chip clock setup errors James Hilliard
2026-11-05 18:55 ` [PATCH v10 17/26] mtd: rawnand: sunxi: limit buffer transfers to the command byte count James Hilliard
2026-11-05 18:55 ` [PATCH v10 18/26] mtd: rawnand: sunxi: skip unavailable NAND child nodes James Hilliard
2026-11-05 18:55 ` [PATCH v10 19/26] mtd: rawnand: sunxi: scan all chips before registering MTD devices James Hilliard
2026-11-05 18:55 ` [PATCH v10 20/26] dt-bindings: mtd: sunxi: require the H616 AHB reset James Hilliard
2026-11-06 8:19 ` Krzysztof Kozlowski
2026-11-06 8:28 ` James Hilliard
2026-11-06 8:30 ` Krzysztof Kozlowski
2026-11-05 18:55 ` [PATCH v10 21/26] mtd: rawnand: sunxi: reset the H616 data path after DMA aborts James Hilliard
2026-11-05 18:55 ` [PATCH v10 22/26] mtd: rawnand: sunxi: reuse ECC status within each transfer James Hilliard
2026-11-05 18:55 ` [PATCH v10 23/26] mtd: rawnand: sunxi: avoid redundant column changes for extra OOB James Hilliard
2026-11-05 18:55 ` [PATCH v10 24/26] mtd: rawnand: sunxi: reduce user-data length register accesses James Hilliard
2026-11-05 18:55 ` [PATCH v10 25/26] dt-bindings: mtd: sunxi: Add randomized OOB flag James Hilliard
2026-11-05 18:55 ` [PATCH v10 26/26] mtd: rawnand: sunxi: support the Allwinner randomized OOB format James Hilliard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ik1tdodm.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=bbrezillon@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=james.hilliard1@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=linux-sunxi@lists.linux.dev \
--cc=mripard@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=richard.genoud@bootlin.com \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=rostedt@goodmis.org \
--cc=samuel@sholland.org \
--cc=sashiko-bot@kernel.org \
--cc=vigneshr@ti.com \
--cc=wens@kernel.org \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox