]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: core: Abort active target transfer on controller suspend
authorPraveen Talari <praveen.talari@oss.qualcomm.com>
Thu, 25 Jun 2026 15:56:02 +0000 (21:26 +0530)
committerMark Brown <broonie@kernel.org>
Thu, 25 Jun 2026 16:43:06 +0000 (17:43 +0100)
When an SPI controller operating in target mode has a transfer in
progress at the time of system suspend, the suspend path proceeds
without aborting the ongoing transfer. This can leave the hardware in
an inconsistent state, potentially causing the system to hang or fail
to resume cleanly.

Fix this by invoking the controller's target_abort callback from
spi_controller_suspend() when the controller is in target mode and the
callback is registered. This ensures any active target transfer is
cleanly terminated before the controller is suspended.

Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
Link: https://patch.msgid.link/20260625-abort_active_transfer_duirng_s2r-v2-1-1d6f724406b6@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c

index d7e584afa301a4bac222b0b3148f2a4aa88f7c8d..f35d288c64fe2bea1f2b9ac5a38d976427407e07 100644 (file)
@@ -3671,6 +3671,9 @@ int spi_controller_suspend(struct spi_controller *ctlr)
 {
        int ret = 0;
 
+       if (ctlr->cur_msg && spi_controller_is_target(ctlr) && ctlr->target_abort)
+               ctlr->target_abort(ctlr);
+
        /* Basically no-ops for non-queued controllers */
        if (ctlr->queued) {
                ret = spi_stop_queue(ctlr);