* [PATCH] soundwire: qcom: handle interface clock failure on runtime resume
@ 2026-11-29 19:25 Jiawen Liu
2026-11-29 19:43 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Jiawen Liu @ 2026-11-29 19:25 UTC (permalink / raw)
To: Srinivas Kandagatla, Vinod Koul, Bard Liao
Cc: Pierre-Louis Bossart, linux-arm-msm, linux-sound
After runtime suspend releases the interface clock, PCM startup can
request a runtime resume. On SDM845 with WCD9340, an RPMh active vote
for the parent clock can time out during clk_prepare_enable().
swrm_runtime_resume() ignores the error, enables the main IRQ and
accesses controller registers. Runtime PM then marks the controller
active, so callers can proceed with I/O without the interface clock.
Return the clock error before enabling the main IRQ or accessing the
controller. Keep masking the optional wake IRQ before the clock call
to prevent an asserted level-triggered wake IRQ from retriggering on
failure. Unbind can proceed after a failed resume, so disable runtime
PM during remove and release the clock only if the controller is
still active.
Verification covered source review,
arm64 builds of qcom.o with CONFIG_PM enabled and disabled, and
git diff --check and checkpatch.pl. Runtime and hardware reproduction
were not performed.
Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
drivers/soundwire/qcom.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index a4cb62897192e..0274957d1e48a 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1787,7 +1787,9 @@ static void qcom_swrm_remove(struct platform_device *pdev)
struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
sdw_bus_master_delete(&ctrl->bus);
- clk_disable_unprepare(ctrl->hclk);
+ pm_runtime_disable(ctrl->dev);
+ if (!pm_runtime_status_suspended(ctrl->dev))
+ clk_disable_unprepare(ctrl->hclk);
}
static int __maybe_unused swrm_runtime_resume(struct device *dev)
@@ -1800,7 +1802,10 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
disable_irq_nosync(ctrl->wake_irq);
}
- clk_prepare_enable(ctrl->hclk);
+ ret = clk_prepare_enable(ctrl->hclk);
+ if (ret)
+ return ret;
+
enable_irq(ctrl->irq);
if (ctrl->clock_stop_not_supported) {
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] soundwire: qcom: handle interface clock failure on runtime resume
2026-11-29 19:25 [PATCH] soundwire: qcom: handle interface clock failure on runtime resume Jiawen Liu
@ 2026-11-29 19:43 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-29 19:43 UTC (permalink / raw)
To: Jiawen Liu; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] soundwire: qcom: pm_runtime_disable() called after
sdw_bus_master_delete()
--
commit 0bb49a0cfd730102126279a4ada1a6ea8640b778
Author: Jiawen Liu <liu1298662399@gmail.com>
soundwire: qcom: handle interface clock failure on runtime resume
This commit checks the return value of clk_prepare_enable() in
swrm_runtime_resume() and updates qcom_swrm_remove() to disable runtime PM
and only disable the interface clock if the device is not runtime
suspended.
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index a4cb62897192e..0274957d1e48a 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -1787,7 +1787,9 @@ static void qcom_swrm_remove(struct platform_device *pdev)
> struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
>
> sdw_bus_master_delete(&ctrl->bus);
> - clk_disable_unprepare(ctrl->hclk);
> + pm_runtime_disable(ctrl->dev);
> + if (!pm_runtime_status_suspended(ctrl->dev))
> + clk_disable_unprepare(ctrl->hclk);
> }
[Severity: Medium]
Should pm_runtime_disable(ctrl->dev) be called before
sdw_bus_master_delete(&ctrl->bus)?
__device_release_driver() drops its runtime PM reference via
pm_runtime_put_sync() before calling qcom_swrm_remove(), so ctrl->dev
enters remove with usage_count == 0 and runtime PM still enabled. While
sdw_bus_master_delete() unregisters active child slaves,
pm_runtime_reinit() decrements ctrl->dev->power.child_count and queues an
async runtime suspend on ctrl->dev (or the autosuspend timer can fire):
CPU0 CPU1 (pm_wq)
qcom_swrm_remove()
sdw_bus_master_delete(&ctrl->bus)
device_for_each_child(...,
sdw_delete_slave)
device_unregister(&slave->dev)
...
pm_request_idle(ctrl->dev)
swrm_runtime_suspend()
sdw_bus_prep_clk_stop(&ctrl->bus)
list_for_each_entry(slave,
&bus->slaves, node)
list_del_init(&slave->node)
put_device(&slave->dev) <-- list corruption / UAF
pm_runtime_disable(ctrl->dev)
Calling pm_runtime_disable(ctrl->dev) before sdw_bus_master_delete()
matches the reverse of qcom_swrm_probe() and waits for any in-flight
runtime PM transitions before tearing down the bus.
--
Sashiko AI review · https://sashiko.dev/#/patchset/179598033513.2.3324784559138164822.pattern-ext-053.3@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 19:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 19:25 [PATCH] soundwire: qcom: handle interface clock failure on runtime resume Jiawen Liu
2026-11-29 19:43 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox