Skip to content

SoundWire: Perform clock stop in system suspend - #5875

Open
bardliao wants to merge 4 commits into
thesofproject:topic/sof-devfrom
bardliao:sdw_clk_stop
Open

SoundWire: Perform clock stop in system suspend#5875
bardliao wants to merge 4 commits into
thesofproject:topic/sof-devfrom
bardliao:sdw_clk_stop

Conversation

@bardliao

Copy link
Copy Markdown
Collaborator

To get lower power consumption when the Peripheral supports clock stop mode 1. And we keep the bus unwakeable because there is no need to wake up the bus in system suspend.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Intel SoundWire suspend flow to explicitly control whether in-band wake is enabled when stopping the bus, with the goal of reducing power by performing clock stop during system suspend and keeping the bus unwakeable in that state.

Changes:

  • Extends the Intel SoundWire stop_bus hardware op and wrapper APIs to include a wake_enable parameter.
  • Updates intel_stop_bus() and suspend/runtime-suspend call sites to pass an explicit wake policy (wake disabled for system suspend; enabled for runtime clock-stop path).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
include/linux/soundwire/sdw_intel.h Extends the stop_bus hw op signature with wake_enable.
drivers/soundwire/intel.h Updates inline wrapper and prototype for sdw_intel_stop_bus()/intel_stop_bus().
drivers/soundwire/intel_bus_common.c Updates intel_stop_bus() signature and removes implicit wake-enable derivation.
drivers/soundwire/intel_auxdevice.c Updates suspend/runtime-suspend call sites to pass explicit wake_enable values.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 213 to 217
if (clock_stop) {
ret = sdw_cdns_clock_stop(cdns, true);
if (ret < 0)
dev_err(dev, "%s: cannot stop clock: %d\n", __func__, ret);
else
wake_enable = true;
}
ujfalusi and others added 4 commits August 12, 2026 20:07
sdw_get_clk_stop_mode() converts slave->dev.driver with
drv_to_sdw_driver() and dereferences the result unconditionally.  A
Peripheral can be attached and enumerated on the bus while it has no
driver bound to it, for example after its codec driver module has been
removed, and in that case slave->dev.driver is NULL.

sdw_bus_prep_clk_stop() walks every Peripheral which has a device
number and is in ATTACHED or ALERT state, so the Manager's runtime
suspend reaches such an unbound Peripheral and the container_of()
arithmetic turns the NULL pointer into a small negative offset:

  BUG: unable to handle page fault for address: fffffffffffffff8
  RIP: 0010:sdw_bus_prep_clk_stop+0x93/0x1d0 [soundwire_bus]
  Call Trace:
   sdw_cdns_clock_stop+0xbe/0x1d0 [soundwire_cadence]
   intel_stop_bus+0xc1/0x100 [soundwire_intel]
   intel_suspend_runtime+0x7b/0x160 [soundwire_intel]
   __rpm_callback+0x57/0x210
   rpm_suspend+0xfc/0x660
   pm_runtime_work+0xa4/0xb0

Take sdw_dev_lock and check slave->probed before looking at the driver,
the same way sdw_slave_clk_stop_callback() and the other clock stop
helpers do, and fall back to the mode advertised by the Peripheral
property when no driver is bound.

Fixes: 922ebc4 ("soundwire: bus: add CLOCK_STOP_MODE1 support back")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Will add a wake_enable paramter to bus_clock ops first.

This reverts commit cce6989.
Currently, we assume the bus is wakeable when the bus clock stops. But
in some case like system suspend, we want to stop the bus but keep the
bus unwakeable.
No function change in this commit.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Perform clock stop with proper mode so that the Peripherals can enter
the deserved power state. And keep the bus unwakeable because there is
no need to wake up the bus in system suspend.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Copilot AI review requested due to automatic review settings August 12, 2026 12:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (3)

drivers/soundwire/bus.c:964

  • sdw_get_clk_stop_mode() reads slave->prop.clk_stop_mode1 before taking slave->sdw_dev_lock, but prop is updated under that mutex during probe (drivers/soundwire/bus_type.c), so this can race with read_prop() when clock stop happens before probe completes. Consider taking the mutex first, reading the property under lock, and also guarding slave->dev.driver before calling drv_to_sdw_driver().
	enum sdw_clk_stop_mode mode;

	mode = slave->prop.clk_stop_mode1 ? SDW_CLK_STOP_MODE1 : SDW_CLK_STOP_MODE0;

	mutex_lock(&slave->sdw_dev_lock);

drivers/soundwire/intel_bus_common.c:209

  • en is a very generic name here; it’s used specifically as the post-clock-stop shim wake enable state. Either rename it (preferred) or at least annotate it to make the intent clearer.
	bool en = false;

drivers/soundwire/intel_auxdevice.c:673

  • This comment line is longer than typical kernel style and is hard to read in reviews/blame. Please wrap it onto multiple lines.
	/* Perform clock stop with proper mode and keep the bus unwakeable in system suspend. */

@bardliao

Copy link
Copy Markdown
Collaborator Author

@plbossart Could you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants