* [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND
@ 2026-11-24 13:06 Teng Wu
2026-11-24 13:17 ` sashiko-bot
2026-11-24 13:40 ` Miquel Raynal
0 siblings, 2 replies; 3+ messages in thread
From: Teng Wu @ 2026-11-24 13:06 UTC (permalink / raw)
To: linux-mtd
Cc: miquel.raynal, vigneshr, richard, linux-kernel, teng.wu,
weijie.huang
GigaDevice raw NAND chips (manufacturer ID 0xC8) support the timing
modes advertised in their ONFI parameter page, so there is no need to
verify or enforce the timing mode switch on them. The supported set
depends on the supply voltage: 3.3V parts (e.g. GD9FU2G8F3A, DID DAh)
report modes 0-5 (3Fh in byte 129-130 of the parameter page), while
1.8V parts (e.g. GD9FS2G8F3A, DID AAh) report modes 0-4 (1Fh). The
highest supported mode is already picked automatically from the
parameter page by nand_choose_best_sdr_timings(), so the only thing
getting in the way is the readback check.
The GET_FEATURE timing mode readback on these chips does not reflect
the mode selected through SET_FEATURE. The strict check in
nand_setup_interface() therefore misdetects the chip as not
acknowledging the requested timing mode, printing "timing mode N not
acknowledged by the NAND chip" and falling back to a slower mode for
no reason.
Skip the readback check for GigaDevice chips while keeping it for all
other vendors, and go straight to updating the interface
configuration.
Signed-off-by: Teng Wu <gigadevice2025@gmail.com>
---
drivers/mtd/nand/raw/nand_base.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index a225b10f8145..8d77ebac4939 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;
+ }
+
pr_warn("%s timing mode %d not acknowledged by the NAND chip\n",
nand_interface_is_nvddr(chip->best_interface_config) ? "NV-DDR" : "SDR",
chip->best_interface_config->timings.mode);
--
2.43.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND
2026-11-24 13:06 [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND Teng Wu
@ 2026-11-24 13:17 ` sashiko-bot
2026-11-24 13:40 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-24 13:17 UTC (permalink / raw)
To: Teng Wu, linux-mtd
Cc: miquel.raynal, vigneshr, richard, teng.wu, weijie.huang
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/
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND
2026-11-24 13:06 [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND Teng Wu
2026-11-24 13:17 ` sashiko-bot
@ 2026-11-24 13:40 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2026-11-24 13:40 UTC (permalink / raw)
To: Teng Wu; +Cc: linux-mtd, vigneshr, richard, linux-kernel, teng.wu, weijie.huang
Hi,
> 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;
> + }
> +
There is a vendor driver, you shall use it rather than polluting the
core with vendor specific fixups. Check what
macronix_nand_fix_broken_get_timings() does for example.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:06 [PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND Teng Wu
2026-11-24 13:17 ` sashiko-bot
2026-11-24 13:40 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox