Skip to content

SoundWire: prevent race condition between sync_arm/config_update/sync_go - #6068

Open
plbossart wants to merge 3 commits into
thesofproject:topic/sof-devfrom
plbossart:sdw/sync_arm_unlocked
Open

plbossart wants to merge 3 commits into
thesofproject:topic/sof-devfrom
plbossart:sdw/sync_arm_unlocked

Conversation

@plbossart

Copy link
Copy Markdown
Member

For some reason only one of the two calls of cdns_init() is
error-checked, align error handling for consistency.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>

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.

🟡 Changes recommended

The CNL operations table omits .sync_arm_unlocked, causing multi-link startup and reset-resume to issue CONFIG_UPDATE/SYNCGO without arming CMDSYNC and breaking required synchronization.

1 open issue
What changed in this PR

This PR aims to prevent Intel SoundWire synchronization races by holding the shared shim lock across the sync-arm, configuration-update, and sync-go sequence during startup and reset-resume.

Changes:

  • Add an unlocked sync-arm callback and platform helpers.
  • Extend locking across the full synchronization sequence.
  • Handle initialization failures and release the lock on error paths.
File Description
include/​linux/​soundwire/​sdw_intel.h Declare and document the unlocked sync-arm callback.
drivers/​soundwire/​intel.h Add the callback dispatch wrapper.
drivers/​soundwire/​intel.c Extract the unlocked legacy Intel sync-arm helper.
drivers/​soundwire/​intel_bus_common.c Serialize startup and reset-resume synchronization, with error-path unlocks.
drivers/​soundwire/​intel_ace2x.c Extract and register the unlocked ACE2.x sync-arm helper.

Review effort: Balanced

Comment thread drivers/soundwire/intel.c Resolved
Comment thread drivers/soundwire/intel_ace2x.c Resolved
AI models report a possible race condition when starting multiple
links. Add new helper to take lock at a higher level, following the
example of sync_go_unlocked.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
AI models expose a possible race condition when starting multiple links in parallel.

Link A:	  	   Link B:
sync_arm	   sync_arm
config_update      ...
sync_go            ...
		   config_update
		   sync_go

The sync_go on Link A would clear the CMDSYNC bit for link B, but the
config_update has not taken place just yet and the second sync_go
would be a no-op - Link B would not start.

The suggested fix is to rely on the shim_lock to start each link in a
more atomic way.

Note that this race condition does not happen during a regular bank
switch where the Cadence IP does not need to be configured. It's the
sync_arm+config_update that's problematic only on startup/resume.

Link: https://lore.kernel.org/linux-sound/0ece6c88-9e3d-4d30-9027-21722bea8754@linux.dev/T/#m74e6c505170df142d8015c93fef1f881e0f5d394
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
@plbossart
plbossart force-pushed the sdw/sync_arm_unlocked branch from bcfca52 to 6225763 Compare December 1, 2026 20:13
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