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

Paul Cercueil paul.cercueil at bootlin.com
Tue Oct 13 01:25:07 PDT 2026


Hi Mark,

Le jeudi 08 octobre 2026 à 10:32 +0200, Mark Brown a écrit :
> On Mon, Oct 05, 2026 at 10:11:36AM +0200, Paul Cercueil wrote:
> > From: Tanmay Jagdale <tanmay at marvell.com>
> > 
> > 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.

Does it though? The kernel is panicking so the queue won't be processed anymore,
it should be fine to just ignore it.

ACK for the PM - I think in the V2 I'll just bail if the controller has auto-
runtime-PM on.

-- 
Paul Cercueil, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



More information about the linux-mtd mailing list