[PATCH v2 2/2] soundwire: qcom: force runtime suspend across system sleep

From: Gopi Chandra Sekhar Reddy Kanala

Date: Mon Nov 30 2026 - 02:14:08 EST


The controller only implements runtime PM callbacks and relies on
runtime suspend to stop the bus clock, gate hclk and arm the wake IRQ.
That is not enough across system suspend: from the prepare phase until
the complete phase the PM core holds a runtime PM usage count on every
device, so a controller that is runtime active at that point stays
active until the system resumes. This happens when suspend is entered
within the 3 second autosuspend delay after bus activity, or when a
peripheral driver resumes its device from its own system suspend
callback, as the SDCA class function driver does to quiesce its
interrupts.

The bus clock then keeps running and hclk stays enabled for the whole
suspend. On Qualcomm platforms the LPASS clock votes behind it are held
as well, which keeps CX and DDR from collapsing in s2idle.

Add system sleep callbacks that force the controller into runtime
suspend and undo it on resume. Only do this when it is safe to run the
runtime suspend path with the peripherals still attached:

- The bus supports clock stop. Without it, runtime resume resets the
bus and only re-initializes the peripherals it saw detach, which
peripherals that were never runtime suspended have not done.

- No stream is set up on the bus. A set up stream stays prepared and
enabled across system sleep, and nothing programs its ports again
on resume. Forcing the suspend during playback left the speakers
silent after resume on Glymur CRD.

A controller that is already runtime suspended is left alone, so runtime
PM is not disabled for it any earlier than before.

Signed-off-by: Gopi Chandra Sekhar Reddy Kanala <gopi.kanala@xxxxxxxxxxxxxxxx>
---
drivers/soundwire/qcom.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 4cd9093c303d..954acb499328 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -225,6 +225,7 @@ struct qcom_swrm_ctrl {
u32 slave_status;
u32 wr_fifo_depth;
bool clock_stop_not_supported;
+ bool sleep_forced;
/* Per-Slave SCP_ADDRPAGE1/2 shadow; -1 = unknown. */
s16 page1_cache[SDW_MAX_DEVICES + 1];
s16 page2_cache[SDW_MAX_DEVICES + 1];
@@ -1901,7 +1902,44 @@ static int swrm_runtime_suspend(struct device *dev)
return 0;
}

+static int swrm_suspend(struct device *dev)
+{
+ struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev);
+ bool stream_set_up;
+ int ret;
+
+ if (pm_runtime_status_suspended(dev))
+ return 0;
+
+ scoped_guard(mutex, &ctrl->bus.bus_lock)
+ stream_set_up = !list_empty(&ctrl->bus.m_rt_list);
+
+ if (ctrl->clock_stop_not_supported || stream_set_up)
+ return 0;
+
+ ret = pm_runtime_force_suspend(dev);
+ if (ret)
+ return ret;
+
+ ctrl->sleep_forced = true;
+
+ return 0;
+}
+
+static int swrm_resume(struct device *dev)
+{
+ struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev);
+
+ if (!ctrl->sleep_forced)
+ return 0;
+
+ ctrl->sleep_forced = false;
+
+ return pm_runtime_force_resume(dev);
+}
+
static const struct dev_pm_ops swrm_dev_pm_ops = {
+ SYSTEM_SLEEP_PM_OPS(swrm_suspend, swrm_resume)
RUNTIME_PM_OPS(swrm_runtime_suspend, swrm_runtime_resume, NULL)
};


--
2.43.0