Skip to content

ASoC: SOF: ipc4: Fix pipeline state transitions for aggregate DAIs#5765

Open
ujfalusi wants to merge 1 commit into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/aggregated-sdw-trigger
Open

ASoC: SOF: ipc4: Fix pipeline state transitions for aggregate DAIs#5765
ujfalusi wants to merge 1 commit into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/aggregated-sdw-trigger

Conversation

@ujfalusi
Copy link
Copy Markdown
Collaborator

@ujfalusi ujfalusi commented May 7, 2026

For aggregate DAIs (num_cpus > 1) the pre_trigger/post_trigger callbacks send pipeline state IPCs per-DAI without considering that multiple DAIs may share the same pipeline. This causes premature state transitions where the pipeline goes RUNNING before all link DMAs have started, or individual DAIs send redundant IPCs for shared pipelines.

Add a per-pipeline trigger_count to gate state transitions:

  • START/PAUSE_RELEASE: defer RUNNING IPC until all DAIs sharing the same pipeline have completed their link DMA operations
  • STOP/SUSPEND/PAUSE_PUSH: use pipeline state dedup so the PAUSED IPC is sent once regardless of how many DAIs share the pipeline

The per-spipe DAI count is computed dynamically to handle all aggregate topologies: shared pipelines, independent pipelines, and mixed cases.

Copy link
Copy Markdown

Copilot AI left a comment

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 fixes IPC4 pipeline state transitions for aggregate back-end links (num_cpus > 1) where multiple CPU DAIs may share the same SOF pipeline, which can currently cause premature RUNNING transitions and redundant PAUSED IPCs.

Changes:

  • Add a per-pipeline trigger_count to gate START/PAUSE_RELEASE so RUNNING is sent only after all DAIs sharing a pipeline have completed link DMA triggering.
  • Deduplicate STOP/SUSPEND/PAUSE_PUSH PAUSED IPCs for shared pipelines by checking the current pipeline state.
  • Compute the “DAIs-per-pipeline” threshold dynamically per BE link to support shared/independent/mixed aggregate topologies.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sound/soc/sof/sof-audio.h Adds trigger_count to struct snd_sof_pipeline to track aggregate trigger completion per pipeline.
sound/soc/sof/intel/hda-dai-ops.c Adds per-pipeline DAI counting and uses trigger_count to gate RUNNING/PAUSED IPC transitions for aggregate DAIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (!w)
continue;

sw = w->dobj.private;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please check

Comment on lines +443 to +449
int spipe_dais = hda_ipc4_count_spipe_dais(substream,
swidget->spipe);

swidget->spipe->trigger_count++;
swidget->spipe->started_count++;
if (swidget->spipe->trigger_count < spipe_dais)
break;
kv2019i
kv2019i previously approved these changes May 12, 2026
Copy link
Copy Markdown
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Please check the copilot comment on defensive programming. Otherwise complex, but looks good to me.

if (!w)
continue;

sw = w->dobj.private;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please check

For aggregate DAIs (num_cpus > 1) the pre_trigger/post_trigger callbacks
send pipeline state IPCs per-DAI without considering that multiple DAIs
may share the same pipeline. This causes premature state transitions
where the pipeline goes RUNNING before all link DMAs have started, or
individual DAIs send redundant IPCs for shared pipelines.

Add a per-pipeline trigger_count to gate state transitions:
- START/PAUSE_RELEASE: defer RUNNING IPC until all DAIs sharing the
  same pipeline have completed their link DMA operations
- STOP/SUSPEND/PAUSE_PUSH: use pipeline state dedup so the PAUSED IPC
  is sent once regardless of how many DAIs share the pipeline

The per-spipe DAI count is computed dynamically to handle all aggregate
topologies: shared pipelines, independent pipelines, and mixed cases.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi ujfalusi force-pushed the peter/sof/pr/aggregated-sdw-trigger branch from 4f4063d to 22f1037 Compare May 12, 2026 13:04
@ujfalusi
Copy link
Copy Markdown
Collaborator Author

Changes since v1:

  • add NULL pointer check for w->dobj.private
  • correct started_count possible unbalance

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