Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: conor+dt@kernel.org, linux-sunxi@lists.linux.dev,
	robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 03/17] mtd: rawnand: sunxi: propagate page-setup and erased-check errors
Date: Sun, 13 Sep 2026 04:16:42 +0000	[thread overview]
Message-ID: <20260913041642.E28F81F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260912-submit-sunxi-nand-vendor-oob-layout-v1-v4-3-4a64bed94229@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch introduces a regression for small-page NANDs by explicitly propagating errors from `nand_change_read_column_op()`, which unconditionally returns `-ENOTSUPP` when `mtd->writesize <= 512`.
--

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

mtd: rawnand: sunxi: propagate page-setup and erased-check errors

This commit stops before starting PIO or DMA transfers when page setup fails
and shares the erased-chunk fallback between PIO and DMA. It routes PIO page
and subpage error exits through ECC disable before returning the transfer
error.

> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 172c7c4b0ba6d..d5d8d383b6d12 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
[ ... ]
> @@ -1067,6 +1067,40 @@ static void sunxi_nfc_hw_ecc_update_stats(struct nand_chip *nand,
>  	}
>  }
>  
> +/*
> + * Return 1 for an erased chunk or 0 for an uncorrectable chunk, with ECC
> + * statistics updated in either case. Negative values report transport errors.
> + */
> +static int sunxi_nfc_hw_ecc_read_error(struct nand_chip *nand,
> +				       u8 *data, int data_off,
> +				       u8 *oob, int oob_off,
> +				       unsigned int user_data_sz,
> +				       unsigned int *max_bitflips)
> +{
> +	struct nand_ecc_ctrl *ecc = &nand->ecc;
> +	unsigned int oob_len = ecc->bytes + user_data_sz;
> +	int ret;
> +
> +	/* Check the physical representation for bitflips in erased pages. */
> +	if (nand->options & NAND_NEED_SCRAMBLING) {
> +		ret = nand_change_read_column_op(nand, data_off, data,
> +						 ecc->size, false);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	ret = nand_change_read_column_op(nand, oob_off, oob, oob_len, false);
> +	if (ret)
> +		return ret;

[Severity: High]
Will this introduce a regression for small-page NANDs?

When an ECC error is detected, the driver attempts an erased chunk check via
sunxi_nfc_hw_ecc_read_error(), which calls nand_change_read_column_op().

Looking at nand_change_read_column_op() in drivers/mtd/nand/raw/nand_base.c,
it does not support column changes for small-page NANDs and unconditionally
returns -ENOTSUPP:

drivers/mtd/nand/raw/nand_base.c:nand_change_read_column_op() {
        ...
        /* Small page NANDs do not support column change. */
        if (mtd->writesize <= 512)
                return -ENOTSUPP;
        ...
}

By explicitly propagating this error, it appears read operations on erased
pages, bad block scans, and OOB data reads on small-page NANDs will now abort
with a transport error (-ENOTSUPP) instead of correctly reporting ECC errors
(-EBADMSG) or processing erased chunks. Prior to this patch, the error from
nand_change_read_column_op() was safely ignored in this path, allowing the
driver to fall back to reporting an uncorrectable ECC error gracefully.

> +
> +	ret = nand_check_erased_ecc_chunk(data, ecc->size, oob, oob_len, NULL, 0,
> +					  ecc->strength);
> +
> +	sunxi_nfc_hw_ecc_update_stats(nand, max_bitflips, ret);
> +
> +	return ret >= 0;
> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260912-submit-sunxi-nand-vendor-oob-layout-v1-v4-0-4a64bed94229@gmail.com?part=3

  reply	other threads:[~2026-09-13  4:16 UTC|newest]

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