All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Michael Walle" <mwalle@kernel.org>
Cc: "Pratyush Yadav" <pratyush@kernel.org>,
	 "Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
	 "Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	 "Nicolas Ferre" <nicolas.ferre@microchip.com>,
	 "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	 "Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
	 "Jonathan Corbet" <corbet@lwn.net>,
	 "Shuah Khan" <skhan@linuxfoundation.org>,
	 "Steam Lin" <STLin2@winbond.com>,
	"Hsin-Yi Wang" <hsinyi@chromium.org>,
	 "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	 <linux-mtd@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	 <linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v3 03/23] mtd: spi-nor: Refactor Read Status/Write Status support
Date: Wed, 02 Sep 2026 12:08:14 +0200	[thread overview]
Message-ID: <874ig87ypd.fsf@bootlin.com> (raw)
In-Reply-To: <DKONYM8W4BAW.25PBIPPWCILG1@kernel.org> (Michael Walle's message of "Fri, 14 Aug 2026 14:25:56 +0200")

Hello Michael,

>> There will probably be breakages on older chips. These cannot be
>> guessed because they are not properly listed in manufacturer
>> fixups (yet). If we want a cleanup/simplification, we will have to cope
>> with this risk.
>>
>> I hope the diff stats will motivate people to have a look and report
>> their testing.
>>
>> I will also eagerly monitor Sashiko's output which will probably be
>> very useful to catch niche weird cases where these changes might break.
>
>
> Honestly, I'm still not sold at the sr1 and sr2 split. But since
> spi-nor is know for it's code churn. I could just rework that later
> :)

:'-)

> Still I had some questions in the old thread:
> I don't get why there should be any endianness problems?
> Just the low level read and write would have to figure out how to
> read and write the status registers.

Yes, that's the point, with an array there is no endianness problem,
even low level helpers do not need to know memory ordering. Endianness
is *always* a pain, it is most of the time wrongly understood, I hate
endianness topics :)

[...]

