[PATCH] ALSA: hda: fix general protection fault in azx_runtime_idle

Kai Vehmanen kai.vehmanen at linux.intel.com
Thu Nov 11 18:39:36 CET 2021


Hi,

On Thu, 11 Nov 2021, Takashi Iwai wrote:

> A potential problem with the current code is that it doesn't disable
> the runtime PM at the release procedure.  Could you try the patch
> below?  You can put WARN_ON(!chip) at azx_runtime_idle(), too, for
> catching the invalid runtime call.
[...]
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -1347,8 +1347,13 @@ static void azx_free(struct azx *chip)
>  	if (hda->freed)
>  		return;
>  
> -	if (azx_has_pm_runtime(chip) && chip->running)
> +	if (azx_has_pm_runtime(chip) && chip->running) {
>  		pm_runtime_get_noresume(&pci->dev);
> +		pm_runtime_forbid(&pci->dev);
> +		pm_runtime_dont_use_autosuspend(&pci->dev);
> +		pm_runtime_disable(&pci->dev);
> +	}
> +
>  	chip->running = 0;

Tested with next-20211019 (first next tag where I've seen test failures) 
and your patch, and this seems to do the trick. I didn't have my drvdata 
patch included when I ran the test. No rpm_idle() calls 
anymore after azx_remove(), so the bug is not hit.

>  	azx_del_card_list(chip);
> @@ -2320,6 +2325,7 @@ static int azx_probe_continue(struct azx *chip)
>  	set_default_power_save(chip);
>  
>  	if (azx_has_pm_runtime(chip)) {
> +		pm_runtime_enable(&pci->dev);
>  		pm_runtime_use_autosuspend(&pci->dev);

This does generate warnings
[   13.495059] snd_hda_intel 0000:00:1f.3: Unbalanced pm_runtime_enable!

And later
[   54.770701] Enabling runtime PM for inactive device (0000:00:1f.3) with active children
[   54.770718] WARNING: CPU: 0 PID: 10 at drivers/base/power/runtime.c:1439 pm_runtime_enable+0x98/0xb0

Adding a "pm_runtime_set_active(&pci->dev)" to both azx_free() and 
azx_probe_continue() seems to help and fix still works.

Br, Kai


More information about the Alsa-devel mailing list