[PATCH v2 4/5] ALSA: hda: Stop unsol event and jack polling at hda-ext device removal, too

From: Takashi Iwai

Date: Fri Oct 09 2026 - 09:48:22 EST


In the recent commit f3607b6952ca ("ALSA: hda: Stop unsol events and
jack polling before codec unbind"), we applied the workaround to stop
pending works at the hda codec driver removal, but it was applied
after the bypass for hda-ext ops hdev_detach. Basically the same
issue is seen for hda-ext stuff, so it's safer to apply the workaround
at the beginning of hda_codec_driver_remove().

Along with it, the clearance of unsol_disabled flag is moved to the
beginning of hda_codec_driver_probe(), too; otherwise hda-ext
hdev_attach() might miss the unsol event handling when the code gets
re-bound.

Fixes: f3607b6952ca ("ALSA: hda: Stop unsol events and jack polling before codec unbind")
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
sound/hda/common/bind.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/hda/common/bind.c b/sound/hda/common/bind.c
index d12359970e74..957feace0f58 100644
--- a/sound/hda/common/bind.c
+++ b/sound/hda/common/bind.c
@@ -92,6 +92,9 @@ static int hda_codec_driver_probe(struct device *dev)
bool probed = false;
int err;

+ /* unsol events are still blocked until registered */
+ codec->core.unsol_disabled = false;
+
if (codec->bus->core.ext_ops) {
if (WARN_ON(!codec->bus->core.ext_ops->hdev_attach))
return -EINVAL;
@@ -101,9 +104,6 @@ static int hda_codec_driver_probe(struct device *dev)
if (WARN_ON(!codec->preset))
return -EINVAL;

- /* unsol events are still blocked until registered */
- codec->core.unsol_disabled = false;
-
err = snd_hda_codec_set_name(codec, codec->preset->name);
if (err < 0)
goto error;
@@ -161,16 +161,16 @@ static int hda_codec_driver_remove(struct device *dev)
struct hda_codec *codec = dev_to_hda_codec(dev);
struct hda_codec_driver *driver = hda_codec_to_driver(codec);

+ /* stop asynchronous jack handling before freeing driver resources */
+ snd_hdac_device_disable_unsol(&codec->core);
+ cancel_delayed_work_sync(&codec->jackpoll_work);
+
if (codec->bus->core.ext_ops) {
if (WARN_ON(!codec->bus->core.ext_ops->hdev_detach))
return -EINVAL;
return codec->bus->core.ext_ops->hdev_detach(&codec->core);
}

- /* stop asynchronous jack handling before freeing driver resources */
- snd_hdac_device_disable_unsol(&codec->core);
- cancel_delayed_work_sync(&codec->jackpoll_work);
-
snd_hda_codec_disconnect_pcms(codec);
snd_hda_jack_tbl_disconnect(codec);
snd_refcount_sync(&codec->pcm_ref);
--
2.55.0