b78e84d132
simultaneously detaching kernel drivers on the same USB device we can get stuck in the "usb_wait_pending_ref_locked()" function because the conditions needed for allowing detach are not met. The "destroy_dev()" function waits for all system calls involving the given character device to return. Character device system calls may lock the USB enumeration lock, which is also held when "destroy_dev()" is called. This can sometimes lead to a deadlock not noticed by WITNESS. The current solution is to ensure the calling thread is the only one holding the USB enumeration lock and prevent other threads from getting refs while a USB device detach is ongoing. This turned out not to be sufficient. To solve this deadlock we could use "destroy_dev_sched()" to schedule the device destruction in the background, but then we don't know when it is safe to free() the private data of the character device. Instead a callback function is executed by the USB explore process to kill off any leftover USB character devices synchronously after the USB device explore code is finished and the USB enumeration lock is no longer locked. This makes porting easier and also ensures us that character devices must eventually go away after a USB device detach. While at it ensure that "flag_iserror" is only written when "priv_mtx" is locked, which is protecting it. MFC after: 5 days |
||
---|---|---|
.. | ||
controller | ||
gadget | ||
input | ||
misc | ||
net | ||
quirk | ||
serial | ||
storage | ||
template | ||
wlan | ||
ufm_ioctl.h | ||
uftdiio.h | ||
uled_ioctl.h | ||
usb_bus.h | ||
usb_busdma.c | ||
usb_busdma.h | ||
usb_cdc.h | ||
usb_compat_linux.c | ||
usb_compat_linux.h | ||
usb_controller.h | ||
usb_core.c | ||
usb_core.h | ||
usb_debug.c | ||
usb_debug.h | ||
usb_dev.c | ||
usb_dev.h | ||
usb_device.c | ||
usb_device.h | ||
usb_dynamic.c | ||
usb_dynamic.h | ||
usb_endian.h | ||
usb_error.c | ||
usb_freebsd_loader.h | ||
usb_freebsd.h | ||
usb_generic.c | ||
usb_generic.h | ||
usb_handle_request.c | ||
usb_hid.c | ||
usb_hub.c | ||
usb_hub.h | ||
usb_if.m | ||
usb_ioctl.h | ||
usb_lookup.c | ||
usb_mbuf.c | ||
usb_mbuf.h | ||
usb_msctest.c | ||
usb_msctest.h | ||
usb_parse.c | ||
usb_pci.h | ||
usb_pf.c | ||
usb_pf.h | ||
usb_process.c | ||
usb_process.h | ||
usb_request.c | ||
usb_request.h | ||
usb_transfer.c | ||
usb_transfer.h | ||
usb_util.c | ||
usb_util.h | ||
usb.h | ||
usbdevs | ||
usbdi_util.h | ||
usbdi.h | ||
usbhid.h |