Skip to content

DAPM widget will not power off after playback is stop #661

Closed

Description

@keqiaozhang

This issue is found on Yorp Chromebook.

How to reproduce:

  1. plug in headset
  2. run speaker-test -D hw:0,1 -c 2 or aplay -Dhw:0,1 -f dat -c 2 Music.wav
  3. ctrl + c to stop speaker-test or aplay
  4. Do not unplug headset and check DAPM status:
    grep On /sys/kernel/debug/asoc/sof-glkda7219max/ -r

DAPM status after playback:

/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Playback:Playback: On  in 0 out 2
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/HPR:HPR: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/HPL:HPL: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Charge Pump:Charge Pump: On  in 0 out 0 - R71(0x47) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Headphone Right PGA:Headphone Right PGA: On  in 0 out 0 - R108(0x6c) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Headphone Left PGA:Headphone Left PGA: On  in 0 out 0 - R107(0x6b) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Mixout Right PGA:Mixout Right PGA: On  in 0 out 1 - R111(0x6f) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Mixout Left PGA:Mixout Left PGA: On  in 0 out 1 - R110(0x6e) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/DACR:DACR: On  in 0 out 1 - R106(0x6a) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/DACL:DACL: On  in 0 out 1 - R105(0x69) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/ST Mixer Out FilterR:ST Mixer Out FilterR: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/ST Mixer Out FilterL:ST Mixer Out FilterL: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Mixer Out FilterR:Mixer Out FilterR: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Mixer Out FilterL:Mixer Out FilterL: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Out DACR Mux:Out DACR Mux: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Out DACL Mux:Out DACL Mux: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/DAIIN:DAIIN: On  in 0 out 2
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/DAI:DAI: On  in 0 out 0 - R44(0x2c) mask 0x80
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/TONE:TONE: On  in 1 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/Mic Bias:Mic Bias: On (forced)  in 0 out 0 - R98(0x62) mask 0x8
/sys/kernel/debug/asoc/sof-glkda7219max/i2c-DLGS7219:00/dapm/bias_level:On
/sys/kernel/debug/asoc/sof-glkda7219max/MX98357A:00/dapm/bias_level:On
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/PIPELINE.7.HDA5.OUT:PIPELINE.7.HDA5.OUT: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF7.1:BUF7.1: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF7.0:BUF7.0: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/PIPELINE.6.HDA4.OUT:PIPELINE.6.HDA4.OUT: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF6.1:BUF6.1: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF6.0:BUF6.0: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/PIPELINE.5.HDA3.OUT:PIPELINE.5.HDA3.OUT: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF5.1:BUF5.1: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF5.0:BUF5.0: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/PIPELINE.4.DMIC0.IN:PIPELINE.4.DMIC0.IN: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF4.0:BUF4.0: On  in 1 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/PIPELINE.3.SSP2.IN:PIPELINE.3.SSP2.IN: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF3.1:BUF3.1: On  in 2 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF3.0:BUF3.0: On  in 2 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/PIPELINE.2.SSP2.OUT:PIPELINE.2.SSP2.OUT: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/SSP2.OUT:SSP2.OUT: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF2.1:BUF2.1: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF2.0:BUF2.0: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/PIPELINE.1.SSP1.OUT:PIPELINE.1.SSP1.OUT: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF1.1:BUF1.1: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/BUF1.0:BUF1.0: On  in 0 out 1
/sys/kernel/debug/asoc/sof-glkda7219max/sof-audio/dapm/bias_level:On
/sys/kernel/debug/asoc/sof-glkda7219max/dapm/Platform Clock:Platform Clock: On  in 0 out 0
/sys/kernel/debug/asoc/sof-glkda7219max/dapm/Headphone Jack:Headphone Jack: On  in 0 out 1

Test recipe:
ChromeOS:R73-11559.0.0
SOF/TPLG-glk-006-drop-stable: ad95dba8475b9
kernel-cros-sof-v4.14-rebase: a83979d

