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

From: Praveen Talari

Date: Wed Aug 05 2026 - 06:44:00 EST


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.

Register a panic notifier to suspend the SPI controller, stopping the
transfer queue and preventing the DMA engine from issuing further
transactions to invalidated IOVAs.

Signed-off-by: Praveen Talari <praveen.talari@xxxxxxxxxxxxxxxx>
---
drivers/spi/spi-geni-qcom.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index 39d67f19244c..dfd87428e84f 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -14,6 +14,7 @@
#include <linux/io.h>
#include <linux/log2.h>
#include <linux/module.h>
+#include <linux/panic_notifier.h>
#include <linux/platform_device.h>
#include <linux/pm_opp.h>
#include <linux/pm_runtime.h>
@@ -115,6 +116,7 @@ struct spi_geni_master {
struct dma_chan *rx;
int cur_xfer_mode;
const struct geni_spi_desc *dev_data;
+ struct notifier_block panic_nb;
};

static void spi_slv_setup(struct spi_geni_master *mas)
@@ -1073,6 +1075,23 @@ static void spi_geni_shutdown(struct platform_device *pdev)
spi_controller_suspend(spi);
}

+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);
+ return NOTIFY_OK;
+}
+
+static void spi_geni_unregister_notifiers(void *data)
+{
+ struct spi_geni_master *mas = data;
+
+ atomic_notifier_chain_unregister(&panic_notifier_list, &mas->panic_nb);
+}
+
static int spi_geni_probe(struct platform_device *pdev)
{
int ret, irq;
@@ -1161,7 +1180,16 @@ static int spi_geni_probe(struct platform_device *pdev)
if (ret)
return ret;

- 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);
}

static int __maybe_unused spi_geni_runtime_suspend(struct device *dev)

--
2.34.1