Skip to content

Up2: load/unload module always fail because of IPC issues #534

Closed

Description

@plbossart

When executing sof_bootloop.sh, sooner or later we hit an issue with the trace. This time it was at the 39th iteration. Increasing the sleep time between insert/remove seems to make things better, maybe we have a synchronization issue. Once the IPC error occurs, it's no longer possible to load/unload modules.

[  451.561107] sof-audio sof-audio: stream_tag: 1
[  451.561144] sof-audio sof-audio: ipc tx: 0x90010000: GLB_TRACE_MSG
[  451.561362] sof-audio sof-audio: error: ipc error for 0x90010000 size 0xc
[  451.561802] sof-audio sof-audio: error: can't set params for DMA for trace -22
[  451.562288] sof-audio sof-audio: warning: failed to initialize trace -22
[  451.562430] sof-audio sof-audio: created machine bxt-pcm512x

Activity

  1. plbossart commented on Jan 11, 2019

    @plbossart
    MemberAuthor

    Additional tests show the error may happen on resume as well, but still with the DMA trace.

    boot_fail.log

    kernel SHA1: 2ac82ee
    sof SHA1: 872cefe

  2. ranj063 commented on Jan 11, 2019

    @ranj063
    Collaborator

    @plbossart I cant even get to the second iteration in my case. But I have a hunch about the call to suspend_streams() in our PM suspend sequence.
    @keyonjie and I talked about possibly checking if it is really required or not. It seems to work on chrome but I'll need to verify on up2.

  3. plbossart commented on Jan 12, 2019

    @plbossart
    MemberAuthor

    @ranj063 indeed sof_bootloop.sh always failed, I had to add a sleep 5 between iterations to make it work for longer. Definitively a timing/race condition.
    Also keep in mind Chrome stops the streams before suspend and restarts them, so there are differences to check.

  4. added
    bugSomething isn't working
    APLApplies to ApolloLake platform
    on Jan 15, 2019
  5. zhuyingjiang commented on Jan 16, 2019

    @zhuyingjiang

    @plbossart I still face a oops, during the loop, the first is ok, and then the scripts dead, the dmesg got the attached log.
    bootloop_oops.log
    I think this is another issue with this loop.

  6. ranj063 commented on Jan 16, 2019

    @ranj063
    Collaborator

    @zhuyingjiang finally someone else is seeing the same issue as mine.

  7. zhuyingjiang commented on Jan 16, 2019

    @zhuyingjiang

    @zhuyingjiang finally someone else is seeing the same issue as mine.
    Does the log be the same?

  8. plbossart commented on Jan 16, 2019

    @plbossart
    MemberAuthor

    I don't have a kernel oops, and this one seems like the result of a bad error handling rather than a host-dsp issue. Maybe file it as a different issue? Also pretty please include all the dmesg (or all the sof parts) so that we can know what the setup is prior to the crash. I don't get if you are using the nocodec mode (known issue) or the PCM512x board?

  9. ranj063 commented on Jan 17, 2019

    @ranj063
    Collaborator

    @zhuyingjiang @plbossart my log in the other bug #490 is very similar to what Yingjiang is seeing.

  10. zhuyingjiang commented on Jan 17, 2019

    @zhuyingjiang

    @zhuyingjiang @plbossart my log in the other bug #490 is very similar to what Yingjiang is seeing.

    @ranj063 @plbossart Yes, the issue I found is the same as #490. I will focus on the issue Pierre found in this thread.

  11. zhuyingjiang commented on Jan 17, 2019

    @zhuyingjiang

    I don't have a kernel oops, and this one seems like the result of a bad error handling rather than a host-dsp issue. Maybe file it as a different issue? Also pretty please include all the dmesg (or all the sof parts) so that we can know what the setup is prior to the crash. I don't get if you are using the nocodec mode (known issue) or the PCM512x board?

    @plbossart My problem is that I use the same version you provide (kernel SHA1: 2ac82ee, sof SHA1: 872cefe) can't reproduce the issue you found, I am using PCM512x, and my issue found is the same as Rajani found in #490.
    Am I missed something? which one do you use, PCM512x or nocodec?

  12. ranj063 commented on Jan 17, 2019

    @ranj063
    Collaborator

    @zhuyingjiang @plbossart I fixed my problem by disabling pulseaudio. It was triggering a stream to play the boot up sound and it interfered with the timing of sof_remove.

    So with pulseaudio disabled, I am able to run the loop of 100 iterations of load/unload.

  13. zhuyingjiang commented on Jan 17, 2019

    @zhuyingjiang

    @ranj063 @plbossart Yes, with pulseaudio disabled, I still got 100 loops. Can we close this issue and #490 ?

  14. zhuyingjiang commented on Jan 22, 2019

    @zhuyingjiang

    The analysis of this issue is:
    The pulseaudio play a 5 seconds wav every time the sof module is inserted, but the sof_remove next run only delay 1 second; the PCM is locked during playing, when the sof_remove.sh try to disconnect device with snd_pcm_dev_disconnect it got stuck.
    So there are 2 ways:
    1 disable the pulseaudio when do the insert/remove loop.
    2 sleep longer than 5 seconds after sof_insert

    The pulse wav captured when do 10 seconds delay between remove and insert, although we can't heard it.
    wav-captured-during-loop
    wav-captured-during-loop.zip
    The pulse wav play can be seen in the end of the log(from 98 to 103, 10 seconds delay added in between):

    [ 98.246567] sof-audio sof-audio: ipc tx succeeded: 0x50020000: GLB_COMP_MSG: GET_VALUE
    [ 98.246601] sof-audio sof-audio: ipc tx: 0x50020000: GLB_COMP_MSG: GET_VALUE
    [ 98.246761] sof-audio sof-audio: ipc tx succeeded: 0x50020000: GLB_COMP_MSG: GET_VALUE
    [ 98.256752] sof-audio sof-audio: pcm: trigger stream 0 dir 0 cmd 1
    [ 98.256787] sof-audio sof-audio: ipc tx: 0x60040000: GLB_STREAM_MSG: TRIG_START
    [ 98.256998] sof-audio sof-audio: ipc tx succeeded: 0x60040000: GLB_STREAM_MSG: TRIG_START
    [ 98.657926] sof-audio sof-audio: ipc rx: 0x90020000: GLB_TRACE_MSG
    [ 98.657948] sof-audio sof-audio: ipc rx done: 0x90020000: GLB_TRACE_MSG
    [ 99.157886] sof-audio sof-audio: ipc rx: 0x90020000: GLB_TRACE_MSG
    [ 99.157909] sof-audio sof-audio: ipc rx done: 0x90020000: GLB_TRACE_MSG
    [ 103.259662] sof-audio sof-audio: pcm: trigger stream 0 dir 0 cmd 0
    [ 103.259918] sof-audio sof-audio: ipc tx: 0x60050000: GLB_STREAM_MSG: TRIG_STOP
    [ 103.260254] sof-audio sof-audio: ipc tx succeeded: 0x60050000: GLB_STREAM_MSG: TRIG_STOP
    [ 103.260344] sof-audio sof-audio: pcm: free stream 0 dir 0
    [ 103.260367] sof-audio sof-audio: ipc tx: 0x60030000: GLB_STREAM_MSG: PCM_FREE
    [ 103.260517] sof-audio sof-audio: ipc tx succeeded: 0x60030000: GLB_STREAM_MSG: PCM_FREE
    [ 103.275925] sof-audio sof-audio: pcm: close stream 0 dir 0

    by compare the 1 second delay and 10 seconds delay log, we can find that in 10 seconds delay log the PCM stream is stoped after 5 seconds:
    boot_0-add-10s-delay.log
    boot_0-add-1s-delay.log
    this one is the log which disabled pulse, no PCM playing after sof_insert:
    boot-disable-pulse_0.log

    The call stack during sof_remove:
    devm_card_release
    =>snd_soc_unregister_card
    =>snd_soc_unbind_card
    =>snd_soc_dapm_shutdown
    =>soc_cleanup_card_resources
    1=>snd_soc_tplg_component_remove
    =>remove_dai
    =>remove_link
    =>remove_widget
    ==>sof_widget_unload
    ===>hda_dsp_core_reset_power_down
    ====>hda_dsp_core_power_down
    2=>snd_card_free
    ==>init_completion
    ==>snd_card_free_when_closed
    ===>snd_card_disconnect
    ====>snd_pcm_dev_disconnect (stuck here for the PCM is playing and locked)
    ===>put_device
    ==>wait_for_completion
    The error may different depend on the PCM playing state.
    We can do forbid module remove when PCM is playing, but this seems should be handled in ASOC?
    @plbossart @lgirdwood

  15. mengdonglin commented on Jan 22, 2019

    @mengdonglin

    @plbossart @zhuyingjiang @ranj063 @keyonjie @bardliao

    The script sof_remove.sh shows we start from removing the PCI device driver, not the machine driver that registers the sound card. Maybe we should remove the machine driver at first?
    Probably ALSA can prevent removing the sound card that is being used, and report 'device busy' if Pulseaudio or aplay is using the device.

    https://github.com/thesofproject/sof/blob/master/tools/kmod_scripts/sof_remove.sh:
    remove_module sof_pci_dev
    remove_module sof_acpi_dev
    ...
    remove_module snd_soc_sst_bytcr_rt5640
    remove_module snd_soc_sst_bytcr_rt5651
    remove_module snd_soc_sst_cht_bsw_rt5645
    remove_module snd_soc_sst_cht_bsw_rt5670
    remove_module snd_soc_sst_byt_cht_da7213
    remove_module snd_soc_sst_bxt_pcm512x
    remove_module snd_soc_sst_bxt_tdf8532
    remove_module snd_soc_cnl_rt274
    remove_module snd_sof_nocodec
    remove_module snd_sof

  16. keyonjie commented on Jan 22, 2019

    @keyonjie

    @mengdonglin I just went though this, the existed scripts looks fine.

    The crucial one in remove is "remove_module sof_pci_dev"(or remove_module sof_acpi_dev"), once this is removed, all platform devices we created in SOF drivers will be deleted, and then we can remove other remained drivers(machine driver, platform driver, intel platform drivers, xtensa drivers) in any sequence.

  17. zhuyingjiang commented on Jan 22, 2019

    @zhuyingjiang

    another case analysed:
    if there is no PCM playing and do sof_remove.sh. for the sof_suspend has been called, sof_remove will call sof_resume first before remove.
    but when PCM is playing, sof_suspend is not called, sof_remove will directly call devm_card_release, so the state is not correct, I will check the detail difference.

  18. plbossart commented on Jan 23, 2019

    @plbossart
    MemberAuthor

    This thread has completely forked. My initial issue was that the Trace DMA IPC fails and that resulted in load/module failing. The problem with userspace trying to play while we remove is a different one. Please address each issue separately.

  19. plbossart commented on Jan 23, 2019

    @plbossart
    MemberAuthor

    I retried with an updated code
    firmware: eca416a
    kernel: e4fb585

    and still face a number of IPC issues - however not just with the trace DMA (likely because of a fix Keyon added today). Still this is not robust at all, the test fails within 80 loops. see below different results (not consecutive)

    You need the update for kmod_scripts shared at thesofproject/sof#880

    [  258.931026] BUG: Bad page state in process modprobe  pfn:1781de
    [  258.931351] page:fffff5d205e07780 count:-1 mapcount:0 mapping:0000000000000000 index:0x0
    [  258.931859] flags: 0x200000000000000()
    [  258.932120] raw: 0200000000000000 dead000000000100 dead000000000200 0000000000000000
    [  258.932524] raw: 0000000000000000 0000000000000000 ffffffffffffffff 0000000000000000
    [  258.932929] page dumped because: nonzero _count
    [  258.933185] Modules linked in: snd_soc_rl6231 snd_soc_hdac_hdmi snd_soc_dmic snd_soc_hdac_hda snd_sof_intel_hda snd_hda_ext_core snd_hda_codec snd_hwdep snd_hda_core iptable_nat nf_nat_ipv4 nf_nat x86_pkg_temp_thermal intel_lpss_pci intel_lpss mfd_core snd_soc_core snd_pcm efivarfs mmc_block sdhci_pci cqhci sdhci xhci_pci xhci_hcd [last unloaded: snd_soc_acpi]
    [  258.933205] CPU: 1 PID: 11086 Comm: modprobe Not tainted 4.20.0-test+ #12
    [  258.933206] Hardware name: AAEON UP-APL01/UP-APL01, BIOS UPA1AM40 08/06/2018
    [  258.933208] Call Trace:
    [  258.933220]  dump_stack+0x46/0x5b
    [  258.933226]  bad_page+0xbf/0x120
    [  258.933229]  get_page_from_freelist+0xe12/0xfd0
    [  258.933234]  ? 0xffffffffc0151000
    [  258.933237]  ? alloc_vmap_area+0x247/0x350
    [  258.933239]  __alloc_pages_nodemask+0x11f/0x260
    [  258.933242]  __vmalloc_node_range+0x140/0x260
    [  258.933246]  ? load_module+0x8e4/0x2560
    [  258.933249]  module_alloc+0x6c/0xc0
    [  258.933251]  ? load_module+0x8e4/0x2560
    [  258.933253]  load_module+0x8e4/0x2560
    [  258.933257]  ? vfs_read+0x10a/0x130
    [  258.933260]  ? kernel_read_file+0x1a3/0x1d0
    [  258.933262]  ? __do_sys_finit_module+0xba/0xe0
    [  258.933264]  __do_sys_finit_module+0xba/0xe0
    [  258.933268]  do_syscall_64+0x43/0xf0
    [  258.933272]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [  258.933275] RIP: 0033:0x7f1eb7984259
    [  258.933278] Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 0f 4c 2b 00 f7 d8 64 89 01 48
    [  258.933279] RSP: 002b:00007fffc37e43c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
    [  258.933281] RAX: ffffffffffffffda RBX: 000055b97a466e10 RCX: 00007f1eb7984259
    [  258.933283] RDX: 0000000000000000 RSI: 000055b979de7638 RDI: 0000000000000004
    [  258.933284] RBP: 000055b979de7638 R08: 0000000000000000 R09: 0000000000000000
    [  258.933285] R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
    [  258.933286] R13: 000055b97a466550 R14: 0000000000040000 R15: 0000000000000000
    [  258.933288] Disabling lock debugging due to kernel taint
    
    [  394.635126] sof-audio sof-audio: ipc tx: 0x30010000: GLB_TPLG_MSG: COMP_NEW
    [  394.635235] sof-audio sof-audio: error: ipc error for 0x30010000 size 0x14
    [  394.635708] sof-audio sof-audio: error: failed to load widget type 27 with ID: 10
    [  394.636177] sof-audio sof-audio: error: failed to restore pipeline after resume -22
    
    [  674.677614] sof-audio sof-audio: tplg: config SSP5 fmt 0x4001 mclk 24576000 bclk 3072000 fclk 48000 width (24)32 sl
    ots 2 mclk id 0
    [  674.677634] sof-audio sof-audio: ipc tx: 0x80010000: GLB_DAI_MSG: CONFIG
    [  674.677735] sof-audio sof-audio: ipc tx succeeded: 0x80010000: GLB_DAI_MSG: CONFIG
    [  674.677751] sof-audio-pci 0000:00:0e.0: link dma channel 0 for playback
    [  674.677770] sof-audio sof-audio: ipc tx: 0x80010000: GLB_DAI_MSG: CONFIG
    [  674.677851] sof-audio sof-audio: ipc tx succeeded: 0x80010000: GLB_DAI_MSG: CONFIG
    [  674.677859] sof-audio-pci 0000:00:0e.0: link dma channel 1 for playback
    [  674.677880] sof-audio sof-audio: ipc tx: 0x80010000: GLB_DAI_MSG: CONFIG
    [  674.677980] sof-audio sof-audio: error: ipc error for 0x80010000 size 0xc
    [  674.678357] sof-audio sof-audio: error: failed to set DAI config for direction:0 of HDA dai 1
    [  674.678802] sof-audio sof-audio: error: failed to process hda dai link iDisp2
    [  674.679176] sof-audio sof-audio: ASoC: physical link loading failed
    [  674.679517] sof-audio sof-audio: error: tplg component load failed -5
    [  674.679970] sof-audio sof-audio: error: failed to load DSP topology -22
    [  674.680320] sof-audio sof-audio: ASoC: failed to probe component -22
    [  674.680722] bxt-pcm512x bxt-pcm512x: ASoC: failed to instantiate card -22
    [  674.681083] bxt-pcm512x bxt-pcm512x: Topology forgot to remove link Port5?
    [  674.681085] bxt-pcm512x bxt-pcm512x: Topology forgot to remove link HDMI1?
    [  674.681087] bxt-pcm512x bxt-pcm512x: Topology forgot to remove link HDMI2?
    [  674.681088] bxt-pcm512x bxt-pcm512x: Topology forgot to remove link HDMI3?
    [  674.681114] bxt-pcm512x bxt-pcm512x: snd_soc_register_card failed -22
    [  674.681539] bxt-pcm512x: probe of bxt-pcm512x failed with error -22
    
  20. changed the title [-]Up2: load/unload module always fail because of trace DMA[/-] [+]Up2: load/unload module always fail because of IPC issues[/+] on Jan 23, 2019
  21. wenqingfu commented on Jan 27, 2019

    @wenqingfu

    this error is same as @ranj063 reported in thesofproject/sof#766. Can you try if non-SMP help?

    [  394.635126] sof-audio sof-audio: ipc tx: 0x30010000: GLB_TPLG_MSG: COMP_NEW
    [  394.635235] sof-audio sof-audio: error: ipc error for 0x30010000 size 0x14
    
  22. plbossart commented on Feb 8, 2019

    @plbossart
    MemberAuthor

    closing, we've run hundreds of cycles of module load/unload without issues

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

Metadata

Metadata

Assignees

Labels

APLApplies to ApolloLake platformbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions