Re: [PATCH 1/5] spi: spi-mem: Add support for panic mem writes

From: Mark Brown

Date: Thu Oct 08 2026 - 04:41:45 EST


On Mon, Oct 05, 2026 at 10:11:36AM +0200, Paul Cercueil wrote:
> From: Tanmay Jagdale <tanmay@xxxxxxxxxxx>
>
> Add a 'panic_write' flag to the controller's capabilities struct.
> When set, the SPI controller indicates that it will be able to send
> commands to a connected NOR or NAND memory in the context of a kernel
> panic, which means without sleeping and without relying on IRQs.

> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -398,6 +398,31 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
> u8 *tmpbuf;
> int ret;
>
> + if (op->panic_write) {
> + if (!spi_mem_controller_is_capable(ctlr, panic_write))
> + return -EOPNOTSUPP;
> + /*
> + * Only support panic writes if we'll go through .exec_op().
> + * The regular SPI path (spi_sync(), etc.) explicitly mentions
> + * that it can only be used from a context that may sleep, which
> + * is not the case on a kernel panic.
> + * If this changes in the future, this could be reworked, but
> + * for now this will have to do.
> + */

This also needs to ensure that the queue is idle - we'll still execute
spi_mem_access_start() which flushes the queue, and we've got runtime PM
operations there which might be a bit challenging in a panic situation.

Attachment: signature.asc
Description: PGP signature