diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 49b1c40ed038a7..6a30cc68507ec1 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -713,9 +713,8 @@ static int sof_pcm_probe(struct snd_soc_component *component) } /* enable runtime PM with auto suspend */ - pm_runtime_set_autosuspend_delay(component->dev, - SND_SOF_SUSPEND_DELAY); - pm_runtime_use_autosuspend(component->dev); + snd_sof_pm_runtime_enable(sdev); + pm_runtime_enable(component->dev); pm_runtime_mark_last_busy(component->dev); diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index 80be44929c3b4b..19a05c708886ea 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -411,3 +411,21 @@ int snd_sof_prepare(struct device *dev) return 0; } EXPORT_SYMBOL(snd_sof_prepare); + +void snd_sof_pm_runtime_enable(struct snd_sof_dev *sdev) +{ + /* allow runtime_pm */ + pm_runtime_set_autosuspend_delay(sdev->dev, SND_SOF_SUSPEND_DELAY); + pm_runtime_use_autosuspend(sdev->dev); + + /* + * runtime pm for pci device is "forbidden" by default. + * so call pm_runtime_allow() to enable it. + */ + pm_runtime_allow(sdev->dev); + + /* follow recommendation in pci-driver.c to decrement usage counter */ + if (sdev->pci) + pm_runtime_put_noidle(sdev->dev); +} +EXPORT_SYMBOL(snd_sof_pm_runtime_enable); diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 71327b875e3da3..f2e851c035ee50 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -218,11 +218,6 @@ static int sof_acpi_probe(struct platform_device *pdev) return ret; } - /* allow runtime_pm */ - pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY); - pm_runtime_use_autosuspend(dev); - pm_runtime_allow(dev); - return ret; } diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index f60b8bae5b6dd3..b605ec78a17675 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -253,19 +253,6 @@ static int sof_pci_probe(struct pci_dev *pci, goto release_regions; } - /* allow runtime_pm */ - pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY); - pm_runtime_use_autosuspend(dev); - - /* - * runtime pm for pci device is "forbidden" by default. - * so call pm_runtime_allow() to enable it. - */ - pm_runtime_allow(dev); - - /* follow recommendation in pci-driver.c to decrement usage counter */ - pm_runtime_put_noidle(dev); - return ret; release_regions: diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 61069d77c5151a..d14a404ce8b884 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -414,6 +414,7 @@ int snd_sof_resume(struct device *dev); int snd_sof_suspend(struct device *dev); int snd_sof_prepare(struct device *dev); int snd_sof_suspend_late(struct device *dev); +void snd_sof_pm_runtime_enable(struct snd_sof_dev *sdev); void snd_sof_new_platform_drv(struct snd_sof_dev *sdev); diff --git a/sound/soc/sof/sof-spi-dev.c b/sound/soc/sof/sof-spi-dev.c index 5f98820eeeafb1..3f56cb55952657 100644 --- a/sound/soc/sof/sof-spi-dev.c +++ b/sound/soc/sof/sof-spi-dev.c @@ -146,11 +146,6 @@ static int sof_spi_probe(struct spi_device *spi) spi->irq = irq; - /* allow runtime_pm */ - pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY); - pm_runtime_use_autosuspend(dev); - pm_runtime_allow(dev); - return ret; }