[PATCH v2 0/2] spi: qcom-geni: Add shutdown and panic notifier support
Praveen Talari <[email protected]>
| Newsgroups | org.kernel.vger.linux-spi,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260818-add-shutdown-and-panic-notifier-for-spi-v2-0-eb25d56634a0@oss.qualcomm.com> |
On VM-based platforms, if an SPI DMA transfer is in progress when the guest is torn down (via reboot/shutdown or a panic/crash), the DMA engine can keep issuing transactions to IOVAs that have already been invalidated as part of teardown. The SMMU then raises context faults, which can affect other VMs sharing the same SMMU instance and obscure the real root cause of the crash. This series adds two independent quiesce paths for the GENI SPI controller so that any in-progress transfer is stopped and the DMA engine is left idle before the IOVA mappings are torn down: - Patch 1 adds a platform shutdown() callback that suspends the SPI controller (via spi_controller_suspend()) on a normal reboot/shutdown path, where sleeping is safe. - Patch 2 registers a panic notifier that cancels/aborts the in-flight command and resets the TX/RX DMA FSMs (or terminates the GPI DMA channels) when the kernel panics, covering the crash path as well. The notifier bails out early if the device is not runtime-active or has no active command, and otherwise uses readl_poll_timeout_atomic() to poll status registers directly instead of waiting on completions/IRQs like the regular error-handling path does, since panic notifiers run with IRQs and preemption disabled. The notifier is registered before devm_spi_register_controller() so a panic during child device probing is still handled. Signed-off-by: Praveen Talari <[email protected]> --- Changes in v2: - Patch 2: instead of just disabling the SPI IRQ (or suspending the controller, which is unsafe in panic context), actively cancel/abort the in-flight command and reset the TX/RX DMA FSMs (or terminate the GPI DMA channels) using atomic-safe register polling (readl_poll_timeout_atomic()), so the DMA engine is actually left idle rather than just having its completion interrupt masked. - Patch 2: skip the quiesce sequence entirely if the device is not runtime-active (pm_runtime_active()) or if there's no active GENI command, to avoid touching registers on a clock-gated SE. - Patch 2: register the panic notifier before devm_spi_register_controller() so a panic during child SPI device probing is still caught. - Link to v1: https://patch.msgid.link/20260805-add-shutdown-and-panic-notifier-for-spi-v1-0-b5db170d491e@oss.qualcomm.com --- Praveen Talari (2): spi: qcom-geni: Add shutdown callback to quiesce hardware on reboot spi: qcom-geni: Add panic notifier to cancel and reset DMA during panic drivers/spi/spi-geni-qcom.c | 78 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) --- base-commit: 9a4cdc958dd79fc6c3b20b51a10debec6ca09fec change-id: 20260804-add-shutdown-and-panic-notifier-for-spi-fa732be7c7dd Best regards, -- Praveen Talari <[email protected]>