From: "Michael Walle" <mwalle@kernel.org>
To: "Miquel Raynal" <miquel.raynal@bootlin.com>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Pratyush Yadav" <pratyush@kernel.org>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Jonathan Corbet" <corbet@lwn.net>
Cc: "Sean Anderson" <sean.anderson@linux.dev>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Steam Lin" <STLin2@winbond.com>, <linux-mtd@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<stable@kernel.org>
Subject: Re: [PATCH v2 03/27] mtd: spi-nor: swp: Improve locking user experience
Date: Mon, 09 Feb 2026 11:39:17 +0100 [thread overview]
Message-ID: <DGAD7N254PVR.1PEPJM24A6679@kernel.org> (raw)
In-Reply-To: <20260108-winbond-v6-18-rc1-spi-nor-swp-v2-3-c462ef806130@bootlin.com>
[-- Attachment #1: Type: text/plain, Size: 1227 bytes --]
On Thu Jan 8, 2026 at 5:57 PM CET, Miquel Raynal wrote:
> In the case of the first block being locked (or the few first blocks),
> if the user want to fully unlock the device it has two possibilities:
> - either it asks to unlock the entire device, and this works;
> - or it asks to unlock just the block(s) that are currently locked,
> which fails.
>
> It fails because the conditions "can_be_top" and "can_be_bottom" are
> true. Indeed, in this case, we unlock everything, so the TB bit does not
> matter. However in the current implementation, use_top would be true (as
> this is the favourite option) and lock_len, which in practice should be
> reduced down to 0, is set to "nor->params->size - (ofs + len)" which is
> a positive number. This is wrong.
>
> An easy way is to simply add an extra condition. In the unlock() path,
> if we can achieve the same result from both sides, it means we unlock
> everything and lock_len must simply be 0. A comment is added to clarify
> that logic.
>
> Fixes: 3dd8012a8eeb ("mtd: spi-nor: add TB (Top/Bottom) protect support")
> Cc: stable@kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Michael Walle <mwalle@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: "Michael Walle" <mwalle@kernel.org>
To: "Miquel Raynal" <miquel.raynal@bootlin.com>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Pratyush Yadav" <pratyush@kernel.org>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Jonathan Corbet" <corbet@lwn.net>
Cc: "Sean Anderson" <sean.anderson@linux.dev>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Steam Lin" <STLin2@winbond.com>, <linux-mtd@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<stable@kernel.org>
Subject: Re: [PATCH v2 03/27] mtd: spi-nor: swp: Improve locking user experience
Date: Mon, 09 Feb 2026 11:39:17 +0100 [thread overview]
Message-ID: <DGAD7N254PVR.1PEPJM24A6679@kernel.org> (raw)
In-Reply-To: <20260108-winbond-v6-18-rc1-spi-nor-swp-v2-3-c462ef806130@bootlin.com>
[-- Attachment #1.1: Type: text/plain, Size: 1227 bytes --]
On Thu Jan 8, 2026 at 5:57 PM CET, Miquel Raynal wrote:
> In the case of the first block being locked (or the few first blocks),
> if the user want to fully unlock the device it has two possibilities:
> - either it asks to unlock the entire device, and this works;
> - or it asks to unlock just the block(s) that are currently locked,
> which fails.
>
> It fails because the conditions "can_be_top" and "can_be_bottom" are
> true. Indeed, in this case, we unlock everything, so the TB bit does not
> matter. However in the current implementation, use_top would be true (as
> this is the favourite option) and lock_len, which in practice should be
> reduced down to 0, is set to "nor->params->size - (ofs + len)" which is
> a positive number. This is wrong.
>
> An easy way is to simply add an extra condition. In the unlock() path,
> if we can achieve the same result from both sides, it means we unlock
> everything and lock_len must simply be 0. A comment is added to clarify
> that logic.
>
> Fixes: 3dd8012a8eeb ("mtd: spi-nor: add TB (Top/Bottom) protect support")
> Cc: stable@kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Michael Walle <mwalle@kernel.org>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
[-- Attachment #2: Type: text/plain, Size: 144 bytes --]
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-02-09 10:39 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 16:57 [PATCH v2 00/27] mtd: spi-nor: Enhance software protection Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 01/27] mtd: spi-nor: Drop duplicate Kconfig dependency Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-02-09 10:35 ` Michael Walle
2026-02-09 10:35 ` Michael Walle
2026-01-08 16:57 ` [PATCH v2 02/27] mtd: spi-nor: debugfs: Fix the flags list Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 03/27] mtd: spi-nor: swp: Improve locking user experience Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-02-09 10:39 ` Michael Walle [this message]
2026-02-09 10:39 ` Michael Walle
2026-01-08 16:57 ` [PATCH v2 04/27] mtd: spi-nor: Improve opcodes documentation Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 05/27] mtd: spi-nor: debugfs: Align variable access with the rest of the file Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 06/27] mtd: spi-nor: debugfs: Enhance output Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 07/27] mtd: spi-nor: swp: Explain the MEMLOCK ioctl implementation behaviour Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 08/27] mtd: spi-nor: swp: Clarify a comment Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 09/27] mtd: spi-nor: swp: Use a pointer for SR instead of a single byte Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 10/27] mtd: spi-nor: swp: Create a helper that writes SR, CR and checks Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 11/27] mtd: spi-nor: swp: Rename a mask Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 12/27] mtd: spi-nor: swp: Create a TB intermediate variable Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 13/27] mtd: spi-nor: swp: Create helpers for building the SR register Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 14/27] mtd: spi-nor: swp: Simplify checking the locked/unlocked range Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 15/27] mtd: spi-nor: swp: Cosmetic changes Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 16/27] mtd: spi-nor: Create a local SR cache Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 17/27] mtd: spi-nor: debugfs: Add locking support Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 18/27] mtd: spi-nor: debugfs: Add a locked sectors map Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 19/27] mtd: spi-nor: Add steps for testing locking support Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 20/27] mtd: spi-nor: swp: Add support for the complement feature Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 21/27] mtd: spi-nor: Add steps for testing locking with CMP Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 22/27] mtd: spi-nor: winbond: Add W25H512NWxxAM CMP locking support Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 23/27] mtd: spi-nor: winbond: Add W25H01NWxxAM " Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 24/27] mtd: spi-nor: winbond: Add W25H02NWxxAM " Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 25/27] mtd: spi-nor: winbond: Add W25H01NWxxIQ " Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:57 ` [PATCH v2 26/27] mtd: spi-nor: winbond: Add W25Q01NWxxIM " Miquel Raynal
2026-01-08 16:57 ` Miquel Raynal
2026-01-08 16:58 ` [PATCH v2 27/27] mtd: spi-nor: winbond: Add W25Q02NWxxIM " Miquel Raynal
2026-01-08 16:58 ` Miquel Raynal
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=DGAD7N254PVR.1PEPJM24A6679@kernel.org \
--to=mwalle@kernel.org \
--cc=STLin2@winbond.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=sean.anderson@linux.dev \
--cc=stable@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=tudor.ambarus@linaro.org \
--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.