Skip to content

ASoC: SOF: Intel: 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: Intel: 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

@ujfalusiujfalusi commented May 7, 2026

Copy link
Copy Markdown
Collaborator

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.

Fix this by checking the HDA stream running state in post_trigger:

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

The running-state check naturally handles all aggregate topologies:
shared pipelines, independent pipelines, and mixed cases without
requiring per-pipeline counters.

CopilotAI 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 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.

FileDescription
sound/soc/sof/sof-audio.hAdds trigger_count to struct snd_sof_pipeline to track aggregate trigger completion per pipeline.
sound/soc/sof/intel/hda-dai-ops.cAdds 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 threadsound/soc/sof/intel/hda-dai-ops.c Outdated
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

@kv2019ikv2019i left a comment

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 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

@ujfalusi
ujfalusiforce-pushed the peter/sof/pr/aggregated-sdw-trigger branch from 4f4063d to 22f1037CompareMay 12, 2026 13:04
@ujfalusi

Copy link
Copy Markdown
CollaboratorAuthor

Changes since v1:

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

CopilotAI review requested due to automatic review settings May 13, 2026 07:17
@ujfalusi
ujfalusiforce-pushed the peter/sof/pr/aggregated-sdw-trigger branch from 22f1037 to 763f980CompareMay 13, 2026 07:17
@ujfalusiujfalusi changed the title ASoC: SOF: ipc4: Fix pipeline state transitions for aggregate DAIsASoC: SOF: Intel: Fix pipeline state transitions for aggregate DAIsMay 13, 2026
@ujfalusi

Copy link
Copy Markdown
CollaboratorAuthor

Changes since v2: new approach to drop the changes outside of sof/intel code

  • remove the counter for triggers
  • use the channel's state as indication of it is running
  • the logic otherwise unchanged and all DAI configurations (single DAI, multiple DAIs, multiple pipelines, etc) should be handled, all transition are handled as well.

CopilotAI 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 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +438 to +446
/*
* For aggregated DAIs (num_cpus > 1), defer pipeline RUNNING
* IPC until all CPU DAIs sharing this pipeline have started
* their link DMAs via hda_trigger(). The running state of each
* DAI's HDA stream naturally tracks completion.
*/
if (num_cpus > 1 &&
!hda_ipc4_all_spipe_dmas_running(substream, swidget->spipe))
break;

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

the PR description has been updated...

Comment on lines 479 to 483
/*
* STOP/SUSPEND trigger is invoked only once when all users of this pipeline have
* been stopped. So, clear the started_count so that the pipeline can be reset
* been stopped. So, clear the started_count so that the pipeline can be reset.
*/
swidget->spipe->started_count = 0;

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

this change should be removed, it is not related to topic.

lgirdwood
lgirdwood previously approved these changes May 14, 2026
@ujfalusi
ujfalusiforce-pushed the peter/sof/pr/aggregated-sdw-trigger branch from 763f980 to 1dc00a6CompareAugust 7, 2026 05:55
CopilotAI review requested due to automatic review settings August 7, 2026 05:55
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.
Fix this by checking the HDA stream running state in post_trigger:
- START/PAUSE_RELEASE: defer RUNNING IPC until all DAIs sharing the
same pipeline have their link DMA streams running
- STOP/SUSPEND/PAUSE_PUSH: use pipeline state dedup so the PAUSED IPC
is sent once regardless of how many DAIs share the pipeline
The running-state check naturally handles all aggregate topologies:
shared pipelines, independent pipelines, and mixed cases without
requiring per-pipeline counters.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi

Copy link
Copy Markdown
CollaboratorAuthor

Changes since v3:

  • restructure the code in hda_ipc4_all_spipe_dmas_running() to cover NULL pointer issues
  • rebased

CopilotAI 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 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +384 to +386
hext_stream = snd_soc_dai_get_dma_data(dai, substream);
if (!hext_stream || !hext_stream->hstream.running)
return false;
Sign up for freeto 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.

4 participants

@ujfalusi@lgirdwood@kv2019i