[PATCH] mtd: rawnand: Skip timing mode readback check for GigaDevice NAND
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Tue Nov 24 05:17:05 PST 2026
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 at 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
More information about the linux-mtd
mailing list