All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alan Borzeszkowski" <alan.borzeszkowski@linux.intel.com>,
	pratyush@kernel.org, mwalle@kernel.org,
	miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: takahiro.kuwano@infineon.com, linux-mtd@lists.infradead.org,
	mika.westerberg@linux.intel.com
Subject: Re: [REGRESSION] mtd: spi-nor: driver probe fails with -EINVAL on intel-spi v7.4-rc1
Date: Thu, 03 Dec 2026 13:25:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-247854@kernel.org> (raw)
In-Reply-To: <111cfeb5ffc603883b6573c62e49675bc3924b0a.camel@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] mtd: spi-nor: missing Signed-off-by trailer in commit message
- [Medium] mtd: spi-nor: otp.c workaround leaves spi_nor_read_sr2()
  returning -EINVAL
- [Low] mtd: spi-nor: missing Fixes trailer for commit 63489002d397
- [Low] mtd: spi-nor: email-style commit log omits
  spi_nor_otp_lock_sr2() rationale
- [Low] mtd: spi-nor: missing Fixes trailer for commit 63489002d397
- [Low] mtd: spi-nor: space indentation instead of tabs in otp.c
--

commit b3e6a237ffa19d462187c2d8c95f34e9cf895c30
Author: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>

> mtd: spi-nor: driver probe fails with -EINVAL on intel-spi v7.4-rc1
>
> 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.

[Severity: High]
This patch is missing a Signed-off-by trailer, which is required for the
Developer's Certificate of Origin before it can be merged.

[Severity: Low]
This fixes a regression introduced by 63489002d397 ("mtd: spi-nor: Refactor
Read Status/Write Status support").  Should it include a formal trailer?

  Fixes: 63489002d397 ("mtd: spi-nor: Refactor Read Status/Write Status support")

[Severity: Low]
The commit message is formatted as a mailing-list bug report ("Hi,",
"LLM-assisted diff below", and a symptom subject naming v7.4-rc1) rather
than a concise changelog describing what the patch changes and why.  It
also explains the probe failure through spi_nor_otp_is_locked_sr2(), but
omits why spi_nor_otp_lock_sr2() is modified as well.

> diff --git a/drivers/mtd/spi-nor/otp.c b/drivers/mtd/spi-nor/otp.c
> index bb9a801b3ceb1..b87e424642a36 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;

[Severity: Low]
Both added return -EOPNOTSUPP; lines (here and in
spi_nor_otp_is_locked_sr2() below) are indented with 16 spaces instead of
two tabs.

> @@ -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;

[Severity: Medium]
Should spi_nor_read_sr2() return -EOPNOTSUPP instead of working around it
in otp.c?

drivers/mtd/spi-nor/core.c:spi_nor_read_sr2() {
	struct spi_nor_flash_parameter *params = nor->params;

	if (!params->opcodes.read_sr2)
		return -EINVAL;
	...
}

Leaving spi_nor_read_sr2() returning -EINVAL means its other caller
sst26vf_nor_unlock() in drivers/mtd/spi-nor/sst.c still propagates -EINVAL
instead of -EOPNOTSUPP on controllers where spi_nor_spimem_adjust_hwcaps()
clears opcodes.read_sr2, conflating an unsupported controller opcode with
invalid unlock arguments or permanently locked blocks.

Changing spi_nor_read_sr2() to return -EOPNOTSUPP fixes both
spi_nor_otp_is_locked_sr2() and sst26vf_nor_unlock(), and calling
spi_nor_read_sr2() directly in spi_nor_otp_lock_sr2() (instead of
spi_nor_read_sr1_and_sr2()) avoids reaching into
nor->params->opcodes.read_sr2 from otp.c.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/111cfeb5ffc603883b6573c62e49675bc3924b0a.camel@linux.intel.com?part=1

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

  reply	other threads:[~2026-12-03 13:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
2026-12-04 11:10 ` Miquel Raynal
2026-12-04 16:34   ` Alan Borzeszkowski

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-247854@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alan.borzeszkowski@linux.intel.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=takahiro.kuwano@infineon.com \
    --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.