[PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove

From: Birk Skyum via B4 Relay

Date: Tue Dec 01 2026 - 11:28:18 EST


From: Birk Skyum <birk.skyum@xxxxx>

qcom_swrm_probe() enables runtime PM and autosuspend at the end of
probe, but qcom_swrm_remove() never disables runtime PM and
unconditionally disables and unprepares ctrl->hclk even when runtime
suspend has already released it.

When the controller unbinds and rebinds (on X1E80100 whenever the audio
DSP restarts, because the LPASS chain depends on clocks provided by the
DSP), the unbind warns that hclk is already disabled/unprepared, and the
second probe runs with runtime PM still enabled. sdw_bus_master_add()
then triggers swrm_runtime_resume() before the bus is initialized and
oopses with a NULL pointer dereference in sdw_bus_exit_clk_stop().

Disable runtime PM and autosuspend in qcom_swrm_remove(), release hclk
only if the device is not runtime-suspended, and mark the device
suspended. Tested on a Lenovo Yoga Slim 7x (X1E80100) across ADSP
reloads and five consecutive hibernation cycles.

Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support")
Signed-off-by: Birk Skyum <birk.skyum@xxxxx>
---
drivers/soundwire/qcom.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 6dde94e42..d3fd7ccad 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1789,9 +1789,22 @@ static int qcom_swrm_probe(struct platform_device *pdev)
static void qcom_swrm_remove(struct platform_device *pdev)
{
struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
+ struct device *dev = &pdev->dev;

sdw_bus_master_delete(&ctrl->bus);
- clk_disable_unprepare(ctrl->hclk);
+
+ /*
+ * Balance pm_runtime_enable() in probe. Left enabled, the next probe
+ * after an unbind (the audio DSP restarting unbinds the LPASS chain)
+ * runtime-resumes the controller from sdw_bus_master_add() before its
+ * bus is set up and oopses in sdw_bus_exit_clk_stop(). Runtime suspend
+ * already released hclk, so release it here only if still active.
+ */
+ pm_runtime_disable(dev);
+ pm_runtime_dont_use_autosuspend(dev);
+ if (!pm_runtime_status_suspended(dev))
+ clk_disable_unprepare(ctrl->hclk);
+ pm_runtime_set_suspended(dev);
}

static int __maybe_unused swrm_runtime_resume(struct device *dev)

--
2.56.0