freebsd_network: Use a dedicated USB mutex instead of &Giant.

Fixes #17804.
This commit is contained in:
Augustin Cavalier 2022-06-20 13:02:32 -04:00
parent 177a801206
commit 7ac9dc6612

View File

@ -26,6 +26,7 @@ extern "C" {
#include <USB3.h> #include <USB3.h>
struct mtx sUSBLock;
usb_module_info* sUSB = NULL; usb_module_info* sUSB = NULL;
struct taskqueue* sUSBTaskqueue = NULL; struct taskqueue* sUSBTaskqueue = NULL;
@ -40,6 +41,8 @@ init_usb()
dprintf("cannot get module \"%s\"\n", B_USB_MODULE_NAME); dprintf("cannot get module \"%s\"\n", B_USB_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
mtx_init(&sUSBLock, "fbsd usb", NULL, MTX_DEF);
return B_OK; return B_OK;
} }
@ -54,6 +57,7 @@ uninit_usb()
sUSB = NULL; sUSB = NULL;
sUSBTaskqueue = NULL; sUSBTaskqueue = NULL;
mtx_destroy(&sUSBLock);
} }
@ -247,13 +251,13 @@ usbd_transfer_setup(struct freebsd_usb_device* udev,
// Make sure the taskqueue exists. // Make sure the taskqueue exists.
if (sUSBTaskqueue == NULL) { if (sUSBTaskqueue == NULL) {
mtx_lock(&Giant); mtx_lock(&sUSBLock);
if (sUSBTaskqueue == NULL) { if (sUSBTaskqueue == NULL) {
sUSBTaskqueue = taskqueue_create("usb taskq", 0, sUSBTaskqueue = taskqueue_create("usb taskq", 0,
taskqueue_thread_enqueue, &sUSBTaskqueue); taskqueue_thread_enqueue, &sUSBTaskqueue);
taskqueue_start_threads(&sUSBTaskqueue, 1, PZERO, "usb taskq"); taskqueue_start_threads(&sUSBTaskqueue, 1, PZERO, "usb taskq");
} }
mtx_unlock(&Giant); mtx_unlock(&sUSBLock);
} }
const usb_configuration_info* device_config = sUSB->get_configuration( const usb_configuration_info* device_config = sUSB->get_configuration(