Skip to content

[BUG][S3] pulseaudio playback fails after S3 suspend/resume #1000

Closed

Description

@kv2019i

PCM playback to fails to recover after suspend/resume on WHL board.

Commands (with pulseaudio install as default server)
sh2> aplay -Dpulse test.wav
sh3> sudo rtcwake -m mem -s 2

Commands (without pulseaudio as default)
sh1> /usr/bin/pulseaudio -vv
sh2> aplay -Dpulse test.wav
sh3> sudo rtcwake -m mem -s 2

Expected outcome:

  • no error in dmesg+soflogger and audio is good after resume

Actual outcome:

  • audio is not good after resume, errors in FW log

SW&FW versions:

  • sof-dev (0a747dc) + (98972d6) to disable MSI mode
  • FW (47dc14d7) lyakh/ipc-timeout
  • tested with following PA version
    - PA 11 used in Ubuntu 18.04 -> occurs
    - PA 12.2 used in Ubuntu 19.04 -> occurs
    - PA master -> does not occur
    -> PA call sequences look valid in all versions

Notes:

Log excerpt for SW:

(  30.113|   0.000) D: [alsa-sink-HDA Analog (*)] sink-input.c: Have to rewind 23552 bytes on render memblockq.
(  30.113|   0.000) D: [alsa-sink-HDA Analog (*)] source.c: Processing rewind...
(  30.117|   0.004) D: [alsa-sink-HDA Analog (*)] sink.c: Volume change to 31008 at 178811557 was written 72 usec late
(  35.708|   5.590) I: [alsa-sink-HDA Analog (*)] alsa-sink.c: Scheduling delay of 1751,24 ms > 18,38 ms, you might want to investigate this to improve latency...
(  35.708|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-util.c: Got POLLERR from ALSA
(  35.708|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-util.c: Got POLLOUT from ALSA
(  35.708|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-util.c: PCM state is SUSPENDED
(  35.708|   0.000) I: [alsa-sink-HDA Analog (*)] (alsa-lib)pcm_hw.c: SNDRV_PCM_IOCTL_RESUME failed (-38)
(  35.722|   0.014) I: [alsa-sink-HDA Analog (*)] alsa-sink.c: Starting playback.
(  35.723|   0.000) D: [alsa-sink-HDA Analog (*)] ratelimit.c: 40 events suppressed
(  35.723|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-sink.c: Cutting sleep time for the initial iterations by half.
(  35.723|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-util.c: Got POLLERR from ALSA
(  35.723|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-util.c: Got POLLOUT from ALSA
(  35.723|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-util.c: PCM state is RUNNING
(  35.724|   0.000) I: [alsa-sink-HDA Analog (*)] alsa-sink.c: Starting playback.
(  35.725|   0.000) D: [alsa-sink-HDA Analog (*)] alsa-sink.c: Cutting sleep time for the initial iterations by half.

Log excerpt for FW:

   0      2          DMA         170417391868.489594         3.177083 intel/cavs/hda-dma.c:650         hda-dmac: 7 channel 0 -> stop
    0      2          IPC         170417393269.218750      1400.729126    src/ipc/handler.c:479         ipc: comp 1 -> trigger cmd 0x40000
    0      2         PIPE 1.6     170417393273.229187         4.010417 src/audio/pipeline.c:579         pipeline_trigger()
    0      2         HOST         170417393276.822937         3.593750     src/audio/host.c:286         host_trigger()
    0      2          DMA         170417393280.729187         3.906250 intel/cavs/hda-dma.c:555         hda-dmac: 5 channel 0 -> start
    0      2          DMA         170417393284.010437         3.281250 intel/cavs/hda-dma.c:391         hda-dmac: 5 channel 0 -> enable
    0      2       VOLUME         170417393341.822937        57.812500 udio/volume/volume.c:488         volume_trigger()
    0      2          DAI 1.5     170417393345.520844         3.697917      src/audio/dai.c:510         dai_comp_trigger(), command = 1
    0      2          DAI 1.5     170417393348.854187         3.333333      src/audio/dai.c:521         dai_comp_trigger(), START
    0      2          DMA         170417393352.187500         3.333333 intel/cavs/hda-dma.c:555         hda-dmac: 7 channel 0 -> start
    0      2          DMA         170417393355.677094         3.489583 intel/cavs/hda-dma.c:391         hda-dmac: 7 channel 0 -> enable
    0      2          IPC         170417394637.187500      1281.510376    src/ipc/handler.c:479         ipc: comp 1 -> trigger cmd 0x50000
    0      2         PIPE 1.6     170417394640.989594         3.802083 src/audio/pipeline.c:579         pipeline_trigger()
    0      2         HOST         170417394644.739594         3.750000     src/audio/host.c:286         host_trigger()
    0      2          DMA         170417394648.645844         3.906250 intel/cavs/hda-dma.c:650         hda-dmac: 5 channel 0 -> stop
    0      2       VOLUME         170417394652.552094         3.906250 udio/volume/volume.c:488         volume_trigger()
    0      2          DAI 1.5     170417394656.250000         3.697917      src/audio/dai.c:510         dai_comp_trigger(), command = 0
    0      2          DAI 1.5     170417394659.635437         3.385417      src/audio/dai.c:574         dai_comp_trigger(), PAUSE/STOP
    0      2          DMA         170417394662.864594         3.229167 intel/cavs/hda-dma.c:650         hda-dmac: 7 channel 0 -> stop
    0      2          IPC         170417395920.468750      1257.604126    src/ipc/handler.c:479         ipc: comp 1 -> trigger cmd 0x40000
    0      2         PIPE 1.6     170417395924.479187         4.010417 src/audio/pipeline.c:579         pipeline_trigger()
    0      2         HOST         170417395928.072937         3.593750     src/audio/host.c:286         host_trigger()
    0      2          DMA         170417395931.822937         3.750000 intel/cavs/hda-dma.c:555         hda-dmac: 5 channel 0 -> start
    0      2          DMA         170417395935.260437         3.437500 intel/cavs/hda-dma.c:391         hda-dmac: 5 channel 0 -> enable
    0      2       VOLUME         170417395992.760437        57.500000 udio/volume/volume.c:488         volume_trigger()
    0      2          DAI 1.5     170417395996.406250         3.645833      src/audio/dai.c:510         dai_comp_trigger(), command = 1
    0      2          DAI 1.5     170417395999.947937         3.541667      src/audio/dai.c:521         dai_comp_trigger(), START
    0      2          DMA         170417396003.281250         3.333333 intel/cavs/hda-dma.c:555         hda-dmac: 7 channel 0 -> start
    0      2          DMA         170417396006.614594         3.333333 intel/cavs/hda-dma.c:391         hda-dmac: 7 channel 0 -> enable
    0      2       BUFFER         170417396879.375000       872.760437   src/audio/buffer.c:192         comp_update_buffer_consume(), no bytes to consume
    0      1         COMP         170417396884.531250         5.156250 rc/audio/component.c:261         comp_get_copy_limits() error: sink component buffer has not enough free bytes for copy
    0      2         COMP         170417396889.583344         5.052083 of/audio/component.h:729         comp_overrun(), ((dev->comp.id << 16) | sink->free) = 131072, ((min_bytes << 16) | copy_bytes
) = 0
    0      2         PIPE 1.6     170417396892.656250         3.072917 src/audio/pipeline.c:579         pipeline_trigger()
    0      2         HOST         170417396896.197937         3.541667     src/audio/host.c:286         host_trigger()
    0      2          DMA         170417396900.000000         3.802083 intel/cavs/hda-dma.c:650         hda-dmac: 5 channel 0 -> stop
    0      2       VOLUME         170417396903.750000         3.750000 udio/volume/volume.c:488         volume_trigger()
    0      2          DAI 1.5     170417396907.447937         3.697917      src/audio/dai.c:510         dai_comp_trigger(), command = 8
    0      2          DAI 1.5     170417396910.729187         3.281250      src/audio/dai.c:568         dai_comp_trigger(), XRUN
    0      2          DAI 1.5     170417396913.645844         2.916667      src/audio/dai.c:574         dai_comp_trigger(), PAUSE/STOP
    0      2          DMA         170417396916.875000         3.229167 intel/cavs/hda-dma.c:650         hda-dmac: 7 channel 0 -> stop
    0      1       VOLUME         170417396925.156250         8.281250 udio/volume/volume.c:510         volume_copy(): Failed comp_get_copy_limits()
    0      1         PIPE         170417396930.312500         5.156250 src/audio/pipeline.c:732         pipeline_copy() error: ret = -5, start->comp.id = 2, dir = 1
    0      1         PIPE 1.6     170417396936.718750         6.406250 src/audio/pipeline.c:844         pipeline_xrun_recover()
    0      2         PIPE 1.6     170417396941.614594         4.895833 src/audio/pipeline.c:352         pipeline_prepare()

Activity

  1. added
    bugSomething isn't working
    P2Critical bugs or normal features
    WHLApplies to WhiskeyLake platform
    on May 31, 2019
  2. self-assigned this
    on Jun 13, 2019
  3. kv2019i commented on Jun 13, 2019

    @kv2019i
    CollaboratorAuthor

    @mengdonglin @wenqingfu I can start looking at this.

  4. lyakh commented on Jun 17, 2019

    @lyakh
    Collaborator

    @kv2019i hasn't it been decided that this is PA's problem and that their commit, that's present in their master branch should be advanced to a new release and to distributions?

  5. kv2019i commented on Jun 17, 2019

    @kv2019i
    CollaboratorAuthor

    @kv2019i hasn't it been decided that this is PA's problem and that their commit, that's present in their master branch should be advanced to a new release and to distributions?

    @lyakh No. While update to newer pulseaudio can help, to me SOF behaviour is not solid here. I've been debugging this since Friday and target to have more information end of today. UPDATE: rootcause still unknown, but I found at least one behaviour in FW that may explain this -> thesofproject/sof#1572

  6. kv2019i commented on Jun 19, 2019

    @kv2019i
    CollaboratorAuthor

    Issue tracked to problems in how we we handle ALSA prepare(). See logs and explanation in:
    thesofproject/sof#1572 (comment)

    .. this now looks the same problem, but not sure whether to fix on driver or FW side. We are not following ALSA semantics here.

  7. kv2019i commented on Jun 19, 2019

    @kv2019i
    CollaboratorAuthor

    An RFC patch is available at:
    #1049

    ... this fixes sequences with aplay, but does not however fix the Pulseuadio (v11.1) S3 case. I can see from logs that PA is now able to to run a bit longer after each PCM_START attempt, but after a flurry of rewinds, it still ends up to XRUNs and never recovers.

  8. kv2019i commented on Jun 19, 2019

    @kv2019i
    CollaboratorAuthor

    @kv2019i wrote:

    ... this fixes sequences with aplay, but does not however fix the Pulseuadio (v11.1) S3 case. I can see

    Tested with PulseAudio 12.0-293-g03bef (git build) and tests passes without any XRUNs. It seems the main problem with v11.1 is that PA doesn't remember the buffering delay, but tries to find a new optimal value after each XRUN. In 12.0 and newer, PA remembers the old value and PCM resumes without the many rewinds.

  9. ranj063 commented on Jun 19, 2019

    @ranj063
    Collaborator

    @kv2019i so do we still need to fix v11.1?

  10. kv2019i commented on Jun 19, 2019

    @kv2019i
    CollaboratorAuthor

    @kv2019i so do we still need to fix v11.1?

    Yes, I believe so -- what PA does is not against the ALSA PCM interface, so it should work (plus 11.1 is quite widely used, so people will hit this even if new PA is released). We need to still figure out why PR1049 doesn't help with 11.1...

  11. lyakh commented on Jun 26, 2019

    @lyakh
    Collaborator

    #1058 can be used for runtime disabling of MSI

  12. kv2019i commented on Jul 2, 2019

    @kv2019i
    CollaboratorAuthor

    PR1049 fixes multiple issues related to XRUN and restart flows, but even with latest patch, this bug still occurs with PA-11 and PA12.2. OTOH, PA master is now frozen for 13.0 release (bug fixes still allowed).

    I will continue to analyze this bug still to understand whether SOF is following ALSA semantics here and will update the bug accordingly. If behaviour is correct, then I'll close and we recommend people to upgrade to PA13.0 if they hit this bug. But if not, we still need a fix as other application may hit the same problem.

  13. kv2019i commented on Jul 3, 2019

    @kv2019i
    CollaboratorAuthor

    Completed rootcausing of this problem and this turned out to be a clear bug in Pulseaudio 12.2 and older. In the first PA thread iteration after S3 resume, PA alsa-sink does not properly clean up "revents" field of the polldfd, causing ALSA snd_pcm_poll_descriptors_revents() to return POLLERR while in practise the stream is in RUNNING state with no errors. Due to this bad info in revents, PA goes on to call snd_pcm_drop() (from pa_alsa_recover_from_poll()) and try to restart the stream, and this never succeeds.

    Patch to fix this in PA 12.2 (and applies to older releases is at):
    kv2019i/pulseaudio@0b3c523

    The problem has been already fixed in PA master and will be in the soon-to-be-released PA13 release. In PA13, the PCM will be reopened and the rtpoll object will be rebuild, so the bug problem is not hit (and solution is different than the above patch).

    Closing the bug as this is not a SOF bug.

  14. added
    PulseAudioPulseAudio restriction
    won't fixThis will not be worked on atm (e.g. a bug closed for lack of user request, hardware etc)
    on Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Critical bugs or normal featuresPulseAudioPulseAudio restrictionWHLApplies to WhiskeyLake platformbugSomething isn't workingsuspend 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