Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [REGRESSION] mtd: spi-nor: driver probe fails with -EINVAL on intel-spi v7.4-rc1
@ 2026-12-03 13:15 Alan Borzeszkowski
  2026-12-03 13:25 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Borzeszkowski @ 2026-12-03 13:15 UTC (permalink / raw)
  To: pratyush, mwalle, miquel.raynal, richard, vigneshr
  Cc: takahiro.kuwano, linux-mtd, mika.westerberg

Hi,

Since v7.4-rc1, spi-nor fails to probe on some of our client platforms
during internal testing, with the MTD device (/dev/mtd) missing as a
result. Kernel v7.3 works fine on the same machine.
The flash is a Winbond w25q512nwq behind the Intel SPI controller.

Dmesg log:
=====
calling  spi_nor_module_init+0x0/0xff0 [spi_nor] @ 767
spi-nor spi3.0: supply vcc not found, using dummy regulator
spi-nor spi3.0: using lookup tables for GPIO lookup
spi-nor spi3.0: No GPIO consumer reset found
spi-nor spi3.0: error -EINVAL: Failed to register OTP NVMEM device
spi-nor spi3.0: probe with driver spi-nor failed with error -22
probe of spi3.0 with driver spi-nor returned 22 after 2275 usecs
initcall spi_nor_module_init+0x0/0xff0 [spi_nor] returned 0 after 2291 usecs
=====

We narrowed down the issue to following commit:
63489002d397 ("mtd: spi-nor: Refactor Read Status/Write Status
support")

Driver fails probe while adding MTD device in mtd_otp_nvmem_add(),
after calling mtd_otp_size() in the 'user' branch. This call now
returns -EINVAL instead of -EOPNOTSUPP, which is not ignored in the
'err:' block.
Going further, the spi_nor_read_sr2() call in
spi_nor_otp_is_locked_sr2() is the one returning -EINVAL.

Call stack looks like this: mtd_otp_size()->mtd_get_user_prot_info()-
>spi_nor_mtd_otp_info()->spi_nor_otp_is_locked_sr2()-
>spi_nor_read_sr2() = -EINVAL

LLM-assisted diff below restores v7.3 behavior. I tested it on affected
machine - probe succeeds and MTD device is again present in sysfs.

diff --git a/drivers/mtd/spi-nor/otp.c b/drivers/mtd/spi-nor/otp.c
index bb9a801b3ceb..b87e424642a3 100644
--- a/drivers/mtd/spi-nor/otp.c
+++ b/drivers/mtd/spi-nor/otp.c
@@ -178,6 +178,9 @@ int spi_nor_otp_lock_sr2(struct spi_nor *nor, unsigned int region)
 	int ret, lock_bit;
 	u8 sr[2];
 
+	if (!nor->params->opcodes.read_sr2)
+                return -EOPNOTSUPP;
+
 	lock_bit = spi_nor_otp_lock_bit_cr(region);
 	if (lock_bit < 0)
 		return lock_bit;
@@ -210,6 +213,9 @@ int spi_nor_otp_is_locked_sr2(struct spi_nor *nor, unsigned int region)
 	int ret, lock_bit;
 	u8 sr2;
 
+	if (!nor->params->opcodes.read_sr2)
+                return -EOPNOTSUPP;
+
 	lock_bit = spi_nor_otp_lock_bit_cr(region);
 	if (lock_bit < 0)
 		return lock_bit;


I can send this as a patch if you prefer.

Thanks,
Alan

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 13:15 [REGRESSION] mtd: spi-nor: driver probe fails with -EINVAL on intel-spi v7.4-rc1 Alan Borzeszkowski
2026-12-03 13:25 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox