[Bug 194727] uaudio device gets disconnected, and hangs usb until everything using /dev/mixer* is closed

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 30 Jul 2021 00:57:42 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194727

--- Comment #57 from Theron Tarigo <theron.tarigo@gmail.com> ---
I started hacking on this today, and I see two options for fixing the kernel
side:

1. allow pcm_unregister to forcibly close and destroy the device file.  The
kernel already does something like this for block storage devices removed while
in use.  Applications may respond badly but it's better than what we have now,
and pulseaudio and virtual_oss should already handle this.

2. unhook uaudio instance destruction from device detach.  This allows the pcm
device to persist independently of the usb device, ready to clean up when it
can.

(2) seems the better option, as it provides the opportunity to reattach pcm
device when the USB device is reattached, or after resume from suspend. 
However I'm unsure how to proceed with this option.  Are there any other
drivers capable of persisting independently of their bus devices' detaching to
use as an example?

As for the kernel resource "leak": I'm well aware option (2) leads right into
this.  However unless implemented incorrectly these resources are still tied to
a user process: recovery of the exhausted resource by action taken from within
userspace (killing the offending and leaky application, as we already do for
low memory, too many tabs playing audio, etc.) remains sufficient.

-- 
You are receiving this mail because:
You are on the CC list for the bug.