[Bug 299272] snd_hda: devctl_notify() called with HDA driver mutex held on jack change

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 10 Oct 2026 09:09:12 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299272

            Bug ID: 299272
           Summary: snd_hda: devctl_notify() called with HDA driver mutex
                    held on jack change
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: david@crap.solutions
                CC: christos@freebsd.org, multimedia@FreeBSD.org

Created attachment 275549
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=275549&action=edit
snd_hda: drop the driver lock around jack devctl notifications

hdaa_presence_handler() sends the SND CONN devctl notification while holding
the HDA driver mutex. With sysevent loaded, devctl_notify() can sleep (M_WAITOK
allocation, genetlink sx lock), so WITNESS complains when headphones are
plugged
in or out:

  uma_zalloc_debug: zone "malloc-16" with the following non-sleepable locks
held:
  exclusive sleep mutex hdac1 (HDA driver mutex) r = 0 locked @
sys/dev/sound/pci/hda/hdac.c:1131
  lock order reversal: (sleepable after non-sleepable)
   1st hdac1 (HDA driver mutex, sleep mutex) @
sys/dev/sound/pci/hda/hdac.c:1131
   2nd genetlink lock (genetlink lock, sx) @ sys/netlink/netlink_generic.c:483
  ...
  devctl_notify+0x5e
  hdaa_presence_handler+0x2a0
  hdaa_unsol_intr+0xcd
  hdac_unsolq_task+0x99

Seen on FreeBSD 16.0-CURRENT (GENERIC with WITNESS), ThinkPad T14 Gen 1,
Realtek ALC257, when plugging headphones into the laptop jack.

Fix: drop the driver lock around devctl_notify(), as hdaa_autorecsrc_handler()
already does around mix_setrecsrc(). Patch attached. Tested on the same
machine:
the notifications are still sent (SND CONN OUT cdev=dsp3 / dsp4) and WITNESS no
longer reports anything on plug/unplug.

-- 
You are receiving this mail because:
You are the assignee for the bug.