forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 144
ASoC: SOF: Intel: Fix pipeline state transitions for aggregate DAIs #5765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ujfalusi
wants to merge
1
commit into
thesofproject:topic/sof-dev
Choose a base branch
from
ujfalusi:peter/sof/pr/aggregated-sdw-trigger
base: topic/sof-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -292,6 +292,39 @@ static struct hdac_ext_link *sdw_get_hlink(struct snd_sof_dev *sdev, | |
| return hdac_bus_eml_sdw_get_hlink(bus); | ||
| } | ||
|
|
||
| /* | ||
| * Check if all CPU DAIs sharing the same pipeline (spipe) have their link | ||
| * DMA streams running. Used to gate pipeline state transitions for aggregate | ||
| * DAIs: the RUNNING IPC is deferred until the last DAI's link DMA has started. | ||
| */ | ||
| static bool hda_ipc4_all_spipe_dmas_running(struct snd_pcm_substream *substream, | ||
| struct snd_sof_pipeline *target_spipe) | ||
| { | ||
| struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); | ||
| struct snd_soc_dai *dai; | ||
| int i; | ||
|
|
||
| for_each_rtd_cpu_dais(rtd, i, dai) { | ||
| struct snd_soc_dapm_widget *w; | ||
| struct snd_sof_widget *sw; | ||
| struct hdac_ext_stream *hext_stream; | ||
|
|
||
| w = snd_soc_dai_get_widget(dai, substream->stream); | ||
| if (!w) | ||
| continue; | ||
|
|
||
| sw = w->dobj.private; | ||
| if (!sw || sw->spipe != target_spipe) | ||
| continue; | ||
|
|
||
| hext_stream = snd_soc_dai_get_dma_data(dai, substream); | ||
| if (!hext_stream || !hext_stream->hstream.running) | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, | ||
| struct snd_pcm_substream *substream, int cmd) | ||
| { | ||
|
|
@@ -319,13 +352,22 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp | |
| case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
| case SNDRV_PCM_TRIGGER_SUSPEND: | ||
| case SNDRV_PCM_TRIGGER_STOP: | ||
| /* | ||
| * For aggregate DAIs with shared pipelines, the state check | ||
| * deduplicates: the first DAI sends the IPC, subsequent DAIs | ||
| * sharing the same pipeline see it already paused and skip. | ||
| * For aggregate DAIs with different pipelines, each DAI pauses | ||
| * its own pipeline independently. | ||
| */ | ||
| if (pipeline->state == SOF_IPC4_PIPE_PAUSED) | ||
| break; | ||
|
|
||
| ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, | ||
| SOF_IPC4_PIPE_PAUSED); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| pipeline->state = SOF_IPC4_PIPE_PAUSED; | ||
|
|
||
| break; | ||
| default: | ||
| dev_err(sdev->dev, "unknown trigger command %d\n", cmd); | ||
|
|
@@ -372,11 +414,13 @@ static int hda_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, | |
| static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, | ||
| struct snd_pcm_substream *substream, int cmd) | ||
| { | ||
| struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); | ||
| struct sof_ipc4_fw_data *ipc4_data = sdev->private; | ||
| struct snd_sof_widget *pipe_widget; | ||
| struct sof_ipc4_pipeline *pipeline; | ||
| struct snd_sof_widget *swidget; | ||
| struct snd_soc_dapm_widget *w; | ||
| int num_cpus = rtd->dai_link->num_cpus; | ||
| int ret = 0; | ||
|
|
||
| w = snd_soc_dai_get_widget(cpu_dai, substream->stream); | ||
|
|
@@ -391,6 +435,16 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c | |
|
|
||
| switch (cmd) { | ||
| case SNDRV_PCM_TRIGGER_START: | ||
| /* | ||
| * 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; | ||
|
Comment on lines
+438
to
+446
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the PR description has been updated... |
||
|
|
||
| if (pipeline->state != SOF_IPC4_PIPE_PAUSED) { | ||
| ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, | ||
| SOF_IPC4_PIPE_PAUSED); | ||
|
|
@@ -409,6 +463,10 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c | |
| swidget->spipe->started_count++; | ||
| break; | ||
| case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
| if (num_cpus > 1 && | ||
| !hda_ipc4_all_spipe_dmas_running(substream, swidget->spipe)) | ||
| break; | ||
|
|
||
| ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id, | ||
| SOF_IPC4_PIPE_RUNNING); | ||
| if (ret < 0) | ||
|
|
@@ -420,7 +478,7 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c | |
| case SNDRV_PCM_TRIGGER_STOP: | ||
| /* | ||
| * 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; | ||
|
Comment on lines
479
to
483
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change should be removed, it is not related to topic. |
||
| break; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check