Skip to contentSkip to conversation

Patch "USB: Check for dropped connection before switching to full speed" has been added to the 4.12-stable tree

PATCH [email protected] 1 participant 1 message Aug 14, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

USB: Check for dropped connection before switching to full speed

to the 4.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
usb-check-for-dropped-connection-before-switching-to-full-speed.patch
and it can be found in the queue-4.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 94c43b9897abf4ea366ed4dba027494e080c7050 Mon Sep 17 00:00:00 2001

From: Alan Stern <[email protected]>
Date: Tue, 1 Aug 2017 10:41:56 -0400
Subject: USB: Check for dropped connection before switching to full speed

From: Alan Stern <[email protected]>

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.

---
 drivers/usb/core/hub.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/core/hub.c +6 -4
@@ -4730,7 +4730,8 @@ hub_power_remaining(struct usb_hub *hub)
 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
 		u16 portchange)
 {
-	int status, i;
+	int status = -ENODEV;
+	int i;
 	unsigned unit_load;
 	struct usb_device *hdev = hub->hdev;
 	struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
@@ -4934,9 +4935,10 @@ loop:
 
 done:
 	hub_port_disable(hub, port1, 1);
-	if (hcd->driver->relinquish_port && !hub->hdev->parent)
-		hcd->driver->relinquish_port(hcd, port1);
-
+	if (hcd->driver->relinquish_port && !hub->hdev->parent) {
+		if (status != -ENOTCONN && status != -ENODEV)
+			hcd->driver->relinquish_port(hcd, port1);
+	}
 }
 
 /* Handle physical or logical connection change events.

Patches currently in stable-queue which might be from [email protected] are

queue-4.12/usb-check-for-dropped-connection-before-switching-to-full-speed.patch queue-4.12/usb-core-unlink-urbs-from-the-tail-of-the-endpoint-s-urb_list.patch queue-4.12/usb-hcd-mark-secondary-hcd-as-dead-if-the-primary-one-died.patch queue-4.12/usb-storage-fix-deadlock-involving-host-lock-and-scsi_done.patch