Skip to content

[SDW] cannot restart playback after suspend while in pause #1328

Closed

Description

@plbossart

Using the -i flag to play with the PUSH_PAUSE/PUSH_RELEASE trigger works fine with SoundWire with the latest PRs

If we use rtcwake to force a system suspend while in pause, then we have errors on restart

root@jf-icl-rvp-hda-8:~# aplay -Dhw:0,0 chirp_5s.wav -i
Playing WAVE 'chirp_5s.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
=== PAUSE ===                                                             Suspended. Trying resume. Failed. Restarting stream. Done.
aplay: do_pause:1508: pause release error: File descriptor in bad state

This is reproducible 100% of the time, so likely a bad state machine transition.

Activity

  1. added
    bugSomething isn't working
    ICLApplies to Icelake platform
    CMLApplies to Comet Lake platform
    TGLApplies to Tiger Lake platform
    SDW_DEVSDW bug reproduced by developers, fix WIP
    SDWApplies to SoundWire bus for codec connection
    on Oct 16, 2019
  2. ranj063 commented on Oct 16, 2019

    @ranj063
    Collaborator

    @plbossart we fixed the same issue with HDA with this commit bf705ea

    The fix for SDW might be similar.

  3. plbossart commented on Oct 16, 2019

    @plbossart
    MemberAuthor

    Thanks @ranj063 I knew this issue sounded familiar.
    I don't fully get the statement "paused streams do not get suspended", does this mean the TRIGGER_SUSPEND is not sent if a TRIGGER_PUSH_PAUSE was already sent? is this a feature from the framework or a bug on the SOF side?

    Also I am not sure what the moral equivalent this HDaudio fix would be for SoundWire. And actually we do use the same GDMA as for SSP, so not sure if we need to do anything? Odd.

  4. ranj063 commented on Oct 16, 2019

    @ranj063
    Collaborator

    I don't fully get the statement "paused streams do not get suspended", does this mean the TRIGGER_SUSPEND is not sent if a TRIGGER_PUSH_PAUSE was already sent? is this a feature from the framework or a bug on the SOF side?

    Yes, this is from the framework. If the stream is not running, it isnt suspended and so no TRIGGER_SUSPEND is sent.

  5. ranj063 commented on Oct 16, 2019

    @ranj063
    Collaborator

    Also I am not sure what the moral equivalent this HDaudio fix would be for SoundWire. And actually we do use the same GDMA as for SSP, so not sure if we need to do anything? Odd.

    The action we take to fix is in the BE. The problem with HDAudio was that the stream tag is retained for paused streams coming back from suspend when in fact it should be a new stream tag. So the fix basically suggests to clear the stream tag for all streams before suspending.

    My wild guess knowing not much about SDW state machine is that the moral equivalent of this would be deprepare all stream before suspending

  6. plbossart commented on Oct 16, 2019

    @plbossart
    MemberAuthor

    I don't fully get the statement "paused streams do not get suspended", does this mean the TRIGGER_SUSPEND is not sent if a TRIGGER_PUSH_PAUSE was already sent? is this a feature from the framework or a bug on the SOF side?

    Yes, this is from the framework. If the stream is not running, it isnt suspended and so no TRIGGER_SUSPEND is sent.

    so what is the DSP state for this PCM device at this point?
    On a resume, we re-prepare and reinitialize everything, but I guess we don't put the PCM device is the same state as it was before suspend.

  7. ranj063 commented on Oct 16, 2019

    @ranj063
    Collaborator

    so what is the DSP state for this PCM device at this point?
    On a resume, we re-prepare and reinitialize everything, but I guess we don't put the PCM device is the same state as it was before suspend.

    Im not sure of the state names for PCM devices, but as far as the DSP is concerned the PCM is not even started because it has just woken up from D3.

  8. plbossart commented on Oct 17, 2019

    @plbossart
    MemberAuthor

    Additional traces show we are getting a TRIGGER_START on resume, even though the stream was paused, and we are not getting a TRIGGER_PAUSE_RELEASE.

    Something's broken here. not sure why we get the start, or should we interpret the TRIGGER_START as just a means to restore the state in PAUSE?

    dmesg_pause.log

  9. plbossart commented on Oct 17, 2019

    @plbossart
    MemberAuthor

    After an afternoon of debug, I am nearly convinced there is no bug, and the nasty messages on the console are a feature - not an SOF bug. When using a long file, the playback does not exit as I suspected but does go on after the PAUSE_RELEASE - it was a coincidence due to the short files I was using.

    With the traces added to https://github.com/plbossart/sound/tree/fix/pause-suspend, I was able to show that the BADFD messages are due to the ALSA core, not something that the SOF driver did.

    When INFO_RESUME is not supported, ALSA will send a PREPARE ioctl so the PCM state will become PREPARED, which is not the expected state for the PAUSE_RELEASE. However we still get a TRIGGER_START and playback continues.

    We should double-check that the playback is actually audible after the PAUSE_RELEASE (I only did those tests over SSH).

    Traces attached with a "<<<" marker for relevant changes.
    dmesg_pause5.log

    @bardliao @ranj063 @RanderWang can you take a look and confirm my analysis, my brain is officially fried for the day.

  10. bardliao commented on Oct 18, 2019

    @bardliao
    Collaborator

    @plbossart I checked it with legacy HDA driver and it has the same behavior. So it is not an SOF bug.

  11. plbossart commented on Oct 18, 2019

    @plbossart
    MemberAuthor

    thanks @bardliao let's close then

  12. added
    won't fixThis will not be worked on atm (e.g. a bug closed for lack of user request, hardware etc)
    and removed
    bugSomething isn't working
    on Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CMLApplies to Comet Lake platformICLApplies to Icelake platformSDWApplies to SoundWire bus for codec connectionSDW_DEVSDW bug reproduced by developers, fix WIPTGLApplies to Tiger Lake platformsuspend resumeIssues related to suspend resume (e.g. rtcwake)won't fixThis will not be worked on atm (e.g. a bug closed for lack of user request, hardware etc)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions