Skip to content

Commit 6fa085f

Browse files
committed
ASoC: SOF: fix runtime pm usage mismatch after probe errors
With current delayed probe implementation, sof_probe_complete is not called in case of errors. And as this function is responsible for decrementing runtime pm usage counter, this will result in following problem: - probe driver in conditions where probe will fail (to force the condition on Intel SOF systems, set "snd_sof_intel_hda_common.codec_mask=0") - unload driver (runtime-pm usage_count is leaked) - fix the issue by installing missing fw, modifying module parameters, etc actions - try to load driver again -> success, probe ok -> device never enters runtime suspend Fix the issue by storing result of delayed probe to a state variable and providing new snd_sof_device_probe_completed() to be queried from SOF PCI/ACPI/OF drivers. If probe never completed successfully, runtime PM was not set up and thus at remove(), we should not increment usage count anymore. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 7e08619 commit 6fa085f

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

sound/soc/sof/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
246246
if (plat_data->sof_probe_complete)
247247
plat_data->sof_probe_complete(sdev->dev);
248248

249+
sdev->probe_completed = true;
250+
249251
return 0;
250252

251253
fw_trace_err:
@@ -340,6 +342,14 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
340342
}
341343
EXPORT_SYMBOL(snd_sof_device_probe);
342344

345+
bool snd_sof_device_probe_completed(struct device *dev)
346+
{
347+
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
348+
349+
return sdev->probe_completed;
350+
}
351+
EXPORT_SYMBOL(snd_sof_device_probe_completed);
352+
343353
int snd_sof_device_remove(struct device *dev)
344354
{
345355
struct snd_sof_dev *sdev = dev_get_drvdata(dev);

sound/soc/sof/sof-pci-dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ static void sof_pci_remove(struct pci_dev *pci)
445445
snd_sof_device_remove(&pci->dev);
446446

447447
/* follow recommendation in pci-driver.c to increment usage counter */
448-
if (!(sof_pci_debug & SOF_PCI_DISABLE_PM_RUNTIME))
448+
if (snd_sof_device_probe_completed(&pci->dev) &&
449+
!(sof_pci_debug & SOF_PCI_DISABLE_PM_RUNTIME))
449450
pm_runtime_get_noresume(&pci->dev);
450451

451452
/* release pci regions and disable device */

sound/soc/sof/sof-priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ struct snd_sof_dev {
389389

390390
/* work queue in case the probe is implemented in two steps */
391391
struct work_struct probe_work;
392+
bool probe_completed;
392393

393394
/* DSP HW differentiation */
394395
struct snd_sof_pdata *pdata;
@@ -464,6 +465,7 @@ struct snd_sof_dev {
464465
int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data);
465466
int snd_sof_device_remove(struct device *dev);
466467
int snd_sof_device_shutdown(struct device *dev);
468+
bool snd_sof_device_probe_completed(struct device *dev);
467469

468470
int snd_sof_runtime_suspend(struct device *dev);
469471
int snd_sof_runtime_resume(struct device *dev);

0 commit comments

Comments
 (0)