Skip to content
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

ipc4: Ensure pipeline component directions are synchronized #8969

Conversation

tmleman
Copy link
Contributor

@tmleman tmleman commented Mar 20, 2024

This patch addresses an issue where audio output could be silent due to the direction property of pipeline components not being set. The added code ensures that if the source component's direction is unset but the sink's direction is set, or vice versa, the direction is copied from the set component to the unset one.

This synchronization of the direction property guarantees that the pipeline's data flow is correctly established, allowing the pipeline_for_each_comp function to traverse and process all components as intended, thus resolving the silent audio output problem.

Copy link
Collaborator

@softwarecki softwarecki left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
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.

Some questions inline, please check

src/ipc/ipc4/handler.c Outdated Show resolved Hide resolved
* mark the source's direction as set. This ensures that the pipeline's flow
* direction is consistent and correctly configured for the traversal process.
*/
if (!ppl_icd->pipeline->source_comp->direction_set &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Identical code and logic is already done in ipc_comp_connect(). It would be interesting to understand better why this can happen in some case. If this cannot be avoided, can we have a shared helped used by both this function and ipc_comp_connect() ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

the choice of a function to place this code into isn't very obvious. Is this function called for each new pipeline before it's activated? Maybe some more obvious place like when a streaming attempt is made would be clearer?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lyakh I had the same concern, but looks like it's not so easy to pick another spot. This is called from multiple places, from the state machine implementing pipeline state changes. I'm happy with the extended git commit message to explain the change.

@tmleman tmleman force-pushed the topic/upstream/pr/ipc4/ppl_prepare/comp_prepare/direction_set branch 2 times, most recently from b4cb1eb to 4db629f Compare March 28, 2024 14:20
@tmleman
Copy link
Contributor Author

tmleman commented Mar 28, 2024

@kv2019i please take another look.

@tmleman tmleman requested a review from kv2019i March 28, 2024 14:23
Copy link
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.

Thanks, excellent commit message!

@kv2019i
Copy link
Collaborator

kv2019i commented Mar 28, 2024

Ready to go once mandatory CI checks are green.

This patch addresses an issue where audio output could be silent due to
the direction property of pipeline components not being set. The problem
manifests when the pipeline is initialized in the sequence:

Init -> Reset -> Pause -> Ready

In this scenario, the direction property may remain unset, leading to
incorrect pipeline behavior.

In flow of transitions: Init -> Pause -> Ready, this issue does not occur
because the firmware attempts to set the directions in pipe components
during the transition from Init to Pause. This step is skipped if Pause
is done after Reset, which is the scenario that this patch addresses.

The added code ensures that if the source component's direction is unset
but the sink's direction is set, or vice versa, the direction is copied
from the set component to the unset one. This synchronization of the
direction property guarantees that the pipeline's data flow is correctly
established.

This synchronization of the direction property guarantees that the
pipeline's data flow is correctly established, allowing the
`pipeline_for_each_comp` function to traverse and process all components
as intended, thus resolving the silent audio output problem.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
@@ -251,6 +251,28 @@ static struct ipc_comp_dev *pipeline_get_host_dev(struct ipc_comp_dev *ppl_icd)
struct ipc *ipc = ipc_get();
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: in commit message

This synchronization of the
direction property guarantees that the pipeline's data flow is correctly
established.

This synchronization of the direction property guarantees that the
pipeline's data flow is correctly established

looks like a duplication

* mark the source's direction as set. This ensures that the pipeline's flow
* direction is consistent and correctly configured for the traversal process.
*/
if (!ppl_icd->pipeline->source_comp->direction_set &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

the choice of a function to place this code into isn't very obvious. Is this function called for each new pipeline before it's activated? Maybe some more obvious place like when a streaming attempt is made would be clearer?

@kv2019i
Copy link
Collaborator

kv2019i commented Apr 4, 2024

No further comments, so proceeding with merge.

@kv2019i kv2019i merged commit 732f07c into thesofproject:main Apr 4, 2024
43 of 45 checks passed
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.

5 participants