All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Teng Wu" <gigadevice2025@gmail.com>, linux-mtd@lists.infradead.org
Cc: miquel.raynal@bootlin.com, vigneshr@ti.com, richard@nod.at,
	teng.wu@gigadevice.com, weijie.huang@gigadevice.com
Subject: Re: [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND
Date: Tue, 24 Nov 2026 13:17:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-231192@kernel.org> (raw)
In-Reply-To: <awWLzWDg-m9VBZVr@Fantast-WT.localdomain>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mtd: rawnand: hardcoded 0xC8 check in nand_setup_interface()
  hits ESMT chips
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] mtd: rawnand: stale current_interface_config in
  nand_setup_interface() [1]
--

commit dfc5fac94fb600d7bec8edf7fac78be636e97132
Author: Teng Wu <gigadevice2025@gmail.com>

mtd: rawnand: Skip timing mode readback check for GigaDevice NAND

This commit skips the ONFI timing mode GET_FEATURES readback check in
nand_setup_interface() for NAND chips with manufacturer ID 0xC8.

> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index fe8c6dcc9c071..4eebd8b436176 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -890,6 +890,15 @@ static int nand_setup_interface(struct nand_chip *chip, int chipnr)
>  		goto err_reset_chip;
>  
>  	if (request != tmode_param[0]) {
> +		/*
> +		* GigaDevice raw NAND chips (manufacturer ID 0xC8) support
> +		* the timing modes advertised in their ONFI parameter page.
> +		* Skip the strict ack check; keep it for other vendors.
> +		*/
> +		if (chip->id.data[0] == 0xC8) {
> +			goto update_interface_config;
> +		}

[Severity: Medium]
Does checking chip->id.data[0] == 0xC8 here also skip timing mode
readback verification for ESMT NAND chips?

Manufacturer ID 0xC8 (NAND_MFR_ESMT) is shared by both ESMT and
GigaDevice.  Suppressing the readback check for all 0xC8 chips prevents
nand_setup_interface() from detecting a rejected timing mode and falling
back to mode 0 on ESMT parts, while still issuing unnecessary
SET_FEATURES and GET_FEATURES bus operations on affected GigaDevice
parts before ignoring the result.

esmt_nand_fix_broken_get_timings() in drivers/mtd/nand/raw/nand_esmt.c
already handles this for GD9FU2G8F3A by matching chip->parameters.model
and clearing ONFI_FEATURE_ADDR_TIMING_MODE from get_feature_list and
set_feature_list:

drivers/mtd/nand/raw/nand_esmt.c:esmt_nand_fix_broken_get_timings() {
	static const char * const broken_get_timings[] = {
		"GD9FU2G8F3A",
	};
    ...
	bitmap_clear(chip->parameters.get_feature_list,
		     ONFI_FEATURE_ADDR_TIMING_MODE, 1);
	bitmap_clear(chip->parameters.set_feature_list,
		     ONFI_FEATURE_ADDR_TIMING_MODE, 1);
}

Could other affected GigaDevice models such as GD9FS2G8F3A be added to
broken_get_timings[] there instead?

[Severity: High]
This problem wasn't introduced by this patch, but nand_setup_interface()
calls nand_get_features() [1] after switching both the NAND chip
and the controller to chip->best_interface_config while
chip->current_interface_config still holds the SDR mode 0 reset
configuration until update_interface_config.

Because nand_get_features_op() queries nand_get_interface_config(chip),
it passes stale SDR mode 0 timings to nand_exec_op().  When switching to
an NV-DDR timing mode, nand_interface_is_nvddr(conf) evaluates to false,
so nand_get_features_op() reads only 4 bytes instead of 8 and skips
NV-DDR byte de-interleaving, corrupting tmode_param[1..3]:

drivers/mtd/nand/raw/nand_base.c:nand_get_features_op() {
    ...
	if (nand_has_exec_op(chip)) {
		const struct nand_interface_config *conf =
			nand_get_interface_config(chip);
    ...
		/* GET_FEATURE data bytes are received twice in NV-DDR mode */
		if (nand_interface_is_nvddr(conf)) {
			instrs[3].ctx.data.len *= 2;
			instrs[3].ctx.data.buf.in = ddrbuf;
		}
}

[1] https://sashiko.dev/#/bug/linux-0615e8bb-0985-4ed5-8173-2580f1023f12

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/awWLzWDg-m9VBZVr@Fantast-WT.localdomain?part=1

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

  reply	other threads:[~2026-11-24 13:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 13:06 [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND Teng Wu
2026-11-24 13:06 ` Teng Wu
2026-11-24 13:17 ` sashiko-bot [this message]
2026-11-24 13:40 ` Miquel Raynal
2026-11-24 13:40   ` Miquel Raynal
2026-11-27 12:24   ` Teng Wu
2026-11-27 12:24     ` Teng Wu
2026-11-27 12:52     ` Miquel Raynal
2026-11-27 12:52       ` Miquel Raynal

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-231192@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gigadevice2025@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=teng.wu@gigadevice.com \
    --cc=vigneshr@ti.com \
    --cc=weijie.huang@gigadevice.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.