>> +int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2)
>> +{
>> +	struct spi_nor_flash_parameter *params = nor->params;
>> +	int ret;
>> +
>> +	if (params->opcodes.read_sr2) {
>> +		ret = spi_nor_read_sr_ll(nor, params->opcodes.read_sr2, sr2, 1);
>> +		if (ret)
>> +			return ret;
>> +	} else if (spi_nor_get_protocol_width(nor->read_proto) == 4 ||
>> +		   spi_nor_get_protocol_width(nor->write_proto) == 4) {
>> +		/* Make sure the QE bit is persistently kept */
>> +		*sr2 = params->qe_mask[1];
>
> Mh. So before there was at least a check if a quad_enable cb is set.
> Is this now implicit? because qe_mask[1] is zero if there is no
> quad_enable? That should at *least* get some comment.

You are right, this is missing the st_micron case. I will re-add the
check.

> I tried to actually get the original use case, but all I've found
> is Tudors commit 39d1e3340c73 ("mtd: spi-nor: Fix clearing of QE bit
> on lock()/unlock()"). There wasn't much of a discussion on the ML,
> and I couldn't find where Boris was suggesting it.
>
> So before we cannot get rid of it anymore, we should just handle it
> in the one caller which actually uses it: spi_nor_sr_{un,}lock().
> I've checked the current spi_nor_write_sr_and_check() and the only
> actual user is the swp.c. atmel.c is doing global write protection
> on/off, which IIRC only uses SR1.

Yes.

> So let's move that weird handling there. Then chances are, we can
> get rid of it as we know what flashes do locking because that is not
> discoverable at runtime. It's just tedious work to check all the
> datasheets. But as soon as we now put that into a more generic path,
> we can't do anything about it anymore.

I understand the concern, which is right. I just added a
"read_sr2_careful" helper for the swp.c purpose.

>> +	} else {
>> +		*sr2 = 0;
>
> I'd expect an -EINVAL or -EIO here.

There is an actual case that is possible where we do not want to use
quad mode on a BFPT_DWORD15_QER_SR2_BIT1_NO_RD chip. I believe we should
keep = 0 here.

Thanks,
Miquèl

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

WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Michael Walle" <mwalle@kernel.org>
Cc: "Pratyush Yadav" <pratyush@kernel.org>,
	 "Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
	 "Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	 "Nicolas Ferre" <nicolas.ferre@microchip.com>,
	 "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	 "Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
	 "Jonathan Corbet" <corbet@lwn.net>,
	 "Shuah Khan" <skhan@linuxfoundation.org>,
	 "Steam Lin" <STLin2@winbond.com>,
	"Hsin-Yi Wang" <hsinyi@chromium.org>,
	 "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	 <linux-mtd@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	 <linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v3 03/23] mtd: spi-nor: Refactor Read Status/Write Status support
Date: Wed, 02 Sep 2026 12:08:14 +0200	[thread overview]
Message-ID: <874ig87ypd.fsf@bootlin.com> (raw)
In-Reply-To: <DKONYM8W4BAW.25PBIPPWCILG1@kernel.org> (Michael Walle's message of "Fri, 14 Aug 2026 14:25:56 +0200")

Hello Michael,

>> There will probably be breakages on older chips. These cannot be
>> guessed because they are not properly listed in manufacturer
>> fixups (yet). If we want a cleanup/simplification, we will have to cope
>> with this risk.
>>
>> I hope the diff stats will motivate people to have a look and report
>> their testing.
>>
>> I will also eagerly monitor Sashiko's output which will probably be
>> very useful to catch niche weird cases where these changes might break.
>
>
> Honestly, I'm still not sold at the sr1 and sr2 split. But since
> spi-nor is know for it's code churn. I could just rework that later
> :)

:'-)

> Still I had some questions in the old thread:
> I don't get why there should be any endianness problems?
> Just the low level read and write would have to figure out how to
> read and write the status registers.

Yes, that's the point, with an array there is no endianness problem,
even low level helpers do not need to know memory ordering. Endianness
is *always* a pain, it is most of the time wrongly understood, I hate
endianness topics :)

[...]

>> +int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2)
>> +{
>> +	struct spi_nor_flash_parameter *params = nor->params;
>> +	int ret;
>> +
>> +	if (params->opcodes.read_sr2) {
>> +		ret = spi_nor_read_sr_ll(nor, params->opcodes.read_sr2, sr2, 1);
>> +		if (ret)
>> +			return ret;
>> +	} else if (spi_nor_get_protocol_width(nor->read_proto) == 4 ||
>> +		   spi_nor_get_protocol_width(nor->write_proto) == 4) {
>> +		/* Make sure the QE bit is persistently kept */
>> +		*sr2 = params->qe_mask[1];
>
> Mh. So before there was at least a check if a quad_enable cb is set.
> Is this now implicit? because qe_mask[1] is zero if there is no
> quad_enable? That should at *least* get some comment.

You are right, this is missing the st_micron case. I will re-add the
check.

> I tried to actually get the original use case, but all I've found
> is Tudors commit 39d1e3340c73 ("mtd: spi-nor: Fix clearing of QE bit
> on lock()/unlock()"). There wasn't much of a discussion on the ML,
> and I couldn't find where Boris was suggesting it.
>
> So before we cannot get rid of it anymore, we should just handle it
> in the one caller which actually uses it: spi_nor_sr_{un,}lock().
> I've checked the current spi_nor_write_sr_and_check() and the only
> actual user is the swp.c. atmel.c is doing global write protection
> on/off, which IIRC only uses SR1.

Yes.

> So let's move that weird handling there. Then chances are, we can
> get rid of it as we know what flashes do locking because that is not
> discoverable at runtime. It's just tedious work to check all the
> datasheets. But as soon as we now put that into a more generic path,
> we can't do anything about it anymore.

I understand the concern, which is right. I just added a
"read_sr2_careful" helper for the swp.c purpose.

>> +	} else {
>> +		*sr2 = 0;
>
> I'd expect an -EINVAL or -EIO here.

There is an actual case that is possible where we do not want to use
quad mode on a BFPT_DWORD15_QER_SR2_BIT1_NO_RD chip. I believe we should
keep = 0 here.

Thanks,
Miquèl


  reply	other threads:[~2026-09-02 10:08 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 15:19 [PATCH v3 00/23] mtd: spi-nor: QE handling cleanup + fixup reworks + Winbond RV chips addition Miquel Raynal
2026-08-13 15:19 ` Miquel Raynal
2026-08-13 15:19 ` [PATCH v3 01/23] mtd: spi-nor: Rename BFPT_DWORD15_QER_SR2_BIT1_BUGGY Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  7:30   ` Michael Walle
2026-08-14  7:30     ` Michael Walle
2026-08-20  5:50   ` Takahiro.Kuwano
2026-08-20  5:50     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 02/23] mtd: spi-nor: Create a structure containing the flash opcodes Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  7:31   ` Michael Walle
2026-08-14  7:31     ` Michael Walle
2026-08-20  5:52   ` Takahiro.Kuwano
2026-08-20  5:52     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 03/23] mtd: spi-nor: Refactor Read Status/Write Status support Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14 12:25   ` Michael Walle
2026-08-14 12:25     ` Michael Walle
2026-09-02 10:08     ` Miquel Raynal [this message]
2026-09-02 10:08       ` Miquel Raynal
2026-08-13 15:19 ` [PATCH v3 04/23] mtd: spi-nor: Add support for the new JESD216 rev F QER field Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14 12:26   ` Michael Walle
2026-08-14 12:26     ` Michael Walle
2026-08-20  5:53   ` Takahiro.Kuwano
2026-08-20  5:53     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 05/23] mtd: spi-nor: Create the concept of fixup table with match function Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:40   ` Michael Walle
2026-08-14  9:40     ` Michael Walle
2026-08-27 16:43     ` Miquel Raynal
2026-08-27 16:43       ` Miquel Raynal
2026-08-28  9:43       ` Michael Walle
2026-08-28  9:43         ` Michael Walle
2026-08-31 15:07         ` Miquel Raynal
2026-08-31 15:07           ` Miquel Raynal
2026-08-20  5:56   ` Takahiro.Kuwano
2026-08-20  5:56     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 06/23] mtd: spi-nor: Create an indirection on the part name Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:41   ` Michael Walle
2026-08-14  9:41     ` Michael Walle
2026-08-20  5:57   ` Takahiro.Kuwano
2026-08-20  5:57     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 07/23] mtd: spi-nor: Move the SFDP header structure to a C header Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:41   ` Michael Walle
2026-08-14  9:41     ` Michael Walle
2026-08-20  5:57   ` Takahiro.Kuwano
2026-08-20  5:57     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 08/23] mtd: spi-nor: winbond: Prepare introduction of W25QxxRV-Q/N parts Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:46   ` Michael Walle
2026-08-14  9:46     ` Michael Walle
2026-09-01  9:02     ` Miquel Raynal
2026-09-01  9:02       ` Miquel Raynal
2026-08-20  5:58   ` Takahiro.Kuwano
2026-08-20  5:58     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 09/23] mtd: spi-nor: winbond: Add support for W25Q32RV-Q/N Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:46   ` Michael Walle
2026-08-14  9:46     ` Michael Walle
2026-08-20  6:03   ` Takahiro.Kuwano
2026-08-20  6:03     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 10/23] mtd: spi-nor: winbond: Add support for W25Q64RV-Q/N Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:46   ` Michael Walle
2026-08-14  9:46     ` Michael Walle
2026-08-20  6:03   ` Takahiro.Kuwano
2026-08-20  6:03     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 11/23] mtd: spi-nor: winbond: Add support for W25Q12RV-Q/N Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:47   ` Michael Walle
2026-08-14  9:47     ` Michael Walle
2026-08-20  6:04   ` Takahiro.Kuwano
2026-08-20  6:04     ` Takahiro.Kuwano
2026-08-20  7:32   ` Takahiro.Kuwano
2026-08-20  7:32     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 12/23] mtd: spi-nor: winbond: Add support for W25Q51RV-Q/N Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:47   ` Michael Walle
2026-08-14  9:47     ` Michael Walle
2026-08-20  6:04   ` Takahiro.Kuwano
2026-08-20  6:04     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 13/23] mtd: spi-nor: winbond: Add support for W25Q01RV-Q/N Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:47   ` Michael Walle
2026-08-14  9:47     ` Michael Walle
2026-08-20  6:15   ` Takahiro.Kuwano
2026-08-20  6:15     ` Takahiro.Kuwano
2026-09-02 14:48     ` Miquel Raynal
2026-09-02 14:48       ` Miquel Raynal
2026-08-13 15:19 ` [PATCH v3 14/23] mtd: spi-nor: winbond: Add support for W25Q02RV-Q/N Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:48   ` Michael Walle
2026-08-14  9:48     ` Michael Walle
2026-08-20  6:17   ` Takahiro.Kuwano
2026-08-20  6:17     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 15/23] mtd: spi-nor: winbond: Prepare introduction of W25QxxRV-M parts Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:50   ` Michael Walle
2026-08-14  9:50     ` Michael Walle
2026-08-20  6:18   ` Takahiro.Kuwano
2026-08-20  6:18     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 16/23] mtd: spi-nor: winbond: Add support for W25Q32RV-M Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:50   ` Michael Walle
2026-08-14  9:50     ` Michael Walle
2026-08-20  6:19   ` Takahiro.Kuwano
2026-08-20  6:19     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 17/23] mtd: spi-nor: winbond: Add support for W25Q64RV-M Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:51   ` Michael Walle
2026-08-14  9:51     ` Michael Walle
2026-08-20  6:21   ` Takahiro.Kuwano
2026-08-20  6:21     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 18/23] mtd: spi-nor: winbond: Add support for W25Q12RV-M Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:51   ` Michael Walle
2026-08-14  9:51     ` Michael Walle
2026-08-20  6:44   ` Takahiro.Kuwano
2026-08-20  6:44     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 19/23] mtd: spi-nor: winbond: Add support for W25Q51RV-M Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:52   ` Michael Walle
2026-08-14  9:52     ` Michael Walle
2026-08-20  6:48   ` Takahiro.Kuwano
2026-08-20  6:48     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 20/23] mtd: spi-nor: winbond: Add support for W25Q01RV-M Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:52   ` Michael Walle
2026-08-14  9:52     ` Michael Walle
2026-08-20  6:50   ` Takahiro.Kuwano
2026-08-20  6:50     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 21/23] mtd: spi-nor: winbond: Add support for W25Q02RV-M Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:52   ` Michael Walle
2026-08-14  9:52     ` Michael Walle
2026-08-20  6:52   ` Takahiro.Kuwano
2026-08-20  6:52     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 22/23] mtd: spi-nor: winbond: Add support for W25Q51RV-Q/N/M Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-14  9:53   ` Michael Walle
2026-08-14  9:53     ` Michael Walle
2026-08-20  7:42   ` Takahiro.Kuwano
2026-08-20  7:42     ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 23/23] mtd: spi-nor: debugfs: Expose SR opcodes and QE mask Miquel Raynal
2026-08-13 15:19   ` Miquel Raynal
2026-08-20  7:03   ` Takahiro.Kuwano
2026-08-20  7:03     ` Takahiro.Kuwano

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=874ig87ypd.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=STLin2@winbond.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=corbet@lwn.net \
    --cc=hsinyi@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mwalle@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=skhan@linuxfoundation.org \
    --cc=takahiro.kuwano@infineon.com \
    --cc=thomas.petazzoni@bootlin.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.