* [PATCH] soundwire: qcom: re-arm the controller interrupt after gating the clock
@ 2026-11-28 7:44 Gopi Chandra Sekhar Reddy Kanala
2026-11-28 8:09 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Gopi Chandra Sekhar Reddy Kanala @ 2026-11-28 7:44 UTC (permalink / raw)
To: Srinivas Kandagatla, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
Oleg Keri, Dmitry Baryshkov
Cc: linux-arm-msm, linux-sound, linux-kernel,
Gopi Chandra Sekhar Reddy Kanala
Commit 6c067677192f ("soundwire: qcom: disable the interrupt before
gating the clock") correctly stopped the interrupt thread from racing
with clk_disable_unprepare() in swrm_runtime_suspend(), but it also
leaves the controller interrupt masked for the whole duration of clock
stop, which breaks peripheral-initiated wake.
The driver is otherwise set up to service peripheral alerts while the
clock is stopped. swrm_runtime_suspend() masks only MASTER_CLASH_DET
out of ctrl->intr_mask before writing INTERRUPT_CPU_EN, deliberately
leaving SLAVE_PEND_IRQ enabled, and qcom_swrm_irq_handler() brackets
itself with clk_prepare_enable()/clk_disable_unprepare() so that it can
run while the controller is runtime suspended. From there
sdw_handle_slave_alerts() takes a pm_runtime reference on the
peripheral, which resumes the controller and restarts the bus clock
before any register is read over the bus.
With the interrupt masked at the interrupt controller for the whole
idle window that chain never starts. On glymur an SDCA jack insert or
removal while the bus is idle is not reported at all: the alert stays
latched in the codec until something else resumes the bus, such as the
start of playback. Platforms that do not describe a usable wake
interrupt have nothing to fall back on.
disable_irq() is the synchronous variant, so by the time it returns any
in-flight handler has been flushed. That is all the race needed: once
the clock is gated, re-arming is safe because the handler enables the
clock itself. Re-arm at the end of swrm_runtime_suspend() and drop the
now unbalanced enable_irq() from swrm_runtime_resume().
Fixes: 6c067677192f ("soundwire: qcom: disable the interrupt before gating the clock")
Signed-off-by: Gopi Chandra Sekhar Reddy Kanala <gopi.kanala@oss.qualcomm.com>
---
The commit this fixes is currently only in linux-next and has not
appeared in a release, so there is no stable backport to do.
---
drivers/soundwire/qcom.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index a4cb62897192..05ef7bb2c5f7 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1801,7 +1801,6 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
}
clk_prepare_enable(ctrl->hclk);
- enable_irq(ctrl->irq);
if (ctrl->clock_stop_not_supported) {
reinit_completion(&ctrl->enumeration);
@@ -1893,6 +1892,8 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
usleep_range(300, 305);
+ enable_irq(ctrl->irq);
+
if (ctrl->wake_irq > 0) {
if (irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq)))
enable_irq(ctrl->wake_irq);
---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20261128-sdw-qcom-irq-207ea053d898
Best regards,
--
Gopi Chandra Sekhar Reddy Kanala <gopi.kanala@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] soundwire: qcom: re-arm the controller interrupt after gating the clock
2026-11-28 7:44 [PATCH] soundwire: qcom: re-arm the controller interrupt after gating the clock Gopi Chandra Sekhar Reddy Kanala
@ 2026-11-28 8:09 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-28 8:09 UTC (permalink / raw)
To: Gopi Chandra Sekhar Reddy Kanala; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] soundwire: qcom: pending CLK_STOP_FINISHED_V2 replay in
swrm_runtime_suspend()
--
commit 650a30f5b562334bca4f136e5ca1ea065589e930
Author: Gopi Chandra Sekhar Reddy Kanala <gopi.kanala@oss.qualcomm.com>
soundwire: qcom: re-arm the controller interrupt after gating the clock
This commit re-enables the SoundWire controller IRQ at the end of
swrm_runtime_suspend() after gating hclk and removes the corresponding
enable_irq() from swrm_runtime_resume() so that peripheral alerts can
wake the controller while the clock is stopped.
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index a4cb62897192e..05ef7bb2c5f7f 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
[ ... ]
> @@ -1893,6 +1892,8 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
>
> usleep_range(300, 305);
>
> + enable_irq(ctrl->irq);
> +
> if (ctrl->wake_irq > 0) {
> if (irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq)))
> enable_irq(ctrl->wake_irq);
[Severity: High]
Can calling enable_irq(ctrl->irq) here replay a pending
SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED_V2 interrupt and pulse ctrl->hclk
while the bus is in Clock Stop Mode 0?
swrm_runtime_suspend() only masks SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET
in SWRM_REG_INTERRUPT_CPU_EN, leaving
SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED_V2 enabled, and ctrl->irq is
requested with IRQF_TRIGGER_RISING. When sdw_bus_clk_stop() broadcasts
ClockStopNow, SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED wakes
qcom_swrm_irq_handler() and completes ctrl->broadcast, while
CLK_STOP_FINISHED_V2 can assert at the frame boundary after
disable_irq(ctrl->irq) and before clk_disable_unprepare(ctrl->hclk)
finishes gating the clock:
CPU0 CPU1
swrm_runtime_suspend() qcom_swrm_irq_handler()
sdw_bus_clk_stop()
complete(&ctrl->broadcast)
...
disable_irq(ctrl->irq)
<hardirq: CLK_STOP_FINISHED_V2>
handle_fasteoi_irq()
/* sets IRQS_PENDING, masks line */
clk_disable_unprepare(ctrl->hclk)
usleep_range(300, 305)
enable_irq(ctrl->irq)
check_irq_resend()
qcom_swrm_irq_handler()
clk_prepare_enable(ctrl->hclk)
/* CLK_STOP_FINISHED_V2 is a no-op */
clk_disable_unprepare(ctrl->hclk)
<-- pulses bus clock while stopped
Because SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED_V2 is a no-op in
qcom_swrm_irq_handler() and does not resume the controller, the replayed
handler toggles ctrl->hclk on and off without a clock-stop exit or entry
sequence. On platforms such as x1e80100 and glymur where hclk is the
SoundWire bus clock itself, pulsing the clock while peripherals are in
clock stop corrupts peripheral state and causes subsequent clock-stop
exit failures (bus clash, parity errors, AUTO_ENUM_FAILED).
Masking SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED_V2 alongside
SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET in SWRM_REG_INTERRUPT_CPU_EN
before issuing sdw_bus_clk_stop() (or leaving only SLAVE_PEND_IRQ
enabled during clock stop) would prevent CLK_STOP_FINISHED_V2 from being
latched while ctrl->irq is disabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-sdw-qcom-irq-v1-1-d053ac530faa@oss.qualcomm.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 8:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 7:44 [PATCH] soundwire: qcom: re-arm the controller interrupt after gating the clock Gopi Chandra Sekhar Reddy Kanala
2026-11-28 8:09 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox