[PATCH 1/2] soundwire: Suspend and resume managers and peripherals asynchronously
From: Paul Menzel
Date: Fri Nov 27 2026 - 10:03:25 EST
On system resume, the resume callback of a SoundWire peripheral driver
usually waits until the manager has enumerated the peripheral again and the
driver’s update_status callback has re-initialized it. The PM core runs the
callbacks of devices without the async flag one after another in dpm_list
order, so the peripherals on different links wait for each other, and each
of them also waits for all synchronous devices before it in that list.
Apart from the parent-child relation, which the PM core respects for
asynchronous devices, the manager and peripheral devices do not depend on
other devices in the system sleep transitions. Codec drivers that need
their peripherals active, like wcd937x, wcd938x and wcd939x, add device
links, which the PM core respects too. So enable asynchronous suspend and
resume for the managers and the peripherals.
On a Dell XPS 9315 (Alder Lake, SOF), in one cycle, the RT1316 amplifier on
link 2 took 16.3 ms in its resume callback, and the RT714 DMIC codec on
link 3 took 9.9 ms after it. Together with the next patch for the Intel
link devices, the resume callbacks of the two links and the two codecs now
overlap, and their span shrinks from 28.9 ms to 17.1 ms (median of five
s2idle cycles each).
Signed-off-by: Paul Menzel <pmenzel@xxxxxxxxxxxxx>
---
Notes:
The analysis (sleepgraph device callback timings, function traces of the
link start-up), the patch and this commit message were drafted with
claude-opus-5-5 (Claude Code), asked to cut the s2idle resume time of
this laptop, see Documentation/process/generated-content.rst. The tests
are in the commit message and the cover letter.
drivers/soundwire/master.c | 3 +++
drivers/soundwire/slave.c | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/drivers/soundwire/master.c b/drivers/soundwire/master.c
index 440bfc52ccba5..54ce317ab1628 100644
--- a/drivers/soundwire/master.c
+++ b/drivers/soundwire/master.c
@@ -147,6 +147,9 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id);
+ /* the managers of different links can resume in parallel */
+ device_enable_async_suspend(&md->dev);
+
ret = device_register(&md->dev);
if (ret) {
dev_err(parent, "Failed to add master: ret %d\n", ret);
diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
index a7d2938b031d0..3e77c9c586d17 100644
--- a/drivers/soundwire/slave.c
+++ b/drivers/soundwire/slave.c
@@ -84,6 +84,12 @@ int sdw_slave_add(struct sdw_bus *bus,
sdca_lookup_interface_revision(slave);
sdca_lookup_functions(slave);
+ /*
+ * Peripherals wait for their re-initialization on resume, which can
+ * be done for all of them in parallel.
+ */
+ device_enable_async_suspend(&slave->dev);
+
ret = device_register(&slave->dev);
if (ret) {
dev_err(bus->dev, "Failed to add slave: ret %d\n", ret);
--
2.54.0