* [PATCH] spi: core: Abort active target transfer on controller suspend
@ 2026-06-25 5:39 Praveen Talari
2026-06-25 13:27 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Praveen Talari @ 2026-06-25 5:39 UTC (permalink / raw)
To: Mark Brown, bjorn.andersson, Konrad Dybcio
Cc: linux-arm-msm, linux-spi, linux-kernel, Mukesh Kumar Savaliya,
aniket.randive, chandana.chiluveru, Praveen Talari
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>
---
drivers/spi/spi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 76e3563c523f..2a96921ca55b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3667,6 +3667,9 @@ int spi_controller_suspend(struct spi_controller *ctlr)
{
int ret = 0;
+ if (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);
---
base-commit: b99ae45861eccff1e1d8c7b05a13650be805d437
change-id: 20260605-abort_active_transfer_duirng_s2r-ce4e79896e7a
Best regards,
--
Praveen Talari <praveen.talari@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: core: Abort active target transfer on controller suspend
2026-06-25 5:39 [PATCH] spi: core: Abort active target transfer on controller suspend Praveen Talari
@ 2026-06-25 13:27 ` Mark Brown
2026-06-25 14:59 ` Praveen Talari
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2026-06-25 13:27 UTC (permalink / raw)
To: Praveen Talari
Cc: bjorn.andersson, Konrad Dybcio, linux-arm-msm, linux-spi,
linux-kernel, Mukesh Kumar Savaliya, aniket.randive,
chandana.chiluveru
[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]
On Thu, Jun 25, 2026 at 11:09:35AM +0530, Praveen Talari wrote:
> 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.
>
> + if (spi_controller_is_target(ctlr) && ctlr->target_abort)
> + ctlr->target_abort(ctlr);
> +
We need to check for an active message here, drivers are going to
assume there's an in progress operation to cancel - for example the
pxa2xx driver unconditionally sets cur_msg->status during abort which is
going to go badly without a cur_msg.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: core: Abort active target transfer on controller suspend
2026-06-25 13:27 ` Mark Brown
@ 2026-06-25 14:59 ` Praveen Talari
2026-06-25 15:08 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Praveen Talari @ 2026-06-25 14:59 UTC (permalink / raw)
To: Mark Brown
Cc: bjorn.andersson, Konrad Dybcio, linux-arm-msm, linux-spi,
linux-kernel, Mukesh Kumar Savaliya, aniket.randive,
chandana.chiluveru
Hi Mark
On 25-06-2026 18:57, Mark Brown wrote:
> On Thu, Jun 25, 2026 at 11:09:35AM +0530, Praveen Talari wrote:
>> 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.
>>
>> + if (spi_controller_is_target(ctlr) && ctlr->target_abort)
>> + ctlr->target_abort(ctlr);
>> +
> We need to check for an active message here, drivers are going to
> assume there's an in progress operation to cancel - for example the
> pxa2xx driver unconditionally sets cur_msg->status during abort which is
> going to go badly without a cur_msg.
Yes, i got it. Our spi driver had that check in target_abort.
is it fine?
if (ctrl->cur_msg && spi_controller_is_target(ctlr) && ctlr->target_abort)
Thanks,
Praveen Talari
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: core: Abort active target transfer on controller suspend
2026-06-25 14:59 ` Praveen Talari
@ 2026-06-25 15:08 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-06-25 15:08 UTC (permalink / raw)
To: Praveen Talari
Cc: bjorn.andersson, Konrad Dybcio, linux-arm-msm, linux-spi,
linux-kernel, Mukesh Kumar Savaliya, aniket.randive,
chandana.chiluveru
[-- Attachment #1: Type: text/plain, Size: 537 bytes --]
On Thu, Jun 25, 2026 at 08:29:05PM +0530, Praveen Talari wrote:
> On 25-06-2026 18:57, Mark Brown wrote:
> > We need to check for an active message here, drivers are going to
> > assume there's an in progress operation to cancel - for example the
> > pxa2xx driver unconditionally sets cur_msg->status during abort which is
> > going to go badly without a cur_msg.
> Yes, i got it. Our spi driver had that check in target_abort.
> is it fine?
> if (ctrl->cur_msg && spi_controller_is_target(ctlr) && ctlr->target_abort)
I think so.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-25 15:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-25 5:39 [PATCH] spi: core: Abort active target transfer on controller suspend Praveen Talari
2026-06-25 13:27 ` Mark Brown
2026-06-25 14:59 ` Praveen Talari
2026-06-25 15:08 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®