* [PATCH 0/2] soundwire: Suspend and resume asynchronously
@ 2026-11-27 15:00 Paul Menzel
2026-11-27 15:00 ` [PATCH 1/2] soundwire: Suspend and resume managers and peripherals asynchronously Paul Menzel
2026-11-27 15:00 ` [PATCH 2/2] soundwire: intel: Suspend and resume the links asynchronously Paul Menzel
0 siblings, 2 replies; 3+ messages in thread
From: Paul Menzel @ 2026-11-27 15:00 UTC (permalink / raw)
To: Vinod Koul, Bard Liao, Pierre-Louis Bossart
Cc: Paul Menzel, linux-sound, linux-kernel
On system resume, the SoundWire devices are resumed synchronously, so the
codecs on different links wait for each other’s re-enumeration, and the
whole audio subtree waits for every synchronous device before it in
dpm_list. On a Dell XPS 9315 (Alder Lake, SOF, RT1316 on link 2, RT714 on
link 3), the four resume callbacks run one after the other, in one cycle:
soundwire_intel.link.2 2.2 ms
sdw:0:2:025d:1316:01 16.3 ms
soundwire_intel.link.3 2.2 ms
sdw:0:3:025d:0714:01 9.9 ms
Their span is 28.9 ms. With both patches, the callbacks overlap, and the
span drops to 17.1 ms (median of five s2idle cycles each, sleepgraph with
the device callback trace events). It is on the critical path of the resume
with the panel on, right behind SOF, which waits for i915 through its
device link.
Patch 1 marks the generic manager and peripheral devices, patch 2 the Intel
link devices. The SHIM registers are shared by the links; patch 2 explains
why the multi-link SYNC arm and SYNCGO sequence in intel_start_bus()
tolerates two links interleaving. It is the part I am least sure about, so
please check it. The second link’s power-up waits on shim_lock, so in 49 of
50 traced cycles the start-up was serial anyway; in one cycle both links
were armed before the first SYNCGO, and the bus came up fine. If you
prefer, I can serialize intel_start_bus() across links instead; it takes
about 0.1 ms per link.
Not tested: AMD and Qualcomm managers, and peripherals of other codec
drivers. Patch 1 changes the ordering against synchronous devices that are
neither descendants nor device-link consumers of the peripherals. The
WCD93xx codecs have device links. The deferred resume work of the ASoC card
can now run while a codec still waits for its re-initialization; with the
RT1316 and RT715 SDCA drivers, its register writes then end up in the
regmap cache, which the codec syncs afterwards. I checked the other drivers
only by reading the code. Suspend is now asynchronous as well, which I did
not measure.
Tested on the Dell XPS 9315 with 7.4-rc4, these and unrelated resume
patches: 50 s2idle cycles, each followed by 1 s of playback to the RT1316
and 1 s of capture from the RT714 (non-zero samples), with no errors in the
log; also 30 resume stress cycles in an earlier run. The series is based on
soundwire/next and only compile-tested there (W=1).
The analysis, the patches and the messages were drafted with
claude-opus-5-5 (Claude Code), asked to cut the s2idle resume time of the
laptop, see Documentation/process/generated-content.rst.
Paul Menzel (2):
soundwire: Suspend and resume managers and peripherals asynchronously
soundwire: intel: Suspend and resume the links asynchronously
drivers/soundwire/intel_init.c | 3 +++
drivers/soundwire/master.c | 3 +++
drivers/soundwire/slave.c | 6 ++++++
3 files changed, 12 insertions(+)
base-commit: d9ea256ee889f3db9f0bd07ce5d114ce92e31b4f
--
2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] soundwire: Suspend and resume managers and peripherals asynchronously
2026-11-27 15:00 [PATCH 0/2] soundwire: Suspend and resume asynchronously Paul Menzel
@ 2026-11-27 15:00 ` Paul Menzel
2026-11-27 15:00 ` [PATCH 2/2] soundwire: intel: Suspend and resume the links asynchronously Paul Menzel
1 sibling, 0 replies; 3+ messages in thread
From: Paul Menzel @ 2026-11-27 15:00 UTC (permalink / raw)
To: Vinod Koul, Bard Liao, Pierre-Louis Bossart
Cc: Paul Menzel, linux-sound, linux-kernel
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@molgen.mpg.de>
---
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] soundwire: intel: Suspend and resume the links asynchronously
2026-11-27 15:00 [PATCH 0/2] soundwire: Suspend and resume asynchronously Paul Menzel
2026-11-27 15:00 ` [PATCH 1/2] soundwire: Suspend and resume managers and peripherals asynchronously Paul Menzel
@ 2026-11-27 15:00 ` Paul Menzel
1 sibling, 0 replies; 3+ messages in thread
From: Paul Menzel @ 2026-11-27 15:00 UTC (permalink / raw)
To: Vinod Koul, Bard Liao, Pierre-Louis Bossart
Cc: Paul Menzel, linux-sound, linux-kernel
The link devices are auxiliary devices of the audio controller, and without
the async flag the PM core resumes them one after another, and after all
synchronous devices before them in dpm_list. Each link is the parent of its
manager device, so with the async managers and peripherals from the
previous patch, the peripherals on a link still wait for the synchronous
links.
The links share the SHIM registers. Their accesses are serialized by
shim_lock, so link power-up stays sequential. With multi-link
synchronization enabled, intel_start_bus() arms the link in the SYNC
register, initializes the Cadence IP and triggers SYNCGO, which releases
all armed links. If two links interleave there, the first SYNCGO releases
both: a configuration the second link has already written is applied
together with the first one, a later one right away, and the second SYNCGO
finds no armed link. Runtime resume, which goes through the same arm and
SYNCGO sequence, is not serialized across links either.
So enable asynchronous suspend and resume for the link devices too.
On a Dell XPS 9315 (Alder Lake, SOF) with one codec each on links 2 and 3,
the resume callbacks of the links and their codecs now take 17.1 ms instead
of 28.9 ms (median of five s2idle cycles each, both patches). In 49 of 50
traced s2idle cycles, the second link armed 0.06 to 0.32 ms after the first
link’s SYNCGO, because its power-up waits on shim_lock. In one cycle, the
first link’s worker stalled for 0.65 ms after arming (moving from CPU 2 to
CPU 4), so both links wrote CONFIG_UPDATE before the first SYNCGO, and the
two SYNCGO writes followed within 1 us. After each cycle, including that
one, playback to the RT1316 and capture from the RT714 worked.
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
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/intel_init.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index ad48d67fa9358..7fcfce0d2133b 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -98,6 +98,9 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
return ERR_PTR(ret);
}
+ /* accesses to the shared SHIM registers are serialized by shim_lock */
+ device_enable_async_suspend(&auxdev->dev);
+
ret = auxiliary_device_add(&ldev->auxdev);
if (ret < 0) {
dev_err(res->parent, "failed to add link dev %s link_id %d\n",
--
2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-27 15:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 15:00 [PATCH 0/2] soundwire: Suspend and resume asynchronously Paul Menzel
2026-11-27 15:00 ` [PATCH 1/2] soundwire: Suspend and resume managers and peripherals asynchronously Paul Menzel
2026-11-27 15:00 ` [PATCH 2/2] soundwire: intel: Suspend and resume the links asynchronously Paul Menzel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®