Skip to content

[BUG] GLK Chromebooks with da7219 have 400ms delay waiting for SRM lock  #2124

Closed as not planned

Description

@fletcherw

cc @cujomalainey

Describe the bug
There is a 400ms delay when calling snd_pcm_prepare on glk chromebooks using the da7219 since the code to wait for the SRM lock times out after 400ms. I spoke with the author of the codec driver at Dialog, and their response was:

"I'm almost certain this is because the platforms in question are not enabling the WCLK before the codec's PLL is being enabled. [...] So on the Apollo lake and Kaby lake platforms (and probably other Intel ones using DA7219) what would happen is that the codec's PLL would be enabled before WCLK, you see the timeout in the kernel logs after the large delay, and then subsequently (at some point) the Intel I2S related code would then enable the WCLK and the PLL would then lock with SRM."

To Reproduce
Just starting a stream using "aplay /dev/zero" is sufficient to trigger this bug. There will be a noticeable delay of about 700ms before audio starts.

The message "da7219 i2c-DLGS7219:00: SRM failed to lock" will also appear in dmesg.

Reproduction Rate
Every time a stream is started with the codec powered down.

Expected behavior
The SRM lock bit should be flipped before the 400ms is elapsed and we should not see the delay/warning message in dmesg.

Environment

  1. Branch name and commit hash of the 2 repositories: sof (firmware/topology) and linux (kernel driver).
  2. Name of the topology file
    • Topology: presumably sof-glk-da7219.m4
  3. Name of the platform(s) on which the bug is observed.
    • Platform: GLK Chromebooks

Activity

  1. added
    bugSomething isn't working as expected
    on Nov 21, 2019
  2. plbossart commented on Nov 21, 2019

    @plbossart
    Member

    Humm... All machine drivers based on da7219 pretty much do the same thing, so not sure why this would be specific to GLK?
    besides, the MCLK is provided, so not sure why the codec would lock on the WCLK? The PLL reference should the be the MCLK, not WCLK.

  3. cujomalainey commented on Nov 22, 2019

    @cujomalainey
    Contributor

    This is not specific to GLK, we are just logging this here as a GLK bug since this is the only SOF based board that we have the da7219 on that we are seeing this issue with currently and figured since SOF is under active development we should report it here first.

  4. lgirdwood commented on Nov 22, 2019

    @lgirdwood
    Member
  5. plbossart commented on Nov 22, 2019

    @plbossart
    Member

    This is not specific to GLK, we are just logging this here as a GLK bug since this is the only SOF based board that we have the da7219 on that we are seeing this issue with currently and figured since SOF is under active development we should report it here first.

    ok, thanks for the precision.
    I think at some point we discussed turning on the bclock earlier, if it was needed, but if we'd need to turn the fsync/WCLK earlier that's a completely different story, we need need to start dummy transfers.
    @lbetlej please correct me if I am saying something silly here.

  6. cujomalainey commented on Nov 22, 2019

    @cujomalainey
    Contributor

    Jimmy pointed out there appears to be something similarly done for rt5663 on kbl. Maybe something similar needs to be done for all da7219 boards? https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/764232/

  7. plbossart commented on Nov 22, 2019

    @plbossart
    Member

    one of the difference with KBL is that the SOF firmware does not provide (yet) the ability to start BCLK/FSYNC on demand from the machine driver.
    It's something we know we'll need but it's not there just yet.

  8. lgirdwood commented on Nov 23, 2019

    @lgirdwood
    Member

    @plbossart thinking aloud here would could have a tuple flag for this in DAI topology (to enable certain clocks immediately after hw_params are known) e.g.

    1. hw_params IPC is sent from host to FW. hw_params propagates through pipeline.
    2. DAI driver gets hw_params and checks it's topology clock flags.
    3. DAI Enables MCKL/BCLK.
    4. Back on host, the machine driver prepare() stalls for clock lock time.
    5. Host then calls trigger(START)
  9. plbossart commented on Nov 25, 2019

    @plbossart
    Member

    @plbossart thinking aloud here would could have a tuple flag for this in DAI topology (to enable certain clocks immediately after hw_params are known) e.g.

    1. hw_params IPC is sent from host to FW. hw_params propagates through pipeline.
    2. DAI driver gets hw_params and checks it's topology clock flags.
    3. DAI Enables MCKL/BCLK.
    4. Back on host, the machine driver prepare() stalls for clock lock time.
    5. Host then calls trigger(START)

    Yes, and I remember discussing this with @lbetlej. We can enable MCLK and BCLK as soon as the config is known, and we can use the existing SSP quirk mask to indicate the desire behavior.
    The issue is for the WCLK/FSYNC, you have to enable it with dummy transfers so it's a completely different solution that would be needed.

  10. lgirdwood commented on Nov 25, 2019

    @lgirdwood
    Member

    @plbossart ouch, I can see why codec vendor has done this but from a system integration perspective it's undesirable (pretty much for every serial DAI IP from any vendor). Gah.

  11. plbossart commented on Nov 25, 2019

    @plbossart
    Member
  12. tlauda commented on Mar 19, 2020

    @tlauda
    Contributor

    @lgirdwood @plbossart Keeping this here or maybe turning into feature?

  13. lgirdwood commented on Mar 19, 2020

    @lgirdwood
    Member

    @plbossart machine driver infrastructure in ASoC ? or something similar ? My only other though is putting this 400ms delay in codec trigger() (not used atm IIRC)

  14. plbossart commented on Mar 19, 2020

    @plbossart
    Member

    we really need to expose MCLK, BCLK, FSYNC with the clock framework and let the machine driver turn them on/off at will (either on startup/shutdown or on DAPM event).

    it's been done before by the Skylake driver. The main issue for us is the FSYNC which can only work if we start dummy DMA transfers with zero-ed data. MCLK and BCLK can be turned on without audio transfers.

  15. lgirdwood commented on Mar 20, 2020

    @lgirdwood
    Member

    @plbossart we could hook this into hw_params IPC. i.e. have a topology flag that just says "keep playing silence until trigger(start)". This way FW can play silence, we schedule pipeline normally but we manually disconnect the DAI source component from the DAI buffer (until we get trigger(start) where we can then reconnect the DAI buffer source component and process the full pipeline).
    @tlauda any take on this ?

  16. 6 remaining items

  17. lgirdwood commented on Apr 10, 2020

    @lgirdwood
    Member

    @plbossart fine by me, the FW change is the same either way.

  18. plbossart commented on Apr 10, 2020

    @plbossart
    Member

    right, but the clock framework is a bit of a pain to implement.

  19. lgirdwood commented on Apr 10, 2020

    @lgirdwood
    Member

    The path of least resistance is maybe DAPM then ?

  20. plbossart commented on Apr 10, 2020

    @plbossart
    Member

    No I am thinking that maybe the right thing to do is have the SOF core create a clock client - but only when an I2S-based machine driver is used and not for HDaudio. Then the client sends IPCs as required. Since we can play with pm_runtime in the prepare_enable/disable_deprepare, the DSP would remain on as long as the clock is needed.
    We could even prototype this with a small change to @ranj063 's PC test client, instead of flooding the DSP we'd only send specific clock-related IPCs.

  21. bardliao commented on Aug 11, 2020

    @bardliao
    Collaborator

    @lgirdwood @plbossart Won't MCLK be turned on in or right after snd_sof_rintime_resume()?
    @macchian Could you measure the delay in each process?
    For example DSP boot: 20ms, waiting for MCLK ready: 100ms, codec power up: 150ms...
    So we can focus on the critical part to shorten the delay time.

  22. lgirdwood commented on Aug 11, 2020

    @lgirdwood
    Member

    @macchian is this still an issue or has it been solved hence the lack of discussion ?

  23. cujomalainey commented on Aug 11, 2020

    @cujomalainey
    Contributor

    I am still seeing activity on internal bug

  24. brentlu commented on Aug 12, 2020

    @brentlu
    Contributor

    Turning on mclk does not help because da7219 tries to lock the fsync in prepare stage. Another possible fix is using it's "PLL bypass mode" but it requires 11.288/24.576/49.152MHz mclk. This frequency could be achieved by using cardinal clock but KBL does not support it.

  25. brentlu commented on Aug 18, 2020

    @brentlu
    Contributor

    Another issue is there is 220ms delay which is caused by codec driver itself (30ms x 2 in da7219_mixout_event(), 40ms x 4 in da7219_mixout_event()). Google is about to check the 220ms delay with DA.

  26. plbossart commented on Jul 14, 2021

    @plbossart
    Member

    @brentlu @cujomalainey @fletcherw @bzhg does the recent work with the early BCLK enabling solve this SRM lock delay? I vaguely recall seeing such a statement, but the explanations above only talk about FSYNC which is still enabled in the trigger phase when data transfers start (the actual data come with a delay due to SOF pipelining).

    Also adding @lgirdwood and @sathya-nujella on the Intel side.

  27. cujomalainey commented on Jul 15, 2021

    @cujomalainey
    Contributor

    I haven't tested, I am working remote till aug ~10 (currently at the mercy of westjet and they are doing their best to mess with me) so I can't pull ToT and test. I didn't see any work land in the machine driver for the da7219, we would need to enable the clock early there wouldn't we?

  28. plbossart commented on Jul 15, 2021

    @plbossart
    Member

    we use the same topology as for the CS42L42 and the changes in the kernel are related to the SSP in general, not the machine driver.

  29. github-actions commented on Jun 20, 2025

    @github-actions

    This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

  30. added
    staleIssue/PR marked as stale and will be closed after 14 days if there is no activity.
    on Jun 20, 2025
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

    bugSomething isn't working as expectedstaleIssue/PR marked as stale and will be closed after 14 days if there is no activity.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions