Skip to content

MTL:Soundwire: Playback via Max98363 soundwire speaker is silent soon after reboot #4461

Closed

Description

@jairaj-arava

On the Soundwire Max98363 codec, soon after reboot with aplay or Youtube, the speaker playback is silent (4/10)
Tried #4345 and the repro rate got reduced to 1/10. Could see the SCP and DP registers 00 when the issue happens.
Setting the SCP and DP reg values to the working values fixes the issue.

The subusequent playbacks without any reboot doesn't have any issue.
The issue is not observed with the CS42L42 headset codec.

Activity

  1. plbossart commented on Jul 6, 2023

    @plbossart
    Member

    #4345 fixes pm_runtime, that shouldn't have any impacts on sound after boot.

    Please disable pm_runtime first to see if this changes anything.

    #disable PCI pm_runtime
    options snd_sof_pci sof_pci_debug=0x1
    
    #disable SDW runtime PM
    options soundwire_intel sdw_md_flags=0x01010101
    
  2. plbossart commented on Jul 6, 2023

    @plbossart
    Member

    also what do you mean by "Setting the SCP and DP reg values to the working values fixes the issue."

    These values are not visible through regmap, how did you set those values?

  3. bardliao commented on Jul 6, 2023

    @bardliao
    Collaborator

    @jairaj-arava @plbossart With limited information, I guess the issue might be that aplay started before the codec is attached. In this corner case, codec driver should do cache_sync after attached. However, max98363_resume() will return 0 directly if max98363->first_hw_init is false and max98363_io_init set max98363->first_hw_init = true after calling pm_runtime_get_noresume().
    Please see if #4462 makes sense, thanks.

  4. plbossart commented on Jul 6, 2023

    @plbossart
    Member

    Thanks @bardliao this goes back to my earlier question, what exactly was the solution described in "Setting the SCP and DP reg values to the working values fixes the issue."

    SCP and DP values are related to transport, but usually the problem is with regmap caches. That's two very different root causes.

  5. jairaj-arava commented on Jul 6, 2023

    @jairaj-arava
    Author

    also what do you mean by "Setting the SCP and DP reg values to the working values fixes the issue."

    These values are not visible through regmap, how did you set those values?

    Hi @plbossart
    Earlier, Maxim codec team provided a work around patch for another debug to access these SCP/DP registers. Hence, it allowed me to set these registers via commandline. Below are the expected values but the same were 0's when the issue hits.
    0103: 0f
    0120: 01
    0122: c7
    0124: 01
    0126: 33
    0132: c7
    0134: 01
    0136: 33

    As discussed with @bardliao , I will provide the full dmesg log when the issue happens.

  6. plbossart commented on Jul 6, 2023

    @plbossart
    Member

    This has really nothing to do with the regmap cache. My guess is that the port setup isn't done right.

  7. jairaj-arava commented on Jul 6, 2023

    @jairaj-arava
    Author

    This has really nothing to do with the regmap cache. My guess is that the port setup isn't done right.

    so @plbossart , these SCP/DP registers are mandatory for the port setup before the data is fed to the codec?

  8. plbossart commented on Jul 6, 2023

    @plbossart
    Member

    Well, yes. If those registers are not setup, then the codec will not use the data at all. It's different to being 'silent', it never processed the samples.

  9. plbossart commented on Jul 6, 2023

    @plbossart
    Member

    Well, yes. If those registers are not setup, then the codec will not use the data at all. It's different to being 'silent', it never processed the samples.

  10. jairaj-arava commented on Jul 6, 2023

    @jairaj-arava
    Author

    @jairaj-arava @plbossart With limited information, I guess the issue might be that aplay started before the codec is attached. In this corner case, codec driver should do cache_sync after attached. However, max98363_resume() will return 0 directly if max98363->first_hw_init is false and max98363_io_init set max98363->first_hw_init = true after calling pm_runtime_get_noresume(). Please see if #4462 makes sense, thanks.

    Hi @bardliao,
    Yes, as you suspected, I see in the logs during the non-working case with fix #4345 (started immediately as soon as system boots) or without the fix , after PCM triggert start, the slave is attached as shown below.

    [ 20.530374] sof-audio-pci-intel-mtl 0000:00:1f.3: pcm: trigger stream 2 dir 0 cmd 1
    [ 20.530389] sof-audio-pci-intel-mtl 0000:00:1f.3: trigger cmd: 1 state: 4
    [ 20.530398] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx : 0x13000003|0x1 [data size: 12]
    [ 20.530743] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx reply: 0x33000000|0x1
    [ 20.530765] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx done : 0x13000003|0x1 [data size: 12]
    [ 20.530771] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx : 0x13000004|0x1 [data size: 12]
    [ 20.531372] soundwire_intel soundwire_intel.link.2: Slave status change: 0x1100000
    [ 20.531401] max98363 sdw:2:019f:8363:00:1: Slave 5 state check1: UNATTACHED, status was 1
    [ 20.540625] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx reply: 0x33000000|0x1
    [ 20.540652] max98363 sdw:2:019f:8363:00:1: initializing enumeration and init completion for Slave 5
    [ 20.540654] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx done : 0x13000004|0x1 [data size: 12]
    [ [ 20.530374] sof-audio-pci-intel-mtl 0000:00:1f.3: pcm: trigger stream 2 dir 0 cmd 1
    [ 20.530389] sof-audio-pci-intel-mtl 0000:00:1f.3: trigger cmd: 1 state: 4
    ...........
    [ 20.531372] soundwire_intel soundwire_intel.link.2: Slave status change: 0x1100000
    [ 20.531401] max98363 sdw:2:019f:8363:00:1: Slave 5 state check1: UNATTACHED, status was 1
    [ 20.540625] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx reply: 0x33000000|0x1
    [ 20.540652] max98363 sdw:2:019f:8363:00:1: initializing enumeration and init completion for Slave 5
    [ 20.540654] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx done : 0x13000004|0x1 [data size: 12]
    [ 20.540660] max98363 sdw:2:019f:8363:00:0: Slave 6 state check1: UNATTACHED, status was 1
    [ 20.540665] max98363 sdw:2:019f:8363:00:0: initializing enumeration and init completion for Slave 6
    [ 20.540679] soundwire_intel soundwire_intel.link.2: Device0 detected after clearing status, iteration 1
    [ 20.549871] sof-audio-pci-intel-mtl 0000:00:1f.3: FW Poll Status: reg[0x1c0]=0x2014001e successful
    [ 20.549876] soundwire sdw-master-1: Slave attached, programming device number
    [ 20.550058] soundwire sdw-master-1: SDW Slave Addr: 31019f836300
    [ 20.550064] soundwire sdw-master-1: SDW Slave class_id 0x00, mfg_id 0x019f, part_id 0x8363, unique_id 0x1, version 0x3
    [ 20.550072] soundwire sdw-master-1: Slave already registered, reusing dev_num:5

    Attached the full logs.
    NOT_WORKING_WITH_4345fix.txt
    dmesg_NOTWORKING_without_4345fix.txt
    working_withFix4345.txt

    Also, another finding is, when I repro the issue with the fix #4345 (very rare happens) and also without the fix, in both scenarios the issue happens when the DSP is not in D3 and soundwire links are not powered down. I don't see the issue if DSP wents to D3 and soundwire links are powered down in all my trials.

  11. bardliao commented on Jul 7, 2023

    @bardliao
    Collaborator

    @jairaj-arava sdw_enable_stream(sdw_stream); is called in sof_sdw.c's .trigger ops which will program the SCP/DP registers.
    However, from the log:

    [   20.530374] sof-audio-pci-intel-mtl 0000:00:1f.3: pcm: trigger stream 2 dir 0 cmd 1
    ...
    [   20.531372] soundwire_intel soundwire_intel.link.2: Slave status change: 0x1100000
    [   20.531401] max98363 sdw:2:019f:8363:00:1: Slave 5 state check1: UNATTACHED, status was 1
    [   20.540625] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx reply: 0x33000000|0x1
    [   20.540652] max98363 sdw:2:019f:8363:00:1: initializing enumeration and init completion for Slave 5
    [   20.540654] sof-audio-pci-intel-mtl 0000:00:1f.3: ipc tx done : 0x13000004|0x1 [data size: 12]
    [   20.540660] max98363 sdw:2:019f:8363:00:0: Slave 6 state check1: UNATTACHED, status was 1
    [   20.540665] max98363 sdw:2:019f:8363:00:0: initializing enumeration and init completion for Slave 6
    [   20.540679] soundwire_intel soundwire_intel.link.2: Device0 detected after clearing status, iteration 1
    [   20.549871] sof-audio-pci-intel-mtl 0000:00:1f.3: FW Poll Status: reg[0x1c0]=0x2014001e successful
    [   20.549876] soundwire sdw-master-1: Slave attached, programming device number
    [   20.550058] soundwire sdw-master-1: SDW Slave Addr: 31019f836300
    [   20.550064] soundwire sdw-master-1: SDW Slave class_id 0x00, mfg_id 0x019f, part_id 0x8363, unique_id 0x1, version 0x3
    [   20.550072] soundwire sdw-master-1: Slave already registered, reusing dev_num:5
    [   20.550315] soundwire sdw-master-1: SDW Slave Addr: 30019f836300
    [   20.550324] soundwire sdw-master-1: SDW Slave class_id 0x00, mfg_id 0x019f, part_id 0x8363, unique_id 0x0, version 0x3
    [   20.550336] soundwire sdw-master-1: Slave already registered, reusing dev_num:6
    

    Slave re-attached after trigger. I think that is the problem.
    @plbossart Do you have any idea why the codec re-attached after pcm started?

  12. plbossart commented on Jul 7, 2023

    @plbossart
    Member

    @plbossart Do you have any idea why the codec re-attached after pcm started?

    No, it's a hardware issue we can't control. This should not happen, ever. The SoundWire design assumed that the link was reliable and we don't have any support for devices that come and go.

  13. 1 remaining item

  14. RanderWang commented on Jul 11, 2023

    @RanderWang

    It should be the same issue as 98373 bring up. @bardliao will test it and port it to 363.

  15. bardliao commented on Jul 11, 2023

    @bardliao
    Collaborator

    It should be the same issue as 98373 bring up. @bardliao will test it and port it to 363.

    No, @RanderWang the DSP is always active issue is not due to any dapm widget is active. That is a different issue from 98373. I can see 98363 is active, but I have no idea why yet.

  16. added
    SDWApplies to SoundWire bus for codec connection
    on Jul 11, 2023
  17. plbossart commented on Jul 11, 2023

    @plbossart
    Member

    Scenario 1: After reboot, once DSP enters into D3, the playback always works and later DSP is always remains active.

    I don't understand the comment @jairaj-aravav. What do you mean the DSP is always active? As measured by what? can you try to show the refcount if this is pm_runtime active?

    Scenario 2: After reboot, if we make a playback before DSP enters into D3 sporadically playback is not working and we see these unattached prints. As discussed, I see DSP is always active in both scenarios after the playback.

    It's likely that you have a race condition and start playback 'too early'. Please disable pm_runtime and report the results.

  18. bardliao commented on Jul 11, 2023

    @bardliao
    Collaborator

    Scenario 1: After reboot, once DSP enters into D3, the playback always works and later DSP is always remains active.

    I don't understand the comment @jairaj-aravav. What do you mean the DSP is always active? As measured by what? can you try to show the refcount if this is pm_runtime active?

    @plbossart He meant "cat /sys/bus/pci/devices/0000:00:1f.3/power/runtime_status" is active

  19. bardliao commented on Jul 11, 2023

    @bardliao
    Collaborator

    Scenario 1: After reboot, once DSP enters into D3, the playback always works and later DSP is always remains active.

    I don't understand the comment @jairaj-aravav. What do you mean the DSP is always active? As measured by what? can you try to show the refcount if this is pm_runtime active?

    @plbossart He meant "cat /sys/bus/pci/devices/0000:00:1f.3/power/runtime_status" is active

    And while 0000:00:1f.3 is active, cat sdw-master-1/sdw\:2\:019f\:8363\:00\:0/power/runtime_status will be active

  20. plbossart commented on Jul 11, 2023

    @plbossart
    Member

    Not following sorry, do you mean to say the runtime_status remains 'active' even after playback stops? I think we're really confusing things, the first order of business is to clarify why the amp loses sync and what happens without pm_runtime.

  21. bardliao commented on Jul 11, 2023

    @bardliao
    Collaborator

    Not following sorry, do you mean to say the runtime_status remains 'active' even after playback stops? I think we're really confusing things, the first order of business is to clarify why the amp loses sync and what happens without pm_runtime.

    Yes, they are 2 different issues. Let's disable runtime PM and focus on the amp silence issue.

  22. jairaj-arava commented on Jul 11, 2023

    @jairaj-arava
    Author

    Not following sorry, do you mean to say the runtime_status remains 'active' even after playback stops? I think we're really confusing things, the first order of business is to clarify why the amp loses sync and what happens without pm_runtime.

    Hi @plbossart ,
    Yes, there are two different issues that came up during debug.
    Issue#1. Speaker amp silence issue
    Issue#2. DSP active always after the spk amp playback.

    Not following sorry, do you mean to say the runtime_status remains 'active' even after playback stops? I think we're really confusing things, the first order of business is to clarify why the amp loses sync and what happens without pm_runtime.

    Yes, they are 2 different issues. Let's disable runtime PM and focus on the amp silence issue.

    @bardliao
    After disabling the pm_runtime using:
    #disable PCI pm_runtime
    options snd_sof_pci sof_pci_debug=0x1
    #disable SDW runtime PM
    options soundwire_intel sdw_md_flags=0x01010101

    After reboot the speaker amp is still silent for the first playback and the same slave unattached prints are seen in the log.

  23. jairaj-arava commented on Jul 13, 2023

    @jairaj-arava
    Author

    As said this is a sporadic issue, out of the observance from the logs during working and non-working scenario, it is clear that:

    Working scenario: During the playback, the SCP/DP registers are updated correctly and there are no unusual (unattached and re-attached) prints from the codec driver. Attached the log with comments.
    Working_after_reboot.txt

    Non-working scenario: During the playback, the SCP/DP registers are updated correctly, however later as the codec is unattached and re-attached, the SCP/DP registers are made 0’s. Once the playback is stopped, the SCP/DP registers are resumed to the working configuration. Attached the log with comments
    NOT_working_after_reboot.txt

  24. plbossart commented on Jul 26, 2023

    @plbossart
    Member

    @jairaj-arava can you make sure you have all the drivers/soundwire/ upstream patches in your kernel. There was a patch from Cirrus Logic maybe last year to deal with invalid unattached status with there are 2 devices on the same link.

  25. jairaj-arava commented on Jul 26, 2023

    @jairaj-arava
    Author

    @jairaj-arava can you make sure you have all the drivers/soundwire/ upstream patches in your kernel. There was a patch from Cirrus Logic maybe last year to deal with invalid unattached status with there are 2 devices on the same link.

    Hi @plbossart,
    Sure, will check on the Cirrus Logic patch. Here the issue was seen with Maxim speaker amp and if we found Cirrus logic patch for the same issue, will check if we can adopt those for the Maxim too and give a try.

  26. jairaj-arava commented on Jul 27, 2023

    @jairaj-arava
    Author

    Hi @pi

    @jairaj-arava can you make sure you have all the drivers/soundwire/ upstream patches in your kernel. There was a patch from Cirrus Logic maybe last year to deal with invalid unattached status with there are 2 devices on the same link.

    Hi @plbossart,
    I found the series you are mentioning about https://lore.kernel.org/all/20220914160248.1047627-1-rf@opensource.cirrus.com/.
    All the 5 patches are already part of the chrome kernel:

    soundwire: bus: Don't exit early if no device IDs were programmed
    soundwire: cadence: Fix lost ATTACHED interrupts when enumerating
    soundwire: bus: Don't re-enumerate before status is UNATTACHED
    soundwire: bus: Don't lose unattach notifications
    soundwire: cadence: fix updating slave status when a bus has multiple peripherals

    I see you dropped the series from Intel https://github.com/thesofproject/linux/pull/3836/commits as Richard patches were already in upstream by that time.

  27. jairaj-arava commented on Aug 3, 2023

    @jairaj-arava
    Author

    Hi,
    With the fix #4503, couldn't see both the spk amp silent and the DSP active always issues. Hence, closing this. Thanks.

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

Metadata

Metadata

Assignees

Labels

MTLApplies to Meteor Lake platform.SDWApplies to SoundWire bus for codec connection

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions