All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"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>
Cc: "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-sunxi@lists.linux.dev,
	linux-rt-devel@lists.linux.dev, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 06/16] mtd: rawnand: sunxi: select the pattern ID for the current ECC step
Date: Thu, 15 Oct 2026 01:50:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-172123@kernel.org> (raw)
In-Reply-To: <20261014-submit-sunxi-nand-vendor-oob-layout-v1-v7-6-5d3fc6ad2da1@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: rawnand: sunxi: PIO mode overwrites zero pattern with SRAM garbage
--

commit 6c354ef3bc88ac95cdf40b092e5c146de75aa789
Author: James Hilliard <james.hilliard1@gmail.com>
Subject: mtd: rawnand: sunxi: select the pattern ID for the current ECC step

This commit fixes the pattern-ID register check during ECC exception mode.
It updates the correction helper to test the bit corresponding to the
current hardware step rather than always checking bit zero, which ensures
DMA processing classifies physical all-zero and all-ones data blocks
correctly.

> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 57df88099206a..8256982d1d565 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -1101,7 +1101,7 @@ static int sunxi_nfc_hw_ecc_correct(struct nand_chip *nand, u8 *data, u8 *oob,
>  	if (pattern_found & BIT(step)) {
>  		u8 pattern;
>  
> -		if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID(nfc)) & 0x1))) {
> +		if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID(nfc)) & BIT(step)))) {
>  			pattern = 0x0;

[Severity: Medium]
When the pattern is identified as 0x0, the *erased out parameter remains
false. Later in sunxi_nfc_oob_read_batch(), the code checks this boolean
and handles PIO mode (!read->dma) by copying directly from SRAM:

sunxi_nfc_oob_read_batch() {
    ...
    if (erased) {
        read->has_erased_chunk = true;
        continue;
    }

    if (!read->dma)
        memcpy_fromio(data, nfc->regs + NFC_RAM0_BASE, ecc->size);
    ...
}

If scrambling is enabled for a physical all-zero block read in PIO mode,
will this memcpy_fromio() overwrite the valid zeros populated in
sunxi_nfc_hw_ecc_correct() with descrambled pseudo-random garbage from
the SRAM?

It appears this regression leaves PIO broken while fixing DMA zero
pattern reads.

>  		} else {
>  			pattern = 0xff;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-submit-sunxi-nand-vendor-oob-layout-v1-v7-0-5d3fc6ad2da1@gmail.com?part=6

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"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>
Cc: "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-sunxi@lists.linux.dev,
	linux-rt-devel@lists.linux.dev, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 06/16] mtd: rawnand: sunxi: select the pattern ID for the current ECC step
Date: Thu, 15 Oct 2026 01:50:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-172123@kernel.org> (raw)
In-Reply-To: <20261014-submit-sunxi-nand-vendor-oob-layout-v1-v7-6-5d3fc6ad2da1@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: rawnand: sunxi: PIO mode overwrites zero pattern with SRAM garbage
--

commit 6c354ef3bc88ac95cdf40b092e5c146de75aa789
Author: James Hilliard <james.hilliard1@gmail.com>
Subject: mtd: rawnand: sunxi: select the pattern ID for the current ECC step

This commit fixes the pattern-ID register check during ECC exception mode.
It updates the correction helper to test the bit corresponding to the
current hardware step rather than always checking bit zero, which ensures
DMA processing classifies physical all-zero and all-ones data blocks
correctly.

> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 57df88099206a..8256982d1d565 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -1101,7 +1101,7 @@ static int sunxi_nfc_hw_ecc_correct(struct nand_chip *nand, u8 *data, u8 *oob,
>  	if (pattern_found & BIT(step)) {
>  		u8 pattern;
>  
> -		if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID(nfc)) & 0x1))) {
> +		if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID(nfc)) & BIT(step)))) {
>  			pattern = 0x0;

[Severity: Medium]
When the pattern is identified as 0x0, the *erased out parameter remains
false. Later in sunxi_nfc_oob_read_batch(), the code checks this boolean
and handles PIO mode (!read->dma) by copying directly from SRAM:

sunxi_nfc_oob_read_batch() {
    ...
    if (erased) {
        read->has_erased_chunk = true;
        continue;
    }

    if (!read->dma)
        memcpy_fromio(data, nfc->regs + NFC_RAM0_BASE, ecc->size);
    ...
}

If scrambling is enabled for a physical all-zero block read in PIO mode,
will this memcpy_fromio() overwrite the valid zeros populated in
sunxi_nfc_hw_ecc_correct() with descrambled pseudo-random garbage from
the SRAM?

It appears this regression leaves PIO broken while fixing DMA zero
pattern reads.

>  		} else {
>  			pattern = 0xff;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-submit-sunxi-nand-vendor-oob-layout-v1-v7-0-5d3fc6ad2da1@gmail.com?part=6

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2026-10-15  1:50 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  1:33 [PATCH v7 00/16] mtd: rawnand: sunxi: fix transfers and support randomized OOB James Hilliard
2026-10-15  1:33 ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 01/16] mtd: rawnand: sunxi: centralize OOB handling James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 02/16] mtd: rawnand: sunxi: use the logical step's OOB length in PIO James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 03/16] mtd: rawnand: sunxi: propagate page-setup and erased-check errors James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 04/16] mtd: rawnand: sunxi: drain interrupts before reusing the completion James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  7:19   ` Sebastian Andrzej Siewior
2026-10-15  7:19     ` Sebastian Andrzej Siewior
2026-10-15 15:09     ` James Hilliard
2026-10-15 15:09       ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 05/16] mtd: rawnand: sunxi: stop failed program operations and disable ECC James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 06/16] mtd: rawnand: sunxi: select the pattern ID for the current ECC step James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:50   ` sashiko-bot [this message]
2026-10-15  1:50     ` sashiko-bot
2026-10-15  1:33 ` [PATCH v7 07/16] mtd: rawnand: sunxi: propagate buffer and column transfer errors James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 08/16] mtd: rawnand: sunxi: avoid a second program confirm for OOB writes James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 09/16] mtd: rawnand: sunxi: use page reads to reposition small-page NAND James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 10/16] mtd: rawnand: sunxi: bound DMA batches by the user-data register bank James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 11/16] mtd: rawnand: sunxi: reuse ECC status within each transfer James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:33 ` [PATCH v7 12/16] mtd: rawnand: sunxi: avoid redundant column changes for extra OOB James Hilliard
2026-10-15  1:33   ` James Hilliard
2026-10-15  1:34 ` [PATCH v7 13/16] mtd: rawnand: sunxi: avoid duplicate chip setup before page commands James Hilliard
2026-10-15  1:34   ` James Hilliard
2026-10-15  1:34 ` [PATCH v7 14/16] mtd: rawnand: sunxi: reduce user-data length register accesses James Hilliard
2026-10-15  1:34   ` James Hilliard
2026-10-15  1:34 ` [PATCH v7 15/16] dt-bindings: mtd: sunxi: Add randomized OOB flag James Hilliard
2026-10-15  1:34   ` James Hilliard
2026-10-15  1:34 ` [PATCH v7 16/16] mtd: rawnand: sunxi: support the Allwinner randomized OOB format James Hilliard
2026-10-15  1:34   ` 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=sashiko-outbox-172123@kernel.org \
    --to=sashiko-bot@kernel.org \
    --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-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=miquel.raynal@bootlin.com \
    --cc=mripard@kernel.org \
    --cc=richard.genoud@bootlin.com \
    --cc=richard@nod.at \
    --cc=robh@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=samuel@sholland.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.