Skip to content

Xrun recover fixes and refactoring -- for both with and without FW internal Xrun recovery. - #851

Merged
lgirdwood merged 3 commits into
thesofproject:masterfrom
keyonjie:xrun_recover_fix
Apr 24, 2019
Merged

lgirdwood merged 3 commits into
thesofproject:masterfrom
keyonjie:xrun_recover_fix

Conversation

@keyonjie

@keyonjie keyonjie commented Jan 16, 2019 •

Copy link
Copy Markdown
Contributor

This series will fix #902 (FW initiated Xrun recovery)

Currently neither FW internal nor external(ALSA triggered) Xrun recovery works for FW initiated Xrun(please use patch here to verify this issue: keyonjie@755ea15).

This series fix them(verified on UP^2), details please refer to commits.

dai: do re-config after prepare from xrun
pipeline: add pipeline_pre_trigger() for before pipeline real trigger
pipeline: stop pipeline at xrun if no internal xrun recovery

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs more detail in commit messages explaining what issue this fixes and how.

Comment thread src/audio/pipeline.c Resolved
Comment thread src/audio/pipeline.c Resolved
Comment thread src/audio/pipeline.c Resolved
Comment thread src/audio/pipeline.c Resolved
Comment thread src/audio/pipeline.c Resolved
@keyonjie

keyonjie commented Jan 16, 2019 •

Copy link
Copy Markdown
Contributor Author

Needs more detail in commit messages explaining what issue this fixes and how.

Something like this make sense?

Currently neither FW internal nor external(ALSA triggered) Xrun recovery works for FW initiated Xrun(please use patch here to verify this issue: keyonjie/sof@755ea15).

@lgirdwood

Copy link
Copy Markdown
Member

@keyonjie no, the detail should be added to each commit message of what and why each patch does alongside the issue it fixes.

@keyonjie

Copy link
Copy Markdown
Contributor Author

@lgirdwood updated, please help review.

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This adds a lot of complexity.
Ideally we need to ensure that the pipeline state is consistent before pipeline_trigger(START) is called. The XRUN handling code should restore the pipeline to be ready for trigger(START).

@keyonjie

Copy link
Copy Markdown
Contributor Author

This adds a lot of complexity.

@lgirdwood do you mean adding pipeline_pre_trigger() is too complex? even without doing prepare for trigger start?

Ideally we need to ensure that the pipeline state is consistent before pipeline_trigger(START) is called. The XRUN handling code should restore the pipeline to be ready for trigger(START).

@lgirdwood I got your point here, let me think if I can change to make it work like that.

@lgirdwood

Copy link
Copy Markdown
Member

@keyonjie lets look at this again after @tlauda pipeline changes are merged.

@keyonjie

Copy link
Copy Markdown
Contributor Author

@tlauda @lgirdwood rebase and update my PR, please help review.

@keyonjie
keyonjie requested a review from lgirdwood April 10, 2019 14:54
Comment thread src/audio/component.c Resolved
Comment thread src/audio/component.c Resolved
Comment thread src/audio/pipeline.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pipeline_prepare is called in pipeline_xrun_recover, so why do we need additional prepare here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The pipeline_xrun_recover() may be empty once NO_XRUN_RECOVERY is defined, that means there will be trigger stop and trigger start from host side(no prepare trigger). That's why we need this.

@tlauda tlauda Apr 11, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So it means that rather than empty pipeline_xrun_recover() should at least do prepare call, no matter if its disabled or not. And also you are just triggering prepare here instead of calling pipeline_prepare. Is this also intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So it means that rather than empty pipeline_xrun_recover() should at least do prepare call, no matter if its disabled or not. And also you are just triggering prepare here instead of calling

yes, that's another choice. I did it in my way as some driver might send prepare IPC in future before trigger start(ALSA do has that at this senario), but ours doesn't at the moment(we haven't added prepare IPC yet actually, you can see in ipc_stream_pcm_params() we only prepare at hw_params IPC at the moment), and this prepare is actually part of the recovery, so I want to add it here to increase the robustness of our FW(to handle with and without prepare IPC before trigger start for recovery).

pipeline_prepare. Is this also intentional?

it was not intentional here, let me change this.

Comment thread src/audio/pipeline.c Resolved
@keyonjie
keyonjie requested a review from tlauda April 11, 2019 10:06
@keyonjie

Copy link
Copy Markdown
Contributor Author

@tlauda updated.

@keyonjie
keyonjie requested a review from jajanusz as a code owner April 15, 2019 13:00
@keyonjie

keyonjie commented Apr 15, 2019 •

Copy link
Copy Markdown
Contributor Author

@jajanusz @tlauda @slawblauciak cmoka unit test fail issue fixed.

Comment thread src/audio/pipeline.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is all fine, except lets move this xrun handling to a different function i..e.

pipeline_handle_xrun_trigger()
{
    // return value indicates error, caller can continue or caller should return
}

pipeline_trigger()
{
    if (p->in_xrun) {
        ret = pipeline_handle_xrun_trigger();
        if (ret < 0)
            error;
        else if (ret > 0)
           return ret; // xrun handler handled this no further action needed.
      }
    .....
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lrgirdwo updated as you suggested.

@keyonjie
keyonjie requested a review from lgirdwood April 15, 2019 15:45
Comment thread src/audio/pipeline.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You always return 0.

Comment thread src/audio/pipeline.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Common condition for both cases, can be checked before switch.

Comment thread src/audio/pipeline.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Already checked inside the function

Comment thread src/audio/pipeline.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You always return 0.

ret = PPL_STATUS_PATH_STOP

Comment thread src/audio/pipeline.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be checked against status PPL_STATUS_PATH_STOP.

@dabekjakub dabekjakub added the P1 Blocker bugs or important features label Apr 18, 2019
@keyonjie

keyonjie commented Apr 19, 2019 •

Copy link
Copy Markdown
Contributor Author

@tlauda your comments addressed and PR updated.

@keyonjie
keyonjie requested a review from tlauda April 19, 2019 08:23
Comment thread src/audio/component.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@keyonjie does the state transition diagram need updated in the component header ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

correct, let me update it.

@keyonjie

Copy link
Copy Markdown
Contributor Author

@lgirdwood @tlauda updated.

When trigger xrun arrives, we will reset the component state to be
READY, which means prepare will needed before we can recover.

Update state machine diagram and cmoka unit test cases also.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
At xrun, we will try internal recovery(if we have), if recovering
fails(or no internal recovery existed), we need to stop the periodic
scheduling.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Once FW initiated xrun happens, the pipeline will be stopped(via
pipeline_xrun()) first internally, here add logic to ignore any extra
trigger_stop from host, and do prepare for xrun recovery before we
can really trigger it start.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
@lgirdwood
lgirdwood merged commit 395a34e into thesofproject:master Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 Blocker bugs or important features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't recover from FW initiated Xrun

4 participants