Skip to content

Commit 4f66a9e

Browse files
committed
ALSA: hda: intel: More comprehensive PM runtime setup for controller driver
Currently we haven't explicitly enable and allow/forbid the runtime PM at the probe and the remove phases of HD-audio controller driver, and this was the reason of a GPF mentioned in the commit e81478b ("ALSA: hda: fix general protection fault in azx_runtime_idle"); namely, even after the resources are released, the runtime PM might be still invoked by the bound graphics driver during the remove of the controller driver. Although we've fixed it by clearing the drvdata reference, it'd be also better to cover the runtime PM issue more properly. This patch adds a few more pm_runtime_*() calls at the probe and the remove time for setting and cleaning up the runtime PM. Particularly, now more explicitly pm_runtime_enable() and _disable() get called as well as pm_runtime_forbid() call at the remove callback, so that a use-after-free should be avoided. Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Tested-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20211110210307.1172004-1-kai.vehmanen@linux.intel.com Link: https://lore.kernel.org/r/20211115075944.6972-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent fa55b7d commit 4f66a9e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

sound/pci/hda/hda_intel.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,14 @@ static void azx_free(struct azx *chip)
13471347
if (hda->freed)
13481348
return;
13491349

1350-
if (azx_has_pm_runtime(chip) && chip->running)
1350+
if (azx_has_pm_runtime(chip) && chip->running) {
13511351
pm_runtime_get_noresume(&pci->dev);
1352+
pm_runtime_disable(&pci->dev);
1353+
pm_runtime_set_suspended(&pci->dev);
1354+
pm_runtime_forbid(&pci->dev);
1355+
pm_runtime_dont_use_autosuspend(&pci->dev);
1356+
}
1357+
13521358
chip->running = 0;
13531359

13541360
azx_del_card_list(chip);
@@ -2322,6 +2328,8 @@ static int azx_probe_continue(struct azx *chip)
23222328
if (azx_has_pm_runtime(chip)) {
23232329
pm_runtime_use_autosuspend(&pci->dev);
23242330
pm_runtime_allow(&pci->dev);
2331+
pm_runtime_set_active(&pci->dev);
2332+
pm_runtime_enable(&pci->dev);
23252333
pm_runtime_put_autosuspend(&pci->dev);
23262334
}
23272335

0 commit comments

Comments
 (0)