Repository navigation
ASoC: SOF: sof-pci-dev: add .shutdown callback - #2581
Conversation
| } | ||
| EXPORT_SYMBOL(snd_sof_device_remove); | ||
|
|
||
| int snd_sof_device_shutdown(struct device *dev) |
There was a problem hiding this comment.
PCI driver shutdown has "void" return type, so we can't return an error to upper layer. But, but, I think it's ok to keep the "int" and return type, and keep this aligned with rest of SOF ops API.
|
|
||
| /* | ||
| * turn DSP back to D0 from D0I3 before shutting down it, | ||
| * to avoid booting fail at some platforms from D0i3 status. |
There was a problem hiding this comment.
Would be good to split the Intel specific part into a separate patch. I.e. one to add shutdown op, and another to add Intel HDA implementation of it.
The comment is a bit vague, maybe just leave it out and explain the change in commit.
|
Thanks, @kv2019i comments addressed now. |
|
Thanks @lyakh updated now. |
kv2019i
left a comment
There was a problem hiding this comment.
Two minor issues in git commit messages, otherwise good for me.
| @@ -26,6 +26,8 @@ const struct snd_sof_dsp_ops sof_tgl_ops = { | |||
| .probe = hda_dsp_probe, | |||
There was a problem hiding this comment.
In commit, "Fixes:" is only used when pointing to commit hashes. To refer to a bug URL, please use "BugLink: " instead.
There was a problem hiding this comment.
@kv2019i since we are here and I know on i.MX there might be similar issues, do you know how the HIFI DSP is reset / power on / power off on Intel platforms?
Does the BIOS takes care of this. Or DSP by itself can initiate the rest/power off procedure?
There was a problem hiding this comment.
@dbaluta Actual power-on is triggered via PCI MMIO writes, see hda-dsp.c:hda_dsp_core_power_down() in kernel. On DSP side, there is a sequence to ramp down resources and got a loop executing waiti, see for example platform_pm_runtime_power_off().
There was a problem hiding this comment.
@kv2019i fixes is a github construct, it should be used in PR description to help autoclose related bugs if possible. But yes i agree not in the commit message.
| @@ -37,6 +37,14 @@ static inline int snd_sof_remove(struct snd_sof_dev *sdev) | |||
| return 0; | |||
There was a problem hiding this comment.
In commit: "platform specific shutdown stuff" -> "platform specific actions at shutdown"
yes, the shutdown() here only doing possible switching of the ADSP state, from D0I3 to D0, no FW reloading will happen. |
|
I looked into this before the Thanksgiving break and the .shutdown doesn't seem necessary. See device_shutdown(), it does a put_device() at the end that will result in the PCI .remove() callback being called. I don't see a difference between the .shutdown and .remove here, so what does this PR bring? Does this solve anything? |
|
Hi @plbossart @kv2019i @ranj063 @lyakh please help to review the new implementation, basically I switch to call .remove() at .shutdown() for TGL platform, this will lead to longer reboot time (should be several ms level delta, not measure yet). This behaves better during my local reboot stress test, it passes 30 iterations (the previous can't pass 10) and test is continue... Hi @keqiaozhang can you help to test with the latest change at your end also. |
That means we are missing a cancel_work_sync() ? |
Adding cancel_work_sync() can't eliminate the race thoroughly, I had another local change to add a mutex to protect this dsp_power_state access, but that can't make sure the delayed work won't be scheduled after trigger_stop (D0I3->D0), except we do a explicit cancel_work_sync() at PCM trigger stop. So with all this possibilities, adding an extra D0i3->D0 at .shutdown() looks the most light way to me. On the other hand, to make things simpler and more robust, going with another way that just powering off the whole ADSP at .shutdown() (reflected in my latest update above) looks better to me, we can simplify with just power off DSP cores without doing other removal stuffs to speed up the .shutdown() running if needed. Please let me know what do you feel about that. |
I am lost here. If we have a design where we have a risk of race condition because of workqueue, then we need to fix this.
No objection if the race condition is handled. |
Yes, let me submit a fix for that with another PR. |
Here it is: #2600 |
| .probe = hda_dsp_probe, | ||
| .remove = hda_dsp_remove, | ||
|
|
||
| /* shutdown handling */ |
There was a problem hiding this comment.
@keyonjie lets remove the comment. the code is self-explanatory
|
@keyonjie I think the patches are good. Can you please remove the comment in the last patch and then the PR will be good to go. @sathya-nujella is testing it right now and once he reports back the results, we can merge this |
| @@ -102,6 +102,8 @@ struct snd_sof_dsp_ops { | |||
| int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */ | |||
| int (*remove)(struct snd_sof_dev *sof_dev); /* optional */ | |||
|
|
|||
There was a problem hiding this comment.
nit-pick: It seems the empty line is not required.
There was a problem hiding this comment.
nit-pick: It seems the empty line is not required.
Then I should change the comment for "probe and remove" to "probe/remove and shutdown"?
| */ | ||
| int hda_dsp_probe(struct snd_sof_dev *sdev); | ||
| int hda_dsp_remove(struct snd_sof_dev *sdev); | ||
| int hda_dsp_shutdown(struct snd_sof_dev *sdev); |
There was a problem hiding this comment.
Where does hda_dsp_shutdown be used?
There was a problem hiding this comment.
Where does hda_dsp_shutdown be used?
Good catch, this was previous used but now should be removed.
Add .shutdown() callback to the struct snd_sof_dsp_ops, for doing platform specific actions at shutdown. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Add helper snd_sof_device_shutdown() to wrap the platform specific .shutdown callbacks for SOF platforms. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Add the .shutdown() callback to the sof-pci-dev driver, to help to handle shutting down specific tasks for SOF PCI platforms. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Invoke hda_dsp_remove() as the .shutdown() callback, this will help to perform shutdown the DSP safely on TGL platforms before shutting down or rebooting the system. BugLink: thesofproject#2571 Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
|
@bardliao updated now. |
Add .shutdown callback to handle reboot/poweroff related stuff, and pull
DSP back to D0I0 before reboot if it is at D0I3, to fix the boot fail
issue at the consequent rebooting.
Fixes: #2571
Signed-off-by: Keyon Jie yang.jie@linux.intel.com