Activity

  1. bardliao commented on Feb 20, 2019

    @bardliao
    Collaborator

    soc_dapm_dai_stream_event() will be trigger when playback is stop. When soc_dapm_dai_stream_event(SSP2.OUT) is triggered before soc_dapm_dai_stream_event(Passthrough Playback 1), the SSP2.OUT widget which connect to codec's widget will be checked to on due to "Passthrough Playback 1" widget is on. Unfortunately, the order is exactly what we have now.
    But we don't see this issue on Up2. Compare to chrome book project, soc_dapm_dai_stream_event(SSP2.OUT) will be triggered by close_delayed_work() after above sequence is finished on Up2 and SSP2.OUT widget will be marked to off.

            if (rtd->pop_wait == 1) {
                    rtd->pop_wait = 0;
                    snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
                                              SND_SOC_DAPM_STREAM_STOP);
            }
    

    We can "fix" the issue by the following patch

    --- a/sound/soc/intel/boards/glk_rt5682_max98357a.c
    +++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c
    @@ -450,7 +450,6 @@ static struct snd_soc_dai_link geminilake_dais[] = {
                    .dai_fmt = SND_SOC_DAIFMT_I2S |
                            SND_SOC_DAIFMT_NB_NF |
                            SND_SOC_DAIFMT_CBS_CFS,
    -               .ignore_pmdown_time = 1,
                    .be_hw_params_fixup = geminilake_ssp_fixup,
                    .dpcm_playback = 1,
            },
    @@ -466,7 +465,6 @@ static struct snd_soc_dai_link geminilake_dais[] = {
                    .init = geminilake_rt5682_codec_init,
                    .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
                            SND_SOC_DAIFMT_CBS_CFS,
    -               .ignore_pmdown_time = 1,
                    .be_hw_params_fixup = geminilake_ssp_fixup,
                    .ops = &geminilake_rt5682_ops,
                    .dpcm_playback = 1,
    
  2. plbossart commented on Feb 20, 2019

    @plbossart
    Member
  3. bardliao commented on Feb 21, 2019

    @bardliao
    Collaborator

    @plbossart Sorry, it is not clear in the above comment. Let me describe it again. The FE dai (Passthrough Playback 1) should be closed before BE dai (SSP2.OUT). Otherwise, the BE dai will not be powered down since BE dai is connected to FE dai and the FE dai is still active. The .ignore_pmdown_time flag will take effect on both FE and BE dai. In other words, if we set .ignore_pmdown_time to a BE dai and not set in the connected FE dai, DAPM will close the BE dai immediately after playback is stop, but will close the FE dai after the power down time. As a result, the BE dai will be closed before the FE dai.
    Currently, there is no way to set the .ignore_pmdown_time flag to a FE dai through topology. So, the easiest to prevent this issue is to remove the .ignore_pmdown_time flag from BE dai.
    Thanks @xiulipan for helping on this.

  4. plbossart commented on Feb 21, 2019

    @plbossart
    Member

    @bardliao Sorry, still scratching my head on this one. if you stop the playback, isn't pm_runtime going to take everything down? Do we still get this issue after suspend happens?

  5. bardliao commented on Feb 22, 2019

    @bardliao
    Collaborator

    @bardliao Sorry, still scratching my head on this one. if you stop the playback, isn't pm_runtime going to take everything down? Do we still get this issue after suspend happens?

    Yes, we still get the issue after runtime suspended. pm_runtime will not take dapm down. In fact, the pcm512x codec is not going to suspend if there are some dapm widget on.

  6. plbossart commented on Feb 22, 2019

    @plbossart
    Member

    ok, so we do have the issue with the pcm512x (earlier it was stated it was not).
    I see weird things with the -nohdmi topology:

    root@ubilinux4:~# grep On /sys/kernel/debug/asoc/sof-bxt-pcm512x/ -r
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/PIPELINE.1.SSP5.OUT:PIPELINE.1.SSP5.OUT: On  in 0 out 0
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/BUF1.1:BUF1.1: On  in 0 out 2
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/BUF1.0:BUF1.0: On  in 0 out 2
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/bias_level:On
    root@ubilinux4:~# speaker-test -Dhw:0,0 -c2 -r48000 -t sine
    
    speaker-test 1.1.3
    
    Playback device is hw:0,0
    Stream parameters are 48000Hz, S16_LE, 2 channels
    Sine wave rate is 440.0000Hz
    Rate set to 48000Hz (requested 48000Hz)
    Buffer size range from 384 to 16320
    Period size range from 192 to 4032
    Using max buffer size 16320
    Periods = 4
    was set period_size = 3456
    was set buffer_size = 16320
     0 - Unknown
    ^C 1 - Unknown
    Time per period = 0.934100
    root@ubilinux4:~# grep On /sys/kernel/debug/asoc/sof-bxt-pcm512x/ -r
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/i2c-104C5122:00/dapm/Playback:Playback: On  in 0 out 2
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/i2c-104C5122:00/dapm/OUTR:OUTR: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/i2c-104C5122:00/dapm/OUTL:OUTL: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/i2c-104C5122:00/dapm/DACR:DACR: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/i2c-104C5122:00/dapm/DACL:DACL: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/i2c-104C5122:00/dapm/bias_level:On
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/PIPELINE.1.SSP5.OUT:PIPELINE.1.SSP5.OUT: On  in 0 out 0
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/SSP5.OUT:SSP5.OUT: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/BUF1.1:BUF1.1: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/BUF1.0:BUF1.0: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/bias_level:On
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/dapm/Ext Spk:Ext Spk: On  in 0 out 1
    
    after 5s
    root@ubilinux4:~# grep On /sys/kernel/debug/asoc/sof-bxt-pcm512x/ -r
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/PIPELINE.1.SSP5.OUT:PIPELINE.1.SSP5.OUT: On  in 0 out 0
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/BUF1.1:BUF1.1: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/BUF1.0:BUF1.0: On  in 0 out 1
    /sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm/bias_level:On
    
    
    

    I am not too sure why the SSP5 and BUF1.1/1.0 are On even before I start playing. I do see a number of IPCs on startup but there is no .trigger or .prepare/hw_params.

    What I do see is that the Pipeline seems to detached and somehow the buffers are on even though the other components they are linked to are off, so it could be an issue with the buffer widgets.
    dapm_before_platback

  7. plbossart commented on Feb 22, 2019

    @plbossart
    Member

    With HDMI taken out there is clearly something wrong with the topology:

    widgets

    root@ubilinux4:/sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm# more Passthrough\ Playback\ 0 
    Passthrough Playback 0: Off  in 0 out 4
     stream Passthrough Playback 0 inactive
     out  "static" "PCM0P"
     out  "static" "PCM0P"
    root@ubilinux4:/sys/kernel/debug/asoc/sof-bxt-pcm512x/0000:00:0e.0/dapm# more PCM0P 
    PCM0P: Off  in 0 out 2
     stream Passthrough Playback 0 inactive
     out  "static" "BUF1.0"
     in  "static" "Passthrough Playback 0"
     in  "static" "Passthrough Playback 0"
    

    The fact that there are two connections duplicated looks suspicious...

  8. bardliao commented on Feb 23, 2019

    @bardliao
    Collaborator

    @plbossart

    ok, so we do have the issue with the pcm512x (earlier it was stated it was not).

    You will see this issue if you set ignore_pmdown_time = 1, to the dai link of "SSP5-Codec" in bxt_pcm512x.c

    diff --git a/sound/soc/intel/boards/bxt_pcm512x.c b/sound/soc/intel/boards/bxt_pcm512x.c
    index 47e21e26c008..09b19f2a6ccc 100644
    --- a/sound/soc/intel/boards/bxt_pcm512x.c
    +++ b/sound/soc/intel/boards/bxt_pcm512x.c
    @@ -188,6 +188,7 @@ static struct snd_soc_dai_link dailink[] = {
                    .init = init,
                    .be_hw_params_fixup = codec_fixup,
                    .nonatomic = true,
    +               .ignore_pmdown_time = 1,
                    .dpcm_playback = 1,
                    .dpcm_capture = 1,
            },
    
    

    You will see more widgets are On and will not be Off after playback is stop

    ./i2c-104C5122:00/dapm/Playback:Playback: On  in 0 out 2
    ./i2c-104C5122:00/dapm/OUTR:OUTR: On  in 0 out 1
    ./i2c-104C5122:00/dapm/OUTL:OUTL: On  in 0 out 1
    ./i2c-104C5122:00/dapm/DACR:DACR: On  in 0 out 1
    ./i2c-104C5122:00/dapm/DACL:DACL: On  in 0 out 1
    ./i2c-104C5122:00/dapm/bias_level:On
    ./0000:00:0e.0/dapm/PIPELINE.1.SSP5.OUT:PIPELINE.1.SSP5.OUT: On  in 0 out 0
    ./0000:00:0e.0/dapm/SSP5.OUT:SSP5.OUT: On  in 0 out 1
    ./0000:00:0e.0/dapm/BUF1.1:BUF1.1: On  in 0 out 1
    ./0000:00:0e.0/dapm/BUF1.0:BUF1.0: On  in 0 out 1
    ./0000:00:0e.0/dapm/bias_level:On
    ./dapm/Ext Spk:Ext Spk: On  in 0 out 1
    

    SSP5.OUT on will lead to the codec widgets are on, and it is the problem.

    I am not too sure why the SSP5 and BUF1.1/1.0 are On even before I start playing. I do see a number of IPCs on startup but there is no .trigger or .prepare/hw_params.

    The widget id of BUF1.0 and BUF1.1 is snd_soc_dapm_buffer, and it is snd_soc_dapm_scheduler for PIPELINE.1.SSP5.OUT. The power will always on for those two widget ids
    w->power_check = dapm_always_on_check_power;

    The fact that there are two connections duplicated looks suspicious...

    It looks weird for me, too. But I think it will not effect the result since the power status of the duplicated connections will be the same.

  9. plbossart commented on Feb 25, 2019

    @plbossart
    Member

    @ranj063 any comments on the fact that there are duplicate connections? Could it be a topology issue?

  10. ranj063 commented on Feb 25, 2019

    @ranj063
    Collaborator

    @plbossart the duplicate connection looks weird. I'm not sure it is a topology issue. Looking at the tplg graph I only see the connections as below.
    tplg

  11. plbossart commented on Feb 25, 2019

    @plbossart
    Member

    @ranj063 can you remind me where this tplg->graph is? I'd like to run it on the PCM512x topology just to double-check the topology is correct

  12. ranj063 commented on Feb 25, 2019

    @ranj063
    Collaborator

    @plbossart right now its only a binary. I'll send it to you by email and I'm going to submit a PR today to add it to the topology repo.

  13. ranj063 commented on Feb 25, 2019

    @ranj063
    Collaborator

    @plbossart i figured out why there are 2 connections from Passthrough Playback 0 -> PCM0P. actually this is the case for all PCM's in our case. Turns out dapm automatically adds this route when the PCM0P widget is created. The duplicate connection comes from topology indeed. This comes from (in the case of pipe-volume-playback.m4) `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)'.

    If I remove this line from topology, the dapm graph shows up with 1 conenction but hw params fails because we use this route info to bind the PCM ID to the host component. But I think we can possibly remove it while creating the host comp. I'm working on the patch now. Will submit it ASAP.

  14. ranj063 commented on Feb 25, 2019

    @ranj063
    Collaborator

    @plbossart as for the second issue with the buffers and pipeline widgets not turning off, I have a fix for it too. will submit it soon. These widget types are missing their default power_check definitions in soc-dapm.c.

  15. ranj063 commented on Feb 25, 2019

    @ranj063
    Collaborator

    @plbossart #675 fixes both the problems with the buffers being ON and the duplicate connection.
    pcm512x-idle

  16. bardliao commented on Mar 1, 2019

    @bardliao
    Collaborator

    Close it as it has fixed by #675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GLKApplies to Gemini LakeP1Blocker bugs or important featuresbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions