Re: [PATCH 2/2] spi: qcom-geni: Add panic notifier to suspend controller during panic

From: Praveen Talari

Date: Tue Aug 18 2026 - 01:35:27 EST


Hi Mark,

On 11-08-2026 20:06, Mark Brown wrote:
On Wed, Aug 05, 2026 at 04:12:10PM +0530, Praveen Talari wrote:
When a VM crashes with an active SPI DMA transfer in progress, the
SMMU raises context faults as the DMA engine continues to access
IOVAs that are invalidated when the VM's memory context is torn down.
These faults can affect other VMs sharing the same SMMU instance and
obscure the root cause of the crash.
+static int spi_geni_panic_notifier(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct spi_geni_master *mas = container_of(nb, struct spi_geni_master, panic_nb);
+ struct spi_controller *spi = dev_get_drvdata(mas->dev);
+
+ spi_controller_suspend(spi);
This will take locks - are you sure that's OK in a panic handler?
Good point. I hadn't considered the locking requirements of
spi_controller_suspend(). Looking at the implementation, it can take
locks and is therefore not suitable for panic context.

I'll rework this to avoid invoking the SPI core suspend path from the
panic notifier and instead use a panic-safe mechanism that directly
quiesces the controller without taking sleeping locks.

- return devm_spi_register_controller(dev, spi);
+ ret = devm_spi_register_controller(dev, spi);
+ if (ret)
+ return ret;
+
+ mas->panic_nb.notifier_call = spi_geni_panic_notifier;
+ ret = atomic_notifier_chain_register(&panic_notifier_list, &mas->panic_nb);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, spi_geni_unregister_notifiers, mas);
Should we have the notifier in place before registation, what happens if
we panic while probing a SPI device which is probing as a result of
registering the controller?
You're right. There is a window between
devm_spi_register_controller() and notifier registration where a panic
could occur while a child SPI device is probing and issuing transfers.

I'll move the notifier registration before controller registration so
that panic handling is active before any client device can start using

the controller.


Thanks,

Praveen Talari