ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
	linux-sunxi@lists.linux.dev, robh@kernel.org
Subject: Re: [PATCH v5 10/18] mtd: rawnand: sunxi: bound DMA batches by the user-data register bank
Date: Mon, 14 Sep 2026 03:19:28 +0000	[thread overview]
Message-ID: <20260914031929.2E7091F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260913-submit-sunxi-nand-vendor-oob-layout-v1-v5-10-7d711076a6f7@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] DMA batching breaks because the hardware's internal chunk counter resets for each batch, causing it to generate incorrect flash column addresses for main data chunks after the first in subsequent batches.
--

commit fcea2b1acac181df9bb3db6577c776b8c30250b9
Author: James Hilliard <james.hilliard1@gmail.com>

mtd: rawnand: sunxi: bound DMA batches by the user-data register bank

This commit splits DMA transfers into batches whose aggregate user data
fits the hardware's user-data register bank. It reuses hardware slots
from zero in each batch while maintaining logical offsets.

Fixes: 54dcd6aa69db ("mtd: rawnand: sunxi: introduce maximize variable user data length")

> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index e29638c828caf..fbea6f16ea9d7 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
[ ... ]
> @@ -1761,69 +1776,88 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,
[ ... ]
> -	writel(NFC_PAGE_OP | NFC_DATA_SWAP_METHOD |
> -	       NFC_DATA_TRANS | NFC_ACCESS_DIR,
> -	       nfc->regs + NFC_REG_CMD);
> +		writel(NFC_PAGE_OP | NFC_DATA_SWAP_METHOD |
> +		       NFC_DATA_TRANS | NFC_ACCESS_DIR,
> +		       nfc->regs + NFC_REG_CMD);

[Severity: High]
Does this batching approach cause a regression where the controller's
autonomous state machine generates incorrect flash column addresses?

When a page is split into multiple DMA batches, both
sunxi_nfc_hw_ecc_read_batch_dma() and sunxi_nfc_hw_ecc_write_page_dma()
iterate over the batches with first_step > 0. Because the hardware is
reprogrammed for each batch, it appears the controller's internal chunk
counter resets to 0.

While the first chunk of a batch is read or written correctly due to the
manual column change beforehand, won't the NFC_PAGE_OP state machine
automatically issue a 0x05/0x85 column change to jump back to main data
for the second chunk of the batch?

If the internal counter is reset, would the hardware calculate the return
column address as 1 * ecc_size instead of (first_step + 1) * ecc_size?
Could this cause the controller to read or write over the wrong flash
offsets for all chunks after the first in subsequent batches, leading
to data corruption?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260913-submit-sunxi-nand-vendor-oob-layout-v1-v5-0-7d711076a6f7@gmail.com?part=10

  reply	other threads:[~2026-09-14  3:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  3:01 [PATCH v5 00/18] mtd: rawnand: sunxi: support the Allwinner randomized OOB format James Hilliard
2026-09-14  3:01 ` [PATCH v5 01/18] mtd: rawnand: sunxi: drain interrupts before reusing the completion James Hilliard
2026-09-14  3:01 ` [PATCH v5 02/18] mtd: rawnand: sunxi: use the logical step's OOB length in PIO James Hilliard
2026-09-14  3:01 ` [PATCH v5 03/18] mtd: rawnand: sunxi: propagate page-setup and erased-check errors James Hilliard
2026-09-14  3:01 ` [PATCH v5 04/18] mtd: rawnand: sunxi: stop failed program operations and disable ECC James Hilliard
2026-09-14  3:01 ` [PATCH v5 05/18] mtd: rawnand: sunxi: select the pattern ID for the current ECC step James Hilliard
2026-09-14  3:01 ` [PATCH v5 06/18] mtd: rawnand: sunxi: propagate buffer and column transfer errors James Hilliard
2026-09-14  3:01 ` [PATCH v5 07/18] mtd: rawnand: sunxi: avoid a second program confirm for OOB writes James Hilliard
2026-09-14  3:01 ` [PATCH v5 08/18] mtd: rawnand: sunxi: avoid redundant column changes for extra OOB James Hilliard
2026-09-14  3:01 ` [PATCH v5 09/18] mtd: rawnand: sunxi: use page reads to reposition small-page NAND James Hilliard
2026-09-14  3:01 ` [PATCH v5 10/18] mtd: rawnand: sunxi: bound DMA batches by the user-data register bank James Hilliard
2026-09-14  3:19   ` sashiko-bot [this message]
2026-09-14  3:01 ` [PATCH v5 11/18] mtd: rawnand: sunxi: clarify OOB register and step handling James Hilliard
2026-09-14  3:01 ` [PATCH v5 12/18] dt-bindings: mtd: sunxi: Add randomized OOB flag James Hilliard
2026-09-14  3:01 ` [PATCH v5 13/18] mtd: rawnand: sunxi: support randomized OOB formats James Hilliard
2026-09-14  3:01 ` [PATCH v5 14/18] mtd: rawnand: sunxi: select the packed H6/H616 OOB layout James Hilliard
2026-09-14  3:01 ` [PATCH v5 15/18] mtd: rawnand: sunxi: combine contiguous unprotected OOB reads James Hilliard
2026-09-14  3:01 ` [PATCH v5 16/18] mtd: rawnand: sunxi: avoid duplicate chip setup before page commands James Hilliard
2026-09-14  3:01 ` [PATCH v5 17/18] mtd: rawnand: sunxi: reduce user-data length register accesses James Hilliard
2026-09-14  3:01 ` [PATCH v5 18/18] mtd: rawnand: sunxi: reuse ECC status within each DMA read 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=20260914031929.2E7091F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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