]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: hda: Disable codec runtime PM when jack polling is enabled
authorTakashi Iwai <tiwai@suse.de>
Mon, 23 Jun 2025 13:14:31 +0000 (15:14 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 23 Jun 2025 15:21:16 +0000 (17:21 +0200)
When the jack polling is triggered quite frequently, it makes little
sense to perform the runtime PM at each time; since we do almost full
configuration at each runtime resume for HD-audio, the merit by power
saving would be lost.  Hence, it'd be more reasonable to disable the
runtime PM when the jack polling is enabled.

This patch introduces the runtime PM idle callback and disables the
runtime PM when the jack polling is enabled.  This also serves as the
preliminary change for the further jack poll cleanup.

The exception is the case where codec->bus->jackpoll_in_suspend flag
is set by the driver (currently set by HD-audio Tegra driver).  This
flag indicates that the polling is infrequent, hence there is still
benefit to perform the runtime PM.  The idle callback checks this flag
and allows the runtime PM when set.

Link: https://lore.kernel.org/20250619020844.2974160-1-joakim.zhang@cixtech.com
Tested-by: Joakim Zhang <joakim.zhang@cixtech.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250623131437.10670-3-tiwai@suse.de
sound/pci/hda/hda_codec.c

index 4eba3970cd1a759b9d0e6d907ae1541f3aca8f24..ea361390b82936a09e373cb96f7e98a89446d3a1 100644 (file)
@@ -2943,6 +2943,15 @@ static int hda_codec_runtime_resume(struct device *dev)
        return 0;
 }
 
+static int hda_codec_runtime_idle(struct device *dev)
+{
+       struct hda_codec *codec = dev_to_hda_codec(dev);
+
+       if (codec->jackpoll_interval && !codec->bus->jackpoll_in_suspend)
+               return -EBUSY;
+       return 0;
+}
+
 static int hda_codec_pm_prepare(struct device *dev)
 {
        struct hda_codec *codec = dev_to_hda_codec(dev);
@@ -3008,7 +3017,8 @@ const struct dev_pm_ops hda_codec_driver_pm = {
        .thaw = pm_sleep_ptr(hda_codec_pm_thaw),
        .poweroff = pm_sleep_ptr(hda_codec_pm_suspend),
        .restore = pm_sleep_ptr(hda_codec_pm_restore),
-       RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume, NULL)
+       RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume,
+                      hda_codec_runtime_idle)
 };
 
 /* suspend the codec at shutdown; called from driver's shutdown callback */