Attempt to fix deadlocking USB transfers

Whenever a device is removed, let usb_raw cancel all its pending
transfers. Does not seems to help with the issue I'm getting however.

Change-Id: Ie2856e68ea402c9f1cc352ac47bbca624e17d3dc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1424
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Fredrik Modéen <fredrik@modeen.se>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Adrien Destugues 2019-06-28 18:09:12 +02:00 committed by Adrien Destugues
parent a77684c96a
commit 61013090a0

View File

@ -95,6 +95,17 @@ usb_raw_device_removed(void *cookie)
TRACE((DRIVER_NAME": device_removed(0x%p)\n", cookie));
raw_device *device = (raw_device *)cookie;
// cancel all pending transfers to make sure no one keeps waiting forever
// in syscalls.
const usb_configuration_info *configurationInfo =
gUSBModule->get_configuration(device->device);
if (configurationInfo != NULL) {
struct usb_interface_info* interface
= configurationInfo->interface->active;
for (unsigned int i = 0; i < interface->endpoint_count; i++)
gUSBModule->cancel_queued_transfers(interface->endpoint[i].handle);
}
mutex_lock(&gDeviceListLock);
if (gDeviceList == device) {
gDeviceList = (raw_device *)device->link;