Skip to content

Commit bc2f02f

Browse files
AlanSterngregkh
authored andcommitted
USB: Check for dropped connection before switching to full speed
commit 94c43b9897abf4ea366ed4dba027494e080c7050 upstream. Some buggy USB disk adapters disconnect and reconnect multiple times during the enumeration procedure. This may lead to a device connecting at full speed instead of high speed, because when the USB stack sees that a device isn't able to enumerate at high speed, it tries to hand the connection over to a full-speed companion controller. The logic for doing this is careful to check that the device is still connected. But this check is inadequate if the device disconnects and reconnects before the check is done. The symptom is that a device works, but much more slowly than it is capable of operating. The situation was made worse recently by commit 22547c4cc4fe ("usb: hub: Wait for connection to be reestablished after port reset"), which increases the delay following a reset before a disconnect is recognized, thus giving the device more time to reconnect. This patch makes the check more robust. If the device was disconnected at any time during enumeration, we will now skip the full-speed handover. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-and-tested-by: Zdenek Kabelac <zkabelac@redhat.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ed4f50e commit bc2f02f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/usb/core/hub.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4661,7 +4661,8 @@ hub_power_remaining(struct usb_hub *hub)
46614661
static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
46624662
u16 portchange)
46634663
{
4664-
int status, i;
4664+
int status = -ENODEV;
4665+
int i;
46654666
unsigned unit_load;
46664667
struct usb_device *hdev = hub->hdev;
46674668
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
@@ -4865,9 +4866,10 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
48654866

48664867
done:
48674868
hub_port_disable(hub, port1, 1);
4868-
if (hcd->driver->relinquish_port && !hub->hdev->parent)
4869-
hcd->driver->relinquish_port(hcd, port1);
4870-
4869+
if (hcd->driver->relinquish_port && !hub->hdev->parent) {
4870+
if (status != -ENOTCONN && status != -ENODEV)
4871+
hcd->driver->relinquish_port(hcd, port1);
4872+
}
48714873
}
48724874

48734875
/* Handle physical or logical connection change events.

0 commit comments

Comments
 (0)