Skip to content

Commit 3099406

Browse files
ideaktiwai
authored andcommitted
ALSA: hda: Release codec display power during shutdown/reboot
Similarly to the previous patch for the HDA controller make sure here that codecs also drop the display power reference during shutdown and reboot. This fixes a power ref leaked WARN in i915 during shutdown if the HDA driver is built with CONFIG_PM=n. Suggested-by: Takashi Iwai <tiwai@suse.de> References: https://gitlab.freedesktop.org/drm/intel/-/issues/3618 References: https://lore.kernel.org/intel-gfx/s5hzgvhngw6.wl-tiwai@suse.de Signed-off-by: Imre Deak <imre.deak@intel.com> Link: https://lore.kernel.org/r/20210623134601.2128663-2-imre.deak@intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 472e18f commit 3099406

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

sound/pci/hda/hda_bind.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ static void hda_codec_driver_shutdown(struct device *dev)
167167
{
168168
struct hda_codec *codec = dev_to_hda_codec(dev);
169169

170-
if (!pm_runtime_suspended(dev) && codec->patch_ops.reboot_notify)
171-
codec->patch_ops.reboot_notify(codec);
170+
if (!pm_runtime_suspended(dev)) {
171+
if (codec->patch_ops.reboot_notify)
172+
codec->patch_ops.reboot_notify(codec);
173+
snd_hda_codec_display_power(codec, false);
174+
}
172175
}
173176

174177
int __hda_codec_driver_register(struct hda_codec_driver *drv, const char *name,

sound/pci/hda/hda_codec.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
798798
unsigned int power_state);
799799

800800
/* enable/disable display power per codec */
801-
static void codec_display_power(struct hda_codec *codec, bool enable)
801+
void snd_hda_codec_display_power(struct hda_codec *codec, bool enable)
802802
{
803803
if (codec->display_power_control)
804804
snd_hdac_display_power(&codec->bus->core, codec->addr, enable);
@@ -810,7 +810,7 @@ void snd_hda_codec_register(struct hda_codec *codec)
810810
if (codec->registered)
811811
return;
812812
if (device_is_registered(hda_codec_dev(codec))) {
813-
codec_display_power(codec, true);
813+
snd_hda_codec_display_power(codec, true);
814814
pm_runtime_enable(hda_codec_dev(codec));
815815
/* it was powered up in snd_hda_codec_new(), now all done */
816816
snd_hda_power_down(codec);
@@ -836,7 +836,7 @@ static int snd_hda_codec_dev_free(struct snd_device *device)
836836
*/
837837
if (codec->core.type == HDA_DEV_LEGACY)
838838
snd_hdac_device_unregister(&codec->core);
839-
codec_display_power(codec, false);
839+
snd_hda_codec_display_power(codec, false);
840840

841841
/*
842842
* In the case of ASoC HD-audio bus, the device refcount is released in
@@ -2893,7 +2893,7 @@ static int hda_codec_runtime_suspend(struct device *dev)
28932893
(codec_has_clkstop(codec) && codec_has_epss(codec) &&
28942894
(state & AC_PWRST_CLK_STOP_OK)))
28952895
snd_hdac_codec_link_down(&codec->core);
2896-
codec_display_power(codec, false);
2896+
snd_hda_codec_display_power(codec, false);
28972897
return 0;
28982898
}
28992899

@@ -2905,7 +2905,7 @@ static int hda_codec_runtime_resume(struct device *dev)
29052905
if (!codec->card)
29062906
return 0;
29072907

2908-
codec_display_power(codec, true);
2908+
snd_hda_codec_display_power(codec, true);
29092909
snd_hdac_codec_link_up(&codec->core);
29102910
hda_call_codec_resume(codec);
29112911
pm_runtime_mark_last_busy(dev);

sound/pci/hda/hda_local.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld,
709709
#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
710710
void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
711711

712+
void snd_hda_codec_display_power(struct hda_codec *codec, bool enable);
713+
712714
/*
713715
*/
714716
#define codec_err(codec, fmt, args...) \

0 commit comments

Comments
 (0)