From: sashiko-bot@kernel.org
To: "Florian Fainelli" <florian.fainelli@broadcom.com>,
linux-mtd@lists.infradead.org
Cc: bcm-kernel-feedback-list@broadcom.com,
"David Regan" <david.regan@broadcom.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Ahmed Naseef" <naseefkm@gmail.com>,
"Aleksei Sviridkin" <f@lex.la>, "Jeff Kim" <jekim@issi.com>,
"Han Xu" <han.xu@nxp.com>, "Bill Lee" <blee@issi.com>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Gabor Juhos" <j4g8y7@gmail.com>, "Nuno Sá" <nuno.sa@analog.com>,
"Kees Cook" <kees+treewide@kernel.org>,
"Frieder Schrempf" <frieder.schrempf@kontron.de>
Subject: Re: [PATCH] mtd: nand: spi: add Etron EM73C044VCF support
Date: Mon, 30 Nov 2026 23:03:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-242184@kernel.org> (raw)
In-Reply-To: <20261130225341.1989256-1-florian.fainelli@broadcom.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] mtd: spinand: etron: etron_ooblayout_free() overlaps 2-byte bad
block marker
- [Medium] mtd: spinand: etron: etron_ecc_get_status() triggers
premature -EUCLEAN
- [Medium] mtd: spinand: etron: missing SPINAND_HAS_QE_BIT flag for
EM73C044VCF quad ops
--
commit ca2416b337259cb1a2d85354a17e3134dc74ab5d
Author: David Regan <david.regan@broadcom.com>
mtd: nand: spi: add Etron EM73C044VCF support
This commit adds SPI-NAND support for the Etron EM73C044VCF 1Gb 3.3V flash
chip with 4-bit on-die ECC.
> diff --git a/drivers/mtd/nand/spi/etron.c b/drivers/mtd/nand/spi/etron.c
> new file mode 100644
> index 0000000000000..7f75f8968fad0
> --- /dev/null
> +++ b/drivers/mtd/nand/spi/etron.c
> @@ -0,0 +1,116 @@
[ ... ]
> +static SPINAND_OP_VARIANTS(read_cache_variants,
> + SPINAND_PAGE_READ_FROM_CACHE_1S_4S_4S_OP(0, 2, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_4S_OP(0, 1, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_2S_2S_OP(0, 1, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_2S_OP(0, 1, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_FAST_1S_1S_1S_OP(0, 1, NULL, 0, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_1S_OP(0, 1, NULL, 0, 0));
> +
> +static SPINAND_OP_VARIANTS(write_cache_variants,
> + SPINAND_PROG_LOAD_1S_1S_4S_OP(true, 0, NULL, 0),
> + SPINAND_PROG_LOAD_1S_1S_1S_OP(true, 0, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(update_cache_variants,
> + SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
> + SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
[ ... ]
> +static int etron_ooblayout_free(struct mtd_info *mtd, int section,
> + struct mtd_oob_region *region)
> +{
> + if (section)
> + return -ERANGE;
> +
> + /* Reserve 1 byte for the BBM. */
> + region->offset = 1;
> + region->length = (mtd->oobsize / 2) - 1;
> +
> + return 0;
> +}
[Severity: High]
Does reserving only 1 byte for the bad block marker cause
etron_ooblayout_free() to overlap the 2-byte marker used by the SPI-NAND
core?
spinand_isbad() and spinand_markbad() read and write a 2-byte marker at
OOB offsets 0 and 1, and spinand_isbad() treats a block as bad if either
marker[0] != 0xff or marker[1] != 0xff. Exposing OOB offset 1 as the
first free OOB byte means any MTD_OPS_AUTO_OOB write (such as JFFS2
cleanmarkers) that stores a non-0xff byte at free OOB offset 0 on the
first page of an eraseblock will cause subsequent bad-block scans to
classify good eraseblocks as bad.
Should region->offset be 2 and region->length be (mtd->oobsize / 2) - 2?
> +
> +static const struct mtd_ooblayout_ops etron_ooblayout = {
> + .ecc = etron_ooblayout_ecc,
> + .free = etron_ooblayout_free,
> +};
> +
> +/*
> + * The EM73C044VCF only reports four ECC status states when reading a page:
> + * no bitflips, some bitflips corrected, correction limit reached, and
> + * uncorrectable. The exact bitflip count is not available for the "some
> + * bitflips corrected" state, so the maximum for that state (3) is reported.
> + * The "limit reached" state reports the full ECC strength (4), which is
> + * what makes the MTD core return -EUCLEAN and ask for the data to be
> + * scrubbed.
> + */
> +static int etron_ecc_get_status(struct spinand_device *spinand,
> + u8 status)
> +{
> + switch (status & STATUS_ECC_MASK) {
> + case STATUS_ECC_NO_BITFLIPS:
> + return 0;
> +
> + case STATUS_ECC_UNCOR_ERROR:
> + return -EBADMSG;
> +
> + case STATUS_ECC_HAS_BITFLIPS:
> + return 3;
> +
> + case ETRON_STATUS_ECC_LIMIT_BITFLIPS:
> + return 4;
[Severity: Medium]
Does returning 3 for STATUS_ECC_HAS_BITFLIPS cause mtd_read_oob() to
return -EUCLEAN even when only a single bitflip was corrected?
For NAND_ECCREQ(4, 512), spinand_init() sets mtd->bitflip_threshold to
DIV_ROUND_UP(mtd->ecc_strength * 3, 4), which is 3. Because
mtd_read_oob() returns -EUCLEAN whenever ret_code >=
mtd->bitflip_threshold, returning 3 for STATUS_ECC_HAS_BITFLIPS triggers
-EUCLEAN and eraseblock scrubbing before ETRON_STATUS_ECC_LIMIT_BITFLIPS
is reached.
[ ... ]
> +static const struct spinand_info etron_spinand_table[] = {
> + /* EM73C 1Gb 3.3V */
> + SPINAND_INFO("EM73C044VCF",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25),
> + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
> + NAND_ECCREQ(4, 512),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + 0,
> + SPINAND_ECCINFO(&etron_ooblayout, etron_ecc_get_status)),
> +};
[Severity: Medium]
Should the flags argument here include SPINAND_HAS_QE_BIT?
read_cache_variants, write_cache_variants and update_cache_variants
include 4-bit Quad SPI operations, but spinand_configure_chip() only calls
spinand_init_quad_enable() to set CFG_QUAD_ENABLE in feature register 0xB0
when SPINAND_HAS_QE_BIT is set. Without it, Quad SPI transfers will fail
on quad-capable controllers unless the bootloader already enabled the QE
bit.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130225341.1989256-1-florian.fainelli@broadcom.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2026-11-30 23:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 22:53 [PATCH] mtd: nand: spi: add Etron EM73C044VCF support Florian Fainelli
2026-11-30 22:53 ` Florian Fainelli
2026-11-30 23:03 ` sashiko-bot [this message]
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-242184@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=blee@issi.com \
--cc=david.regan@broadcom.com \
--cc=f@lex.la \
--cc=florian.fainelli@broadcom.com \
--cc=frieder.schrempf@kontron.de \
--cc=han.xu@nxp.com \
--cc=j4g8y7@gmail.com \
--cc=jekim@issi.com \
--cc=kees+treewide@kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=naseefkm@gmail.com \
--cc=nuno.sa@analog.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.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.