ALSA: hda/intel: Power down GPU at error on azx_probe_continue()
PATCH 1/2 ALSA: hda/intel: Power down GPU at error on azx_probe_continue()
Since the recent fix commit fbaccb1b19c7 ("ALSA: hda: intel: Don't free card in the probe work"), we don't release the card but just toggles the init_failed flag to stop the operation in the case of error at probing in azx_probe_continue(). This leaves, however, display_power() true, which may block powering down the GPU.
Put display_power(false) at the error path for avoiding the potential blockage.
--- sound/hda/controllers/intel.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/controllers/intel.c +1 -0
@@ -2453,6 +2453,7 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error)if (err <0 ) {if (hda->vga_switcheroo_registered)dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" ); +display_power (chip, false);if (free_on_error) {pci_set_drvdata (pci,NULL );snd_card_free (chip->card);
Signature · 1 line
2.55.0
PATCH 2/2 ALSA: hda/intel: Clean up error handling in azx_probe_continue()
As all callers of azx_probe_continue() pass false to free_on_error argument after the recent fix fbaccb1b19c7 ("ALSA: hda: intel: Don't free card in the probe work"), just drop the argument and the superfluous condition.
While we're at it, move the error handling around out_free label to the tail of the function, in order to make it clearer as an error path by renaming the goto label to "out_err". Since the error check becomes redundant there (as it's only for errors), drop the err check, too.
Only code cleanup and no functional change is expected.
--- sound/hda/controllers/intel.c | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-)
sound/hda/controllers/intel.c +15 -21
@@ -1184,7 +1184,7 @@ static const struct dev_pm_ops azx_pm = { }; -static int azx_probe_continue (struct azx *chip,bool free_on_error); +static int azx_probe_continue (struct azx *chip);#ifdef SUPPORT_VGA_SWITCHEROO static struct pci_dev *get_bound_vga (struct pci_dev *pci);
@@ -1211,7 +1211,7 @@ static void azx_vs_set_state(struct pci_dev *pci,if (!disabled) {dev_info (chip->card->dev,"Start delayed initialization\n" ); -if (azx_probe_continue (chip, false) <0 ) { +if (azx_probe_continue (chip) <0 ) { hda->init_failed =1 ;dev_err (chip->card->dev,"initialization error\n" ); }
@@ -1738,7 +1738,7 @@ static void azx_probe_work(struct work_struct *work) { struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work); -if (azx_probe_continue (&hda->chip, false) <0 ) { +if (azx_probe_continue (&hda->chip) <0 ) { hda->init_failed =1 ;complete_all (&hda->probe_wait);snd_card_disconnect (hda->chip.card);
@@ -2360,7 +2360,7 @@ static const unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = { [AZX_DRIVER_TERA] = 1, }; -static int azx_probe_continue (struct azx *chip,bool free_on_error) +static int azx_probe_continue (struct azx *chip) { struct hda_intel *hda = container_of(chip, struct hda_intel, chip);struct hdac_bus *bus =azx_bus (chip);
@@ -2385,7 +2385,7 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error) err =azx_first_init (chip);if (err <0 ) - goto out_free; + goto out_err;#ifdef CONFIG_SND_HDA_INPUT_BEEP chip->beep_mode = beep_mode[dev];
@@ -2397,7 +2397,7 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error)if (bus->codec_mask) { err =azx_probe_codecs (chip, azx_max_codecs[chip->driver_type]);if (err <0 ) - goto out_free; + goto out_err; }#ifdef CONFIG_SND_HDA_PATCH_LOADER
@@ -2412,7 +2412,7 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error) } else { err =snd_hda_load_patch (&chip->bus, fw->size, fw->data);if (err <0 ) - goto out_free; + goto out_err; } }#endif
@@ -2428,13 +2428,13 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error)return 0 ;/* keep things up */ }dev_err (chip->card->dev,"Cannot probe codecs, giving up\n" ); - goto out_free; + goto out_err; } } err =snd_card_register (chip->card);if (err <0 ) - goto out_free; + goto out_err;setup_vga_switcheroo_runtime_pm (chip);
@@ -2449,24 +2449,18 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error)pm_runtime_put_autosuspend (&pci->dev); } -out_free: -if (err <0 ) { -if (hda->vga_switcheroo_registered) -dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" ); -display_power (chip, false); -if (free_on_error) { -pci_set_drvdata (pci,NULL ); -snd_card_free (chip->card); - } -return err; - } -if (!hda->need_i915_power)display_power (chip, false);complete_all (&hda->probe_wait);to_hda_bus (bus)->bus_probing =0 ; hda->probe_retry =0 ;return 0 ; + +out_err: +if (hda->vga_switcheroo_registered) +dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" ); +display_power (chip, false); +return err; }static void azx_remove (struct pci_dev *pci)
Signature · 1 line
2.55.0
Quoted 21 lines · Takashi Iwai
Since the recent fix commit
fbaccb1b19c7("ALSA: hda: intel: Don't free card in the probe work"), we don't release the card but just toggles theinit_failedflag to stop the operation in the case of error at probing inazx_probe_continue(). This leaves, however,display_power()true, which may block powering down the GPU.Put
display_power(false)at the error path for avoiding the potential blockage.Fixes fbaccb1b19c7 ("ALSA: hda: intel: Don't free card in the probe work")Signed-off-by Takashi Iwai <[email protected]>--- sound/hda/controllers/intel.c | 1 + 1 file changed, 1 insertion(+)sound/hda/controllers/intel.c +0
-0
sound/hda/controllers/intel.c static int azx_probe_continue(struct azx *chip, bool free_on_error) · line 2459
Quoted 7 lines
sound/hda/controllers/intel.c +1
-0@@ -2453,6 +2453,7 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error)if (err <0 ) {if (hda->vga_switcheroo_registered)dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" ); +display_power (chip, false);if (free_on_error) {pci_set_drvdata (pci,NULL );snd_card_free (chip->card);
On the second thought, turning off the display power here alone would be problematic; the rest hardware cleanup procedure will run anyway in azx_free() and with the display_power() off, it may lead to something unexpected.
We can power up again temporarily in azx_free(), too. But I'm not sure whether it's a good idea. Going back to calling azx_free() can still work, but then we'll hit the old issue again about the already bound codecs (that aren't detached by azx_free() itself).
Hmm. Maybe better to leave in the current state for now until someone sees a real problem on an actual hardware.
Takashi