Skip to content

Commit 638139e

Browse files
pmladekgregkh
authored andcommitted
usb: hub: allow to process more usb hub events in parallel
It seems that only choose_devnum() was not ready to process more hub events at the same time. All should be fine if we take bus->usb_address0_mutex there. It will make sure that more devnums will not be chosen for the given bus and the related devices at the same time. Signed-off-by: Petr Mladek <[email protected]> Acked-by: Alan Stern <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 37ebb54 commit 638139e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/usb/core/hub.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,8 @@ static void choose_devnum(struct usb_device *udev)
20452045
int devnum;
20462046
struct usb_bus *bus = udev->bus;
20472047

2048-
/* If hub_wq ever becomes multithreaded, this will need a lock */
2048+
/* be safe when more hub events are proceed in parallel */
2049+
mutex_lock(&bus->usb_address0_mutex);
20492050
if (udev->wusb) {
20502051
devnum = udev->portnum + 1;
20512052
BUG_ON(test_bit(devnum, bus->devmap.devicemap));
@@ -2063,6 +2064,7 @@ static void choose_devnum(struct usb_device *udev)
20632064
set_bit(devnum, bus->devmap.devicemap);
20642065
udev->devnum = devnum;
20652066
}
2067+
mutex_unlock(&bus->usb_address0_mutex);
20662068
}
20672069

20682070
static void release_devnum(struct usb_device *udev)
@@ -5164,11 +5166,8 @@ int usb_hub_init(void)
51645166
* USB-PERSIST port handover. Otherwise it might see that a full-speed
51655167
* device was gone before the EHCI controller had handed its port
51665168
* over to the companion full-speed controller.
5167-
*
5168-
* Also we use ordered workqueue because the code is not ready
5169-
* for parallel execution of hub events, see choose_devnum().
51705169
*/
5171-
hub_wq = alloc_ordered_workqueue("usb_hub_wq", WQ_FREEZABLE);
5170+
hub_wq = alloc_workqueue("usb_hub_wq", WQ_FREEZABLE, 0);
51725171
if (hub_wq)
51735172
return 0;
51745173

0 commit comments

Comments
 (0)