Repository navigation
ASoC: SOF: core: harden shutdown helper - #2791
Conversation
|
This PR needs more work, when an error occurs during the pm_runtime_resume() done in pci_shutdown(), then the firmware boot may be IN_PROGRESS. The use of state > FW_BOOT_NOT_STARTED is not fully correct, this doesn't cover an error on resume. @ranj063 I'll need your help on this one. |
|
It looks like we have a race condition somewhere. The log below shows a correlation between the failures and actually resuming in pci_device_shutdown. When something triggers an earlier resume, there is no issue. working pattern non-working pattern |
@plbossart How did you save such message to the disk? I tried to save such message before but failed. |
I used netconsole on UpExtreme, it's got two Ethernet ports. see instructions here: it's almost like a UART but over Ethernet (UDP packets). The difficulty is finding a device with an Ethernet port, I don't think this works too well with USB dongles. |
kv2019i
left a comment
There was a problem hiding this comment.
Hmm, somewhat with uneasy. The probe_complete error paths have been problematic enough in the past, so not sure how we keep the error unroll paths in shutdown working. It would seem a brute-force shutdown that makes no assumtpions that driver+fw did sane things before sutdown, would be more sure and this is a code ptah we test every time we reboot a machine.
| cancel_work_sync(&sdev->probe_work); | ||
|
|
||
| dev_dbg(dev, "%s: fw state %d\n", __func__, sdev->fw_state); | ||
|
|
There was a problem hiding this comment.
Not sure this is useful. User-space is shutdown, so this log won't be seen in any normal log (i.e. no syslog/systemd anymore). You'll need a serial/netconsole to catch these, and then you probably can add additional traces as well.
| /* all update state to match */ | ||
| sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; | ||
|
|
||
| return ret; |
There was a problem hiding this comment.
This is very hard code to test for regressions, so I wonder if this is practical to add this. I mean if previously functioning device fails to boot after resume, something pretty bad has gone through.
I think it would be safer to have a more robust shutdown logic that would just shutdown the.
|
@ranj063 @kv2019i @libinyang see new log below. What's interesting is that something (PulseAudio?) opens a PCM device after the reboot command is issued, and the PCI device does a pm_runtime suspend while the reboot sequence is happening. |
|
branch updated in case someone wants to give it a try with the same setup |
|
@ranj063 @kv2019i @libinyang now I have a sequence that is 100% reproducible. When removing PulseAudio, there is no longer a pm_runtime_resume and pcm_open(), so the device has to be resumed in the shutdown sequence and that fails ALL THE TIME. So it's really going back to D0 in the shutdown sequence that's problematic. If the device is in D0 the shutdown works fine. I now suspect something in the PCI core that's doing things that get in the way of resuming? |
|
@plbossart wrote:
Hmm, that could happen. I wonder if we could detect that we are shutting down somehow in the PM resume flow (and not really boot the DSP anymore). OTOH, this probably won't work as shutdown/reboot is not directly related to how kernel does suspend/resume. This is still really strange why the boot fails. Some actions towards the DSP work. If some PCI level resources would have been taken down, I'd expect all I/O to fail. Maybe the fw-auth is not working anymore -- seems we don't complete the ROM execution successfully. |
@plbossart I tried on my tgl board and I can't reproduce this issue with disabling or enabling the pulseaudio. And all our CI DUTs do the test with PA disabled. They will reboot after test, but we didn't find such issue on all DUTs. If this issue hangs at pm-runtime resume in shutdown, can we reproduce this issue in pure pm-runtime suspend/resume? |
@kv2019i And it is strange that it shows "DSP core(s) enabled? 1 : core_mask f". I remember we only enable 1 core, do we? |
You can only see the issue if you have netconsole or a UART link. If you don't then you would never know there was a problem. |
@plbossart I captured the dmesg with a camera. It shows OK on my TGL platform. Please see the attachment. (I have disabled PA) |
Ack, that's useful. thanks @libinyang. I think we have possible BIOS issues here. |
When the probe is handled in a workqueue, we must use cancel_work_sync() in the shutdown helper to avoid possible race conditions. We must also take care of possible errors happening in a probe workqueue or during pm_runtime resume (called e.g. before shutdown for PCI devices). We should really only try to access hardware registers and initiate IPCs if the DSP is fully booted. Fixes: daff7f1 ("ASoC: SOF: add snd_sof_device_shutdown() helper for shutdown") Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
|
@libinyang @kv2019i @ranj063 I went back to a minimal fix, we'll have to deal with the firmware authentication during pm_runtime_resume as a separate, possibly device-specific, issue. |

When the probe is handled in a workqueue, we must use
cancel_work_sync() in the shutdown helper to avoid possible race
conditions.
Likewise, when a failure occurs in a workqueue, we should not try to
access hardware registers and create more problems
Fixes: daff7f1 ("ASoC: SOF: add snd_sof_device_shutdown() helper for shutdown")
Signed-off-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com