]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ALSA: hda: Do disconnect jacks at codec unbind
authorTakashi Iwai <tiwai@suse.de>
Wed, 17 Nov 2021 13:30:40 +0000 (14:30 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 14 Nov 2022 10:25:20 +0000 (11:25 +0100)
BugLink: https://bugs.launchpad.net/bugs/1995517
[ Upstream commit 37c4fd0db7c961145d9d1909ecab386fdf703c26 ]

The HD-audio codec driver remove may happen also at dynamically
unbinding during operation, hence it needs manual triggers of
snd_device_disconnect() calls, while it's missing for the jack objects
that are associated with the codec.

This patch adds the manual disconnection call for jacks when the
remove happens without card->shutdown (i.e. not under the full
removal).

Link: https://lore.kernel.org/r/20211117133040.20272-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Stable-dep-of: ead3d3c5b54f ("ALSA: hda: Fix hang at HD-audio codec unbinding due to refcount saturation")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
sound/pci/hda/hda_bind.c
sound/pci/hda/hda_jack.c
sound/pci/hda/hda_jack.h

index 7153bd53e189345df4a8c8b4bcf554c3a184a608..c572fb5886d5d63f56ead62ab2d5e5e192d75245 100644 (file)
@@ -14,6 +14,7 @@
 #include <sound/core.h>
 #include <sound/hda_codec.h>
 #include "hda_local.h"
+#include "hda_jack.h"
 
 /*
  * find a matching codec id
@@ -158,6 +159,7 @@ static int hda_codec_driver_remove(struct device *dev)
 
        refcount_dec(&codec->pcm_ref);
        snd_hda_codec_disconnect_pcms(codec);
+       snd_hda_jack_tbl_disconnect(codec);
        wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref));
        snd_power_sync_ref(codec->bus->card);
 
index f29975e3e98df21894cbacf34c7743c7690c5eab..7d7786df60ea7ad3ba7d996a9505bd722e915a9f 100644 (file)
@@ -158,6 +158,17 @@ snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid, int dev_id)
        return jack;
 }
 
+void snd_hda_jack_tbl_disconnect(struct hda_codec *codec)
+{
+       struct hda_jack_tbl *jack = codec->jacktbl.list;
+       int i;
+
+       for (i = 0; i < codec->jacktbl.used; i++, jack++) {
+               if (!codec->bus->shutdown && jack->jack)
+                       snd_device_disconnect(codec->card, jack->jack);
+       }
+}
+
 void snd_hda_jack_tbl_clear(struct hda_codec *codec)
 {
        struct hda_jack_tbl *jack = codec->jacktbl.list;
index 2abf7aac243a24708989315fd48f2e6b9700e521..ff7d289c034bfe8d33523ddf22f0cc2873036c48 100644 (file)
@@ -69,6 +69,7 @@ struct hda_jack_tbl *
 snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec,
                              unsigned char tag, int dev_id);
 
+void snd_hda_jack_tbl_disconnect(struct hda_codec *codec);
 void snd_hda_jack_tbl_clear(struct hda_codec *codec);
 
 void snd_hda_jack_set_dirty_all(struct hda_codec *codec);