Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption
@ 2026-08-11 15:56 Miquel Raynal
  2026-08-12  9:44 ` Michael Walle
  2026-08-12  9:52 ` Tudor Ambarus
  0 siblings, 2 replies; 6+ messages in thread
From: Miquel Raynal @ 2026-08-11 15:56 UTC (permalink / raw)
  To: Pratyush Yadav, Michael Walle, Takahiro Kuwano,
	Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: Thomas Petazzoni, linux-mtd, linux-kernel, stable, Miquel Raynal

All the parallel locking helpers (spi_nor_prep_and_lock(),
spi_nor_prep_and_lock_pe() and spi_nor_prep_and_lock_rd()) call
spi_nor_prep() then wait with a killable sleep. If the sleep gets
killed, we leave the controller in its prepared state.

Call ->unprepare() in these cases.

Fixes: 74df43b3f626 ("mtd: spi-nor: Enhance locking to support reads while writes")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/spi-nor/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 8bc117b46e02..250e996284f9 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1346,6 +1346,9 @@ int spi_nor_prep_and_lock(struct spi_nor *nor)
 		ret = wait_event_killable(nor->rww.wait,
 					  spi_nor_rww_start_exclusive(nor));
 
+	if (ret)
+		spi_nor_unprep(nor);
+
 	return ret;
 }
 
@@ -1417,6 +1420,9 @@ static int spi_nor_prep_and_lock_pe(struct spi_nor *nor, loff_t start, size_t le
 		ret = wait_event_killable(nor->rww.wait,
 					  spi_nor_rww_start_pe(nor, start, len));
 
+	if (ret)
+		spi_nor_unprep(nor);
+
 	return ret;
 }
 
@@ -1490,6 +1496,9 @@ static int spi_nor_prep_and_lock_rd(struct spi_nor *nor, loff_t start, size_t le
 		ret = wait_event_killable(nor->rww.wait,
 					  spi_nor_rww_start_rd(nor, start, len));
 
+	if (ret)
+		spi_nor_unprep(nor);
+
 	return ret;
 }
 

---
base-commit: db5f6418501f9795a96026b764d747179a231b2b
change-id: 20260811-perso-rww-fixes-016cdd229647

Best regards,
-- 
Miquel Raynal <miquel.raynal@bootlin.com>


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

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

* Re: [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption
  2026-08-11 15:56 [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption Miquel Raynal
@ 2026-08-12  9:44 ` Michael Walle
  2026-08-12 10:05   ` Miquel Raynal
  2026-08-12  9:52 ` Tudor Ambarus
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Walle @ 2026-08-12  9:44 UTC (permalink / raw)
  To: Miquel Raynal, Pratyush Yadav, Takahiro Kuwano,
	Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: Thomas Petazzoni, linux-mtd, linux-kernel, stable

On Tue Aug 11, 2026 at 5:56 PM CEST, Miquel Raynal wrote:
> All the parallel locking helpers (spi_nor_prep_and_lock(),
> spi_nor_prep_and_lock_pe() and spi_nor_prep_and_lock_rd()) call
> spi_nor_prep() then wait with a killable sleep. If the sleep gets
> killed, we leave the controller in its prepared state.
>

Why does this only affect legacy controllers?

> Call ->unprepare() in these cases.
>
> Fixes: 74df43b3f626 ("mtd: spi-nor: Enhance locking to support reads while writes")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Reviewed-by: Michael Walle <mwalle@kernel.org>

-michael

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

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

* Re: [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption
  2026-08-11 15:56 [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption Miquel Raynal
  2026-08-12  9:44 ` Michael Walle
@ 2026-08-12  9:52 ` Tudor Ambarus
  2026-08-12 10:02   ` Miquel Raynal
  1 sibling, 1 reply; 6+ messages in thread
From: Tudor Ambarus @ 2026-08-12  9:52 UTC (permalink / raw)
  To: Miquel Raynal, Pratyush Yadav, Michael Walle, Takahiro Kuwano,
	Richard Weinberger, Vignesh Raghavendra
  Cc: Thomas Petazzoni, linux-mtd, linux-kernel, stable



On 8/11/26 6:56 PM, Miquel Raynal wrote:
> All the parallel locking helpers (spi_nor_prep_and_lock(),
> spi_nor_prep_and_lock_pe() and spi_nor_prep_and_lock_rd()) call
> spi_nor_prep() then wait with a killable sleep. If the sleep gets
> killed, we leave the controller in its prepared state.
> 
> Call ->unprepare() in these cases.


We don't even care about SPI NOR controllers. I stopped adding/accepting
new support for them few years ago, so that we encourage people to update
the drivers to use SPI MEM.

The alternative is to drop prep unprep entirely.

Anyway, all good, regardless the path chosen:

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> 
> Fixes: 74df43b3f626 ("mtd: spi-nor: Enhance locking to support reads while writes")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/mtd/spi-nor/core.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 8bc117b46e02..250e996284f9 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -1346,6 +1346,9 @@ int spi_nor_prep_and_lock(struct spi_nor *nor)
>  		ret = wait_event_killable(nor->rww.wait,
>  					  spi_nor_rww_start_exclusive(nor));
>  
> +	if (ret)
> +		spi_nor_unprep(nor);
> +
>  	return ret;
>  }
>  
> @@ -1417,6 +1420,9 @@ static int spi_nor_prep_and_lock_pe(struct spi_nor *nor, loff_t start, size_t le
>  		ret = wait_event_killable(nor->rww.wait,
>  					  spi_nor_rww_start_pe(nor, start, len));
>  
> +	if (ret)
> +		spi_nor_unprep(nor);
> +
>  	return ret;
>  }
>  
> @@ -1490,6 +1496,9 @@ static int spi_nor_prep_and_lock_rd(struct spi_nor *nor, loff_t start, size_t le
>  		ret = wait_event_killable(nor->rww.wait,
>  					  spi_nor_rww_start_rd(nor, start, len));
>  
> +	if (ret)
> +		spi_nor_unprep(nor);
> +
>  	return ret;
>  }
>  
> 
> ---
> base-commit: db5f6418501f9795a96026b764d747179a231b2b
> change-id: 20260811-perso-rww-fixes-016cdd229647
> 
> Best regards,


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

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

* Re: [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption
  2026-08-12  9:52 ` Tudor Ambarus
@ 2026-08-12 10:02   ` Miquel Raynal
  0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2026-08-12 10:02 UTC (permalink / raw)
  To: Tudor Ambarus
  Cc: Pratyush Yadav, Michael Walle, Takahiro Kuwano,
	Richard Weinberger, Vignesh Raghavendra, Thomas Petazzoni,
	linux-mtd, linux-kernel, stable

On 12/08/2026 at 12:52:48 +03, Tudor Ambarus <tudor.ambarus@linaro.org> wrote:

> On 8/11/26 6:56 PM, Miquel Raynal wrote:
>> All the parallel locking helpers (spi_nor_prep_and_lock(),
>> spi_nor_prep_and_lock_pe() and spi_nor_prep_and_lock_rd()) call
>> spi_nor_prep() then wait with a killable sleep. If the sleep gets
>> killed, we leave the controller in its prepared state.
>> 
>> Call ->unprepare() in these cases.
>
>
> We don't even care about SPI NOR controllers. I stopped adding/accepting
> new support for them few years ago, so that we encourage people to update
> the drivers to use SPI MEM.

Yeah, totally agreed.

> The alternative is to drop prep unprep entirely.

That's indeed what we aim for, but in order to "fix" that report, the
current solution is to call ->unprepare(). Hopefully we can remove them
at some point.

>
> Anyway, all good, regardless the path chosen:
>
> Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>

Thanks,
Miquèl

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

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

* Re: [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption
  2026-08-12  9:44 ` Michael Walle
@ 2026-08-12 10:05   ` Miquel Raynal
  2026-08-12 10:33     ` Michael Walle
  0 siblings, 1 reply; 6+ messages in thread
From: Miquel Raynal @ 2026-08-12 10:05 UTC (permalink / raw)
  To: Michael Walle
  Cc: Pratyush Yadav, Takahiro Kuwano, Richard Weinberger,
	Vignesh Raghavendra, Tudor Ambarus, Thomas Petazzoni, linux-mtd,
	linux-kernel, stable

Hello,

> On Tue Aug 11, 2026 at 5:56 PM CEST, Miquel Raynal wrote:
>> All the parallel locking helpers (spi_nor_prep_and_lock(),
>> spi_nor_prep_and_lock_pe() and spi_nor_prep_and_lock_rd()) call
>> spi_nor_prep() then wait with a killable sleep. If the sleep gets
>> killed, we leave the controller in its prepared state.
>>
>
> Why does this only affect legacy controllers?

Aren't ->prepare()/->unprepare() callbacks only implemented by legacy
spi-nor controllers?

Thanks,
Miquèl

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

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

* Re: [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption
  2026-08-12 10:05   ` Miquel Raynal
@ 2026-08-12 10:33     ` Michael Walle
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Walle @ 2026-08-12 10:33 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Pratyush Yadav, Takahiro Kuwano, Richard Weinberger,
	Vignesh Raghavendra, Tudor Ambarus, Thomas Petazzoni, linux-mtd,
	linux-kernel, stable

On Wed Aug 12, 2026 at 12:05 PM CEST, Miquel Raynal wrote:
> Hello,
>
>> On Tue Aug 11, 2026 at 5:56 PM CEST, Miquel Raynal wrote:
>>> All the parallel locking helpers (spi_nor_prep_and_lock(),
>>> spi_nor_prep_and_lock_pe() and spi_nor_prep_and_lock_rd()) call
>>> spi_nor_prep() then wait with a killable sleep. If the sleep gets
>>> killed, we leave the controller in its prepared state.
>>>
>>
>> Why does this only affect legacy controllers?
>
> Aren't ->prepare()/->unprepare() callbacks only implemented by legacy
> spi-nor controllers?

ah ok :)

-michael

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

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

end of thread, other threads:[~2026-08-12 10:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 15:56 [PATCH] mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption Miquel Raynal
2026-08-12  9:44 ` Michael Walle
2026-08-12 10:05   ` Miquel Raynal
2026-08-12 10:33     ` Michael Walle
2026-08-12  9:52 ` Tudor Ambarus
2026-08-12 10:02   ` Miquel Raynal

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