]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: hda - Don't resume forcibly i915 HDMI/DP codec
authorTakashi Iwai <tiwai@suse.de>
Tue, 16 Jul 2019 06:56:51 +0000 (08:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:12:59 +0000 (09:12 +0200)
commit 4914da2fb0c89205790503f20dfdde854f3afdd8 upstream.

We apply the codec resume forcibly at system resume callback for
updating and syncing the jack detection state that may have changed
during sleeping.  This is, however, superfluous for the codec like
Intel HDMI/DP, where the jack detection is managed via the audio
component notification; i.e. the jack state change shall be reported
sooner or later from the graphics side at mode change.

This patch changes the codec resume callback to avoid the forcible
resume conditionally with a new flag, codec->relaxed_resume, for
reducing the resume time.  The flag is set in the codec probe.

Although this doesn't fix the entire bug mentioned in the bugzilla
entry below, it's still a good optimization and some improvements are
seen.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201901
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/sound/hda_codec.h
sound/pci/hda/hda_codec.c
sound/pci/hda/patch_hdmi.c

index cc7c8d42d4fd9a8a494f6b0cf59d48a8fbf2f902..a0d9d788527dd032f8fe4d095b67df48a43059b9 100644 (file)
@@ -262,6 +262,8 @@ struct hda_codec {
        unsigned int auto_runtime_pm:1; /* enable automatic codec runtime pm */
        unsigned int force_pin_prefix:1; /* Add location prefix */
        unsigned int link_down_at_suspend:1; /* link down at runtime suspend */
+       unsigned int relaxed_resume:1;  /* don't resume forcibly for jack */
+
 #ifdef CONFIG_PM
        unsigned long power_on_acct;
        unsigned long power_off_acct;
index fcdf2cd3783b5c19d1c4ce6c426bc794c6bc0b28..fa1d041da5d2a45531ad184656d07f11912c3ce8 100644 (file)
@@ -2955,15 +2955,19 @@ static int hda_codec_runtime_resume(struct device *dev)
 #ifdef CONFIG_PM_SLEEP
 static int hda_codec_force_resume(struct device *dev)
 {
+       struct hda_codec *codec = dev_to_hda_codec(dev);
+       bool forced_resume = !codec->relaxed_resume;
        int ret;
 
        /* The get/put pair below enforces the runtime resume even if the
         * device hasn't been used at suspend time.  This trick is needed to
         * update the jack state change during the sleep.
         */
-       pm_runtime_get_noresume(dev);
+       if (forced_resume)
+               pm_runtime_get_noresume(dev);
        ret = pm_runtime_force_resume(dev);
-       pm_runtime_put(dev);
+       if (forced_resume)
+               pm_runtime_put(dev);
        return ret;
 }
 
index 0c61c05503f5ee61c551c38b80556582ec7dca6e..dbf0b65f83d875f7381c92a4fee3dc20f8b57727 100644 (file)
@@ -2304,8 +2304,10 @@ static void generic_hdmi_free(struct hda_codec *codec)
        struct hdmi_spec *spec = codec->spec;
        int pin_idx, pcm_idx;
 
-       if (codec_has_acomp(codec))
+       if (codec_has_acomp(codec)) {
                snd_hdac_acomp_register_notifier(&codec->bus->core, NULL);
+               codec->relaxed_resume = 0;
+       }
 
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
                struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
@@ -2578,6 +2580,8 @@ static void register_i915_notifier(struct hda_codec *codec)
        spec->drm_audio_ops.pin_eld_notify = intel_pin_eld_notify;
        snd_hdac_acomp_register_notifier(&codec->bus->core,
                                        &spec->drm_audio_ops);
+       /* no need for forcible resume for jack check thanks to notifier */
+       codec->relaxed_resume = 1;
 }
 
 /* setup_stream ops override for HSW+ */