Skip to content

[SDW] playback is stopped after system suspend #1311

Closed

Description

@plbossart

When we do a system suspend, the playback does not restart on system resume. The dmesg log shows a trigger stop is sent immediately.

console log
root@jf-icl-rvp-hda-8:~# modprobe snd-sof-pci
root@jf-icl-rvp-hda-8:~# speaker-test -Dhw:0,0 -c2 -r48000

speaker-test 1.1.3

Playback device is hw:0,0
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 96 to 16368
Period size range from 48 to 4080
Using max buffer size 16368
Periods = 4
was set period_size = 3312
was set buffer_size = 16368
 0 - Front Left
 1 - Front Right
Time per period = 5.592228
 0 - Front Left
 1 - Front Right
Time per period = 5.934952
 0 - Front Left
 1 - Front Right
Write error: -86,Streams pipe error
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error

The expected behavior is that the playback restarts (possibly with an error message indicating an underflow)

Kernel: integration/soundwire-latest 19df577
Additional traces on top
pm-traces.diff.txt
firmware: master

dmesg log (only tracking after rtcwake -m freeze -s 3)
dmesg_aplay_suspend_stop_on_resume.log

Activity

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

    @ranj063
    Collaborator

    @plbossart it looks like the BE hw_params isnt getting called here.

    In the prepare() callback for the SDW BE ops, I think we should set the hw_params if it is resumed from suspend.

  3. plbossart commented on Oct 12, 2019

    @plbossart
    MemberAuthor

    @ranj063 yes. I suspect that the stream is still configured as 'PREPARED' so we don't do anything.

  4. ranj063 commented on Oct 12, 2019

    @ranj063
    Collaborator

    @ranj063 yes. I suspect that the stream is still configured as 'PREPARED' so we don't do anything.

    @plbossart in the HDA case, we call the hw_params() routine from our prepare() routine if the link is not prepared. The link is marked as not prepared in the stop/suspend triggers.

    I am wondering if we need to use a similar logic in the SDW BE dai ops ie have intel_prepare() called intel_hw_params() upon resuming from system suspend.

  5. plbossart commented on Oct 12, 2019

    @plbossart
    MemberAuthor

    It's definitively a problem with the .prepare callback.

    I added some traces on top of integration/soundwire-latest (https://github.com/plbossart/sound/tree/fix/soundwire-suspend-aplay-resume) and I can see the prepare returns as 'already configured'

    [   57.022310]  SDW0-speakers: ASoC: prepare FE SDW0-speakers
    [   57.022312]  SDW0-Playback: ASoC: prepare BE SDW0-Playback
    [   57.022317] intel-sdw sdw-master-0: intel_prepare: SDW0 Pin2: start
    [   57.022319] sdw_prepare_stream: SDW0 Pin2-Playback start
    [   57.022320] sdw_prepare_stream: SDW0 Pin2-Playback: already configured state 4
    [   57.022321] intel-sdw sdw-master-0: intel_prepare: SDW0 Pin2: done
    [   57.022342] sof-audio-pci 0000:00:1f.3: pcm: prepare stream 0 dir 0
    

    but later on we still do a trigger

       57.023266] sof-audio-pci 0000:00:1f.3: ipc tx succeeded: 0x60040000: GLB_STREAM_MSG: TRIG_START
    [   57.023268]  SDW0-Playback: ASoC: trigger BE SDW0-Playback cmd 1
    [   57.023270] intel-sdw sdw-master-0: intel_trigger: SDW0 Pin2: start
    [   57.023271] sdw_enable_stream: SDW0 Pin2-Playback: start
    [   57.024038] rt711 sdw:0:25d:711:0:1: [rt711_sdw_write] 00e0 <= 0003
    [   57.024118] rt711 sdw:0:25d:711:0:1: [rt711_sdw_write] 00f0 <= 0003
    [   57.024119] rt711 sdw:0:25d:711:0:1: rt711_clock_config complete, clk_freq=4800000
    [   57.024450] sdw_enable_stream: SDW0 Pin2-Playback: done
    [   57.024453] intel-sdw sdw-master-0: intel_trigger: SDW0 Pin2: done
    

    Full log here:
    dmesg_aplay_suspend_already_prepared.log

    It's very likely that since we don't reprogram the transport parameters, the enable does not do anything during the bank switch and there is no data transfer on the bus.

  6. plbossart commented on Oct 12, 2019

    @plbossart
    MemberAuthor

    Update: the issue is due to the stream management, the state machine is inconsistent.
    I fixed it in the updated branch: https://github.com/plbossart/sound/tree/fix/soundwire-suspend-aplay-resume

    As @ranj063 suggested it, the issue is that on system resume, we call the .prepare() callback, but it's in the .hw_params() that we notify firmware of the ALH stream ID. So when we do trigger, nothing will happen since the firmware was not re-configured.

    See trace in attached file (search for marker "<<" to follow the sequence)
    dmesg_aplay3.log

    @slawblauciak, couple of questions for you:
    a. shouldn't we return an error when we trigger and there is no ALH configuration that's passed to the firmware?
    b. is this ok if we pass the ALH configuration during the prepare step, which means that the firmware might receive the configuration multiple times, e.g. if an underrun happens?

    @bardliao @RanderWang please check how we can modify the intel_prepare() callback so as to pass the right information to firmware.

  7. dengyangchao commented on Oct 14, 2019

    @dengyangchao

    no matter s2idle or deep suspend mode will cause I/O error in below two scenarios, except HDMI/DP playback.
    scenario1: aplay 0,0/2/3 (or arecord ) --> pause --> s3/s2 --> wake up -->resume --> I/O error
    scenario2: aplay 0,0/2/3 (or arecord )-->s3/s2 -->wake up --> I/O error

    kernel: https://github.com/thesofproject/linux/tree/integration/soundwire-latest commit: 19df577
    sof: https://github.com/thesofproject/sof/commits/master commit: c7d0149
    platforms: cml rt700 rvp, icl 3-in-1 rvp.

    dmesg.log
    logger.log

  8. bardliao commented on Oct 14, 2019

    @bardliao
    Collaborator

    @plbossart Please check https://github.com/bardliao/linux/tree/fix/soundwire-suspend-aplay-resume.
    soundwire: intel: stream deprepare on TRIGGER_STOP/SUSPEND/PAUSE_PUSH will change stream status from DISABLED to DEPREPARED which will against the status check of sdw_enable_stream(). So I revert the commit and do deprepare in intel_prepare(). Also, I store hw_params and pdi information in sdw_intel {} so we can configure the stream after deprepare. I did some suspend/resume and pulse/release test and all of them works.

  9. plbossart commented on Oct 14, 2019

    @plbossart
    MemberAuthor

    @bardliao thanks for this suggestion.
    I don't have strong objections but we need to keep the state machine consistent. With the changes I did, I added this state check:

    @@ -1635,10 +1638,18 @@ int sdw_enable_stream(struct sdw_stream_runtime *stream)
     
     	sdw_acquire_bus_lock(stream);
     
    +	if ((stream->state != SDW_STREAM_PREPARED) &&
    +	    (stream->state != SDW_STREAM_DISABLED)) {
    +		pr_err("%s: %s: inconsistent state state %d\n", __func__, stream->name, stream->state);
    +		ret = -EINVAL;
    +		goto state_err;
    +	}
    +
     	ret = _sdw_enable_stream(stream);
     	if (ret < 0)
     		pr_err("Enable for stream:%s failed: %d\n", stream->name, ret);
     
    +state_err:
     	sdw_release_bus_lock(stream);

    With your patch, are we saying that on enable we have to be in PREPARED state, and the transition from DISABLED to ENABLED is not allowed?

    Or are we just saying that if prepare() is called while the state was DISABLED, we have to deprepare and prepare again for consistency?

  10. plbossart commented on Oct 14, 2019

    @plbossart
    MemberAuthor

    @bardliao also the issue with your solution is that it will not work when we transition to the multi-cpu dai solution. I think we need to have a flag that is explicitly set on trigger_suspend, and we test against that in the prepare, without using the stream state.

  11. bardliao commented on Oct 15, 2019

    @bardliao
    Collaborator

    With your patch, are we saying that on enable we have to be in PREPARED state, and the transition from DISABLED to ENABLED is not allowed?

    Or are we just saying that if prepare() is called while the state was DISABLED, we have to deprepare and prepare again for consistency?

    @plbossart I think the issue is that the stream status is actually not DISABLED (some configuration are lost) in system suspended (though the stream->status is DISABLED). So, in such case the transition from DISABLED to ENABLED doesn't work. However, in other cases the transition from DISABLED to ENABLED works fine.

  12. plbossart commented on Oct 15, 2019

    @plbossart
    MemberAuthor

    please retest with #1320

  13. YvonneYang2 commented on Oct 16, 2019

    @YvonneYang2

    Test it with #1320 on icl 3-in-1 rvp, system boot up with PA on, dmesg shows

    [    4.991196] sdw_deprepare_stream: SDW0 Pin2-Playback: inconsistent state state 2
    [    4.991197] sdw_deprepare_stream: SDW0 Pin2-Playback: done
    [    4.991198] intel-sdw sdw-master-0: sdw_deprepare_stream: failed -22
    [    4.991210]  SDW0-Playback: ASoC: close BE SDW0-Playback
    [    4.991211] intel-sdw sdw-master-0: intel_shutdown: SDW0 Pin2: start
    [    4.991212] intel-sdw sdw-master-0: intel_shutdown: SDW0 Pin2: done
    [    4.991225]  SDW0-speakers: ASoC: close FE SDW0-speakers
    

    log:
    boot_up_PAon_dmesg.log

    Aplay 0,0 (RT711)will fail and show the same dmesg logs as above. But aplay0,2/3 (RT1308) can work.
    Aplay0,2 --> pause --> s3 --> wake up --> resume --> fail console shows I/O error
    logs :
    pause_s3_resume_dmesg.log
    pause_s3_resume_logger.log

    Test it with #1320 + bardliao@d0247d3, system boot up with PA on or aplay 0,0 still has same dmesg logs as above.
    But no suspend/resume relevant issue occurred.

    Test it with https://github.com/bardliao/linux/tree/integration/soundwire-20191015 , Not occurred issues mentioned above, but all arecord volume always shows 0 with PA on.
    logs:
    arecord_volume0_dmesg.log
    arecord_volume0_logger.log

  14. plbossart commented on Oct 16, 2019

    @plbossart
    MemberAuthor

    Thanks @YvonneYang2

    The trace below essentially tells us we are trying to deprepare a PREPARED stream.

    [    4.991196] sdw_deprepare_stream: SDW0 Pin2-Playback: inconsistent state state 2
    

    That's not currently allowed by the state machine, but it should be as discussed with @bardliao. I guess this happens with PulseAudio trying to open the device and set the hw_params, then close the devices without ever triggering.

    I will fix this, this is a nice bug :-)

  15. ranj063 commented on Oct 16, 2019

    @ranj063
    Collaborator

    That's not currently allowed by the state machine, but it should be as discussed with @bardliao. I guess this happens with PulseAudio trying to open the device and set the hw_params, then close the devices without ever triggering.

    @plbossart pulse audio also tries to open and close device without setting the hw_params too.

  16. bardliao commented on Oct 18, 2019

    @bardliao
    Collaborator

    That's not currently allowed by the state machine, but it should be as discussed with @bardliao. I guess this happens with PulseAudio trying to open the device and set the hw_params, then close the devices without ever triggering.

    @plbossart pulse audio also tries to open and close device without setting the hw_params too.

    Yeah, so prepare <-> deprepare should be a valid transfer :)

  17. dengyangchao commented on Oct 18, 2019

    @dengyangchao

    issue still can reproduce on CML RVP with codec ALC700 in SDW mode
    reproduce rate from 100% to 40% (2/5)
    scenario: aplay 0,0(or arecord)-->s3/s2 -->wake up --> I/O error

    kernel: https://github.com/thesofproject/linux/tree/integration/soundwire-latest d88ee7d + PR1327
    sof: https://github.com/thesofproject/sof/commits/master 81cc31b

  18. plbossart commented on Oct 18, 2019

    @plbossart
    MemberAuthor

    can you please share logs @dengyangchao ? It's impossible to follow-up without dmesg traces...

  19. dengyangchao commented on Oct 18, 2019

    @dengyangchao

    run a stress test and reproduce it at 1/33

    Dmesg
    [  982.234581] atkbd serio0: Failed to enable keyboard on isa0060/serio0
    [  982.431284] sof-audio-pci 0000:00:1f.3: ipc rx: 0x90020000: GLB_TRACE_MSG
    [  982.431312] sof-audio-pci 0000:00:1f.3: ipc rx done: 0x90020000: GLB_TRACE_MSG
    [  982.931242] sof-audio-pci 0000:00:1f.3: ipc rx: 0x90020000: GLB_TRACE_MSG
    [  982.931294] sof-audio-pci 0000:00:1f.3: ipc rx done: 0x90020000: GLB_TRACE_MSG
    [  983.978611] intel-sdw sdw-master-1: IO transfer timed out
    [  983.978628] rt700 sdw:1:25d:700:0:0: [rt700_sdw_write] 3121 <= 0000
    [  983.978834] intel-sdw sdw-master-1: Msg Ack not received
    [  983.978838] intel-sdw sdw-master-1: Msg ignored for Slave 0
    [  983.978845] intel-sdw sdw-master-1: No more devices to enumerate
    [  983.978850] intel-sdw sdw-master-1: End of sdw_program_device_num ret 0
    [  983.978922] intel-sdw sdw-master-1: Msg Ack not received
    [  983.978925] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.978931] rt700 sdw:1:25d:700:0:0: Unable to sync register 0x3501. -61
    [  983.979001] intel-sdw sdw-master-1: Msg Ack not received
    [  983.979004] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.979009] rt700 sdw:1:25d:700:0:0: Unable to sync register 0x7520001a. -61
    [  983.979022] sdw_rt700 sdw_rt700: ASoC: Scheduling resume work
    [  983.979030] sdw_rt700 sdw_rt700: ASoC: starting resume work
    [  983.979194] sdw_rt700 sdw_rt700: ASoC: resume work completed
    [  983.979448] intel-sdw sdw-master-1: Msg Ack not received
    [  983.979453] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.979581] intel-sdw sdw-master-1: Msg Ack not received
    [  983.979587] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.979760] intel-sdw sdw-master-1: Msg Ack not received
    [  983.979763] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.979855] intel-sdw sdw-master-1: Msg Ack not received
    [  983.979859] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.979928] intel-sdw sdw-master-1: Msg Ack not received
    [  983.979930] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.981774] acpi LNXPOWER:09: Turning OFF
    [  983.982634] acpi LNXPOWER:08: Turning OFF
    [  983.985217] OOM killer enabled.
    [  983.985218] Restarting tasks ... 
    [  983.986604]  SDW1-speakers: ASoC: prepare FE SDW1-speakers
    [  983.986607]  SDW1-Playback: ASoC: prepare BE SDW1-Playback
    [  983.986613] intel-sdw sdw-master-1: intel_prepare: SDW1 Pin2: start
    [  983.986628] sof-audio-pci 0000:00:1f.3: ipc tx: 0x80010000: GLB_DAI_MSG: CONFIG
    [  983.990106] done.
    [  983.994688] sof-audio-pci 0000:00:1f.3: ipc tx succeeded: 0x80010000: GLB_DAI_MSG: CONFIG
    [  983.994690] sdw_prepare_stream: SDW1 Pin2-Playback start
    [  983.994743] intel-sdw sdw-master-1: Msg Ack not received
    [  983.994745] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.994747] rt700 sdw:1:25d:700:0:0: DPN_PortCtrl register write failed for port 1
    [  983.994750] intel-sdw sdw-master-1: Program transport params failed: -61
    [  983.994752] intel-sdw sdw-master-1: Program params failed: -61
    [  983.994753] Prepare for stream:SDW1 Pin2-Playback failed: -61
    [  983.994754] sdw_prepare_stream: SDW1 Pin2-Playback: done
    [  983.994756] intel-sdw sdw-master-1: intel_prepare: SDW1 Pin2: done
    [  983.994758] intel-sdw sdw-master-1: ASoC: cpu DAI prepare error: -61
    [  983.994759]  SDW1-Playback: ASoC: backend prepare failed -61
    [  983.994874]  SDW1-speakers: ASoC: hw_free FE SDW1-speakers
    [  983.994878] sof-audio-pci 0000:00:1f.3: pcm: free stream 0 dir 0
    [  983.994886]  SDW1-Playback: ASoC: hw_free BE SDW1-Playback
    [  983.994889] intel-sdw sdw-master-1: intel_hw_free: SDW1 Pin2: start
    [  983.994891] sdw_deprepare_stream: SDW1 Pin2-Playback: start
    [  983.994964] sdw_deprepare_stream: SDW1 Pin2-Playback: done
    [  983.994971] sof-audio-pci 0000:00:1f.3: ipc tx: 0x80010000: GLB_DAI_MSG: CONFIG
    [  983.995068] sof-audio-pci 0000:00:1f.3: ipc tx succeeded: 0x80010000: GLB_DAI_MSG: CONFIG
    [  983.995069] intel-sdw sdw-master-1: intel_hw_free: SDW1 Pin2: done
    [  983.995090]  SDW1-Playback: ASoC: close BE SDW1-Playback
    [  983.995092] intel-sdw sdw-master-1: intel_shutdown: SDW1 Pin2: start
    [  983.995094] intel-sdw sdw-master-1: intel_shutdown: SDW1 Pin2: done
    [  983.995120]  SDW1-speakers: ASoC: close FE SDW1-speakers
    [  983.995122] sof-audio-pci 0000:00:1f.3: pcm: close stream 0 dir 0
    [  983.995125]  SDW1-Playback: ASoC: BE SDW1-Playback event 2 dir 0
    [  983.996245] intel-sdw sdw-master-1: Msg Ack not received
    [  983.996247] intel-sdw sdw-master-1: Msg ignored for Slave 1
    [  983.996455]  SDW1-speakers: ASoC: BE playback disconnect check for SDW1-Playback
    [  983.996457]  SDW1-speakers: freed DSP playback path SDW1-speakers -> SDW1-Playback
    [  984.041280] PM: suspend exit
    [  984.190217] asix 1-8.1:1.0 enx000ec6c686b2: link up, 100Mbps, full-duplex, lpa 0x41E1
    [  984.931289] sof-audio-pci 0000:00:1f.3: ipc rx: 0x90020000: GLB_TRACE_MSG
    [  984.931443] sof-audio-pci 0000:00:1f.3: ipc rx done: 0x90020000: GLB_TRACE_MSG
    

    s3_test_33_logger_all.log
    test_33.log

  20. bardliao commented on Oct 18, 2019

    @bardliao
    Collaborator

    Looks like it is a different issue. Would it be better to create a new issue for it?

  21. plbossart commented on Oct 18, 2019

    @plbossart
    MemberAuthor
  22. YvonneYang2 commented on Oct 21, 2019

    @YvonneYang2

    Original issue is not reproduced with test recipe as below. One new issue after #1327 merged will be tracked in #1340

    kernel: https://github.com/thesofproject/linux/tree/integration/soundwire-latest commit: 29debf8
    FW: https://github.com/thesofproject/sof/commits/master commit: 3d5d314
    tplg: Same with FW branch, sof-icl-rt711-rt1308-rt715-hdmi.tplg rename to sof-icl-rt711-rt1308-rt715.tplg
    platform: ICL RVP, with codec ALC711 -RT1308, RT715 in SDW mode

  23. YvonneYang2 commented on Oct 21, 2019

    @YvonneYang2

    Close for not reproduced and track new behavior in #1344

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 platformbugSomething isn't workingsuspend resumeIssues related to suspend resume (e.g. rtcwake)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions