[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DEBQ9IUDZJ7T.33VMFGMNKPEUY@kernel.org>
Date: Tue, 18 Nov 2025 10:53:42 +0100
From: "Michael Walle" <mwalle@...nel.org>
To: "Miquel Raynal" <miquel.raynal@...tlin.com>, "Tudor Ambarus"
<tudor.ambarus@...aro.org>, "Pratyush Yadav" <pratyush@...nel.org>,
"Richard Weinberger" <richard@....at>, "Vignesh Raghavendra"
<vigneshr@...com>, "Jonathan Corbet" <corbet@....net>
Cc: "Sean Anderson" <sean.anderson@...ux.dev>, "Thomas Petazzoni"
<thomas.petazzoni@...tlin.com>, "Steam Lin" <STLin2@...bond.com>,
<linux-mtd@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<linux-doc@...r.kernel.org>
Subject: Re: [PATCH 06/19] mtd: spi-nor: swp: Explain the MEMLOCK ioctl
implementation behaviour
On Fri Nov 14, 2025 at 6:53 PM CET, Miquel Raynal wrote:
> Add comments about how these requests are actually handled in the SPI
> NOR core. Their behaviour was not entirely clear to me at first, and
> explaining them in plain English sounds the way to go.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@...tlin.com>
> ---
> drivers/mtd/spi-nor/swp.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c
> index 9bc5a356444665ad8824e9e12d679fd551b3e67d..ede03f26de3c65ff53c1cb888c2c43aea268b85a 100644
> --- a/drivers/mtd/spi-nor/swp.c
> +++ b/drivers/mtd/spi-nor/swp.c
> @@ -341,6 +341,14 @@ static int spi_nor_sr_is_locked(struct spi_nor *nor, loff_t ofs, u64 len)
> return spi_nor_is_locked_sr(nor, ofs, len, nor->bouncebuf[0]);
> }
>
> +/*
> + * These ioctls behave according to the following rules:
> + * ->lock(): Never locks more than what is requested, ie. may lock less
That behavior sounds so wrong... The user requests a region to be
locked, and it isn't actually locked.
> + * ->unlock(): Never unlocks more than what is requested, ie. may unlock less
That seems somewhat sane.
Maybe we should return -EINVAL if ofs or ofs+len aren't at sector
boundaries. Yeah it's a change in the UAPI, but I'm not sure the
current behavior is not harmful and misleading.
> + * -is_locked(): Checks if the region is *fully* locked, returns false otherwise.
> + * This feeback may be misleading because users may get an "unlocked"
> + * status even though a subpart of the region is effectively locked.
> + */
> static const struct spi_nor_locking_ops spi_nor_sr_locking_ops = {
> .lock = spi_nor_sr_lock,
> .unlock = spi_nor_sr_unlock,
Anyway, as it is how it's currently behaving:
Reviewed-by: Michael Walle <mwalle@...nel.org>
-michael
Download attachment "signature.asc" of type "application/pgp-signature" (298 bytes)
Powered by blists - more mailing lists