-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: Intel: sort pipeline based on priority #4593
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
ASoC: SOF: Intel: sort pipeline based on priority #4593
Conversation
4268980 to
2ce530d
Compare
|
@ujfalusi update it , thanks! |
|
@RanderWang could you please make sure this PR works as expected with the aec pipeline? untested PRs are not ready for review |
yes, I tested with cavs-rt5682.tplg with nocodec dai and it passed all CI test |
|
@RDharageswari can you help to validate it with Ranjani's topology PR thesofproject/sof#8101 and thesofproject/sof#8204 |
c473966 to
6bc6b06
Compare
|
@plbossart @ujfalusi @ranj063 the tplg is thesofproject/sof#8204. Based on @ranj063 's advice, The following log is for AEC test on MTL, please check the payload for pipeline id. (the first 00000004 indicates 4 pipelines) |
plbossart
left a comment
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.
too many questions, this needs a lot more work @RanderWang
6bc6b06 to
9d28d15
Compare
plbossart
left a comment
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.
Sorry, not getting the picture @RanderWang
You have a very detailed understanding of IPC4, I don't, and I just can't figure out what this PR brings and when the order needs to be low->high or high->low.
sound/soc/sof/ipc4-pcm.c
Outdated
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.
can you clarify why the order needs to be different between PAUSED and RESET?
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.
I also spent time to check it. For REF FW, it doesn't care about the order for PAUSED or RESET and only care about START since START can result to XRUN. Although REF FW doesn't care about PAUSED or RESET, it still use the reverse order compared to START. This behavior is commented in REF driver.
For SOF, we always pause pipeline first then reset. After all the pipeline are paused or are just ready, the order of RESET is unimportant. I follow the current logic. @ranj063 can give more idea.
/*
* IPC4 requires pipelines to be triggered in order starting at the sink and
* walking all the way to the source. So traverse the pipeline_list in the order
* sink->source when starting PCM's and in the reverse order to pause/stop PCM's.
* Skip the pipelines that have their skip_during_fe_trigger flag set. If there is a fork
* in the pipeline, the order of triggering between the left/right paths will be
* indeterministic. But the sink->source trigger order sink->source would still be
* guaranteed for each fork independently.
*/
if (state == SOF_IPC4_PIPE_RUNNING || state == SOF_IPC4_PIPE_RESET)
for (i = pipeline_list->count - 1; i >= 0; i--) {
spipe = pipeline_list->pipelines[i];
sof_ipc4_add_pipeline_to_trigger_list(sdev, state, spipe, trigger_list,
pipe_priority);
}
else
for (i = 0; i < pipeline_list->count; i++) {
spipe = pipeline_list->pipelines[i];
sof_ipc4_add_pipeline_to_trigger_list(sdev, state, spipe, trigger_list,
pipe_priority);
}
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.
i am completely lost. The answer contains two conflicting explanations
A) the reference IPC4 implementation uses the same order for pause and reset
B) the suggested code uses a different order for pause and reset - even though the order for reset does not matter.
if the intent was to follow the reference to the letter, then obviously something went sideways.
I give up at this point, someone else needs to review.
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.
@plbossart let's fully follow the reference. Adopt the same order for pause & resume case.
9d28d15 to
172c97e
Compare
Driver set pipeline priority according to priority setting in topology. Signed-off-by: Rander Wang <rander.wang@intel.com>
172c97e to
e4fe334
Compare
|
let's fully follow the reference. Adopt the same order for pause & resume case: set pipeline from low priority to high. Start trigger uses order from high to low |
|
states update: |
|
@ranj063 @RDharageswari have you reviewed and possibly tested this suggested change? |
@plbossart this is still under testing. Please give us one more day to confirm |
sound/soc/sof/ipc4-pcm.c
Outdated
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.
@RanderWang I had a though about this second patch. Instead of sorting the pipelines based on priority in the kernel while ending the IPC, can we handle this in the FW? When the pipeline is set up, the FW is already aware of the priority. We can use that information in the firmware to trigger in decreasing order of priorities, right?
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.
(1) We can do it in FW, but we need some search operation to find the priority in FW. As you know, host X86 is much faster than dsp core. (5GHZ vs 400MHZ , DDR4800 vs DDR400).
(2) According to above discussing, we should fully align with REF implementation which does it in driver and it should be good for REF FW also.
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.
Verified working fine with randomly start/stop spk playback and DMIC0 RTC AEC.
ranj063
left a comment
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.
just one comment @RanderWang to fix an error path. Otherwise looks good to go.
The pipeline priority is set in topology and driver should sort pipeline based on priority for trigger order. Signed-off-by: Rander Wang <rander.wang@intel.com>
e4fe334 to
b7d0610
Compare
|
updated memory free. Thanks! |
|
|
||
| for (j = trigger_list->count - 1; j >= i; j--) { | ||
| trigger_list->pipeline_instance_ids[j + 1] = trigger_list->pipeline_instance_ids[j]; | ||
| pipe_priority[j + 1] = pipe_priority[j]; |
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.
trigger_list->count - 1 + 1 == trigger_list->count
trigger_list->pipeline_instance_ids[trigger_list->count] and pipe_priority[trigger_list->count] is out of bounds access?
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.
i had the same suspicion when I looked at the code. But the array size is pipeline_list->count not trigger_list->count. So I think it is safe here
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.
At the end we are not going to put all pipelines in the trigger list? Right, when we add the last pipeline the trigger_list->count is pipeline_list->count, I guess it is OK, but super confusing.
|
|
||
| for (j = trigger_list->count - 1; j >= i; j--) { | ||
| trigger_list->pipeline_instance_ids[j + 1] = trigger_list->pipeline_instance_ids[j]; | ||
| pipe_priority[j + 1] = pipe_priority[j]; |
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.
At the end we are not going to put all pipelines in the trigger list? Right, when we add the last pipeline the trigger_list->count is pipeline_list->count, I guess it is OK, but super confusing.
|
usual timeouts in suspend/resume tests. merging |
The pipeline priority is set in topology and driver should sort pipeline based on priority for trigger order.
Topology PR: thesofproject/sof#8204