From: Petr Mladek Date: Fri, 19 Sep 2014 15:32:24 +0000 (+0200) Subject: usb: hub: allow to process more usb hub events in parallel X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=638139eb95d2;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git 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 Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 12a4c67667b1..374b3f93071c 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2045,7 +2045,8 @@ static void choose_devnum(struct usb_device *udev) int devnum; struct usb_bus *bus = udev->bus; - /* If hub_wq ever becomes multithreaded, this will need a lock */ + /* be safe when more hub events are proceed in parallel */ + mutex_lock(&bus->usb_address0_mutex); if (udev->wusb) { devnum = udev->portnum + 1; BUG_ON(test_bit(devnum, bus->devmap.devicemap)); @@ -2063,6 +2064,7 @@ static void choose_devnum(struct usb_device *udev) set_bit(devnum, bus->devmap.devicemap); udev->devnum = devnum; } + mutex_unlock(&bus->usb_address0_mutex); } static void release_devnum(struct usb_device *udev) @@ -5164,11 +5166,8 @@ int usb_hub_init(void) * USB-PERSIST port handover. Otherwise it might see that a full-speed * device was gone before the EHCI controller had handed its port * over to the companion full-speed controller. - * - * Also we use ordered workqueue because the code is not ready - * for parallel execution of hub events, see choose_devnum(). */ - hub_wq = alloc_ordered_workqueue("usb_hub_wq", WQ_FREEZABLE); + hub_wq = alloc_workqueue("usb_hub_wq", WQ_FREEZABLE, 0); if (hub_wq) return 0;