[Sound-open-firmware] [SOF][KERNEL] pm_runtime flow in sof
Pierre-Louis Bossart
pierre-louis.bossart at linux.intel.com
Wed Oct 20 18:44:07 CEST 2021
> In sof-of-dev.c
> static void sof_of_probe_complete(struct device *dev)
> {
> /* allow runtime_pm */
> pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS);
> pm_runtime_use_autosuspend(dev);
> pm_runtime_set_active(dev);
> pm_runtime_enable(dev);
>
> pm_runtime_mark_last_busy(dev);
> pm_runtime_put_autosuspend(dev);
this last line looks wrong
it looks like the code in sof-of-dev.c is imbalanced. The last
pm_runtime_put_autosuspend() is not matching any pm_runtime_get_sync(),
is it?
> }
>
>
> After pm_runtime_put_autosuspend, the current device power usage count should minus one. (1->0)
>
> And wait SND_SOF_SUSPEND_DELAY_MS seconds, sof device will autosuspend (because the power usage count is 0 ).
Indeed.
We have this comment for the PCI case:
/* follow recommendation in pci-driver.c to decrement usage counter */
pm_runtime_put_noidle(dev);
and a matching one for remove:
/* follow recommendation in pci-driver.c to increment usage counter */
if (snd_sof_device_probe_completed(&pci->dev) &&
!(sof_pci_debug & SOF_PCI_DISABLE_PM_RUNTIME))
pm_runtime_get_noresume(&pci->dev);
In the general case, I don't know why you would need to add a
put_autosuspend in the probe complete, even for cases where the device
does support pm_runtime.
Having a mark_last_busy() is fine though, it would reset the counters
and let the autosuspend happen at a later time. But I would call this
before enable for consistency.
Can you try with the sequence below in probe_complete?
pm_runtime_set_autosuspend_delay(dev, DELAY_MS);
pm_runtime_use_autosuspend(dev);
pm_runtime_mark_last_busy(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
More information about the Sound-open-firmware
mailing list