Skip to contentSkip to conversation

usbip: vhci-hcd: return correct port ENABLE status

PATCH Superseded Pei Zhang 2 participants 3 messages Dec 6, 2017 – Dec 15, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Pei Zhang

author
#0 lore raw

PATCH 1/1 usbip: vhci-hcd: return correct port ENABLE status

USB system will clear port's ENABLE feature for some USB devices when vdev is already assigned port address. This cause getPortStatus reports to system that this device is not enabled, client OS will failed to use this usb device.

The failure devices include a SAMSUNG SSD storage, and a Logitech webcam.

---
 drivers/usb/usbip/vhci_hcd.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
drivers/usb/usbip/vhci_hcd.c +23 -15
index e4cb9f0..7b8cf70 100644
@@ -350,24 +350,32 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			dum->re_timeout = 0;
 		}
 
-		if ((dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) !=
-		    0 && time_after(jiffies, dum->re_timeout)) {
-			dum->port_status[rhport] |=
-				(1 << USB_PORT_FEAT_C_RESET);
-			dum->port_status[rhport] &=
-				~(1 << USB_PORT_FEAT_RESET);
-			dum->re_timeout = 0;
-
-			if (dum->vdev[rhport].ud.status ==
-			    VDEV_ST_NOTASSIGNED) {
-				usbip_dbg_vhci_rh(
-					" enable rhport %d (status %u)\n",
-					rhport,
-					dum->vdev[rhport].ud.status);
+		if (dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) {
+		    if (time_after(jiffies, dum->re_timeout)) {
 				dum->port_status[rhport] |=
-					USB_PORT_STAT_ENABLE;
+					(1 << USB_PORT_FEAT_C_RESET);
+				dum->port_status[rhport] &=
+					~(1 << USB_PORT_FEAT_RESET);
+				dum->re_timeout = 0;
+
+				if (dum->vdev[rhport].ud.status ==
+					VDEV_ST_NOTASSIGNED) {
+					usbip_dbg_vhci_rh(
+						" enable rhport %d (status %u)\n",
+						rhport,
+						dum->vdev[rhport].ud.status);
+					dum->port_status[rhport] |=
+						USB_PORT_STAT_ENABLE;
+				}
 			}
+		} else {
+			/* Port would be disabled by clearing FEAT_ENABLE bit,
+			 * make it enabled here. No more thing should be done. */
+			if (dum->vdev[rhport].ud.status == VDEV_ST_USED)
+					dum->port_status[rhport] |=
+						USB_PORT_STAT_ENABLE;
 		}
+
 		((__le16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
 		((__le16 *) buf)[1] =
 			cpu_to_le16(dum->port_status[rhport] >> 16);
Signature · 1 line
2.7.4
author
#1 lore raw

Add maintainers

********* *****
BRs,
Pei Zhang

Quoted 76 lines

-----Original Message-----
From: Zhang, Pei
Sent: Wednesday, December 6, 2017 11:41 AM
To: [email protected]; [email protected]
Cc: Zhang, Pei <[email protected]>
Subject: [PATCH] usbip: vhci-hcd: return correct port ENABLE status

USB system will clear port's ENABLE feature for some USB devices when vdev is already assigned port address. This cause getPortStatus reports to system that this device is not enabled, client OS will failed to use this usb device.

The failure devices include a SAMSUNG SSD storage, and a Logitech webcam.

---
 drivers/usb/usbip/vhci_hcd.c | 38 +++++++++++++++++++++++--------------
(quoted diff) +0 -1
-
 1 file changed, 23 insertions(+), 15 deletions(-)
drivers/usb/usbip/vhci_hcd.c +23 -15
index e4cb9f0..7b8cf70 100644
@@ -350,24 +350,32 @@ static int vhci_hub_control(struct usb_hcd *hcd,
 u16 typeReq, u16 wValue,
 			dum->re_timeout = 0;
 		}
 
-		if ((dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) !=
-		    0 && time_after(jiffies, dum->re_timeout)) {
-			dum->port_status[rhport] |=
-				(1 << USB_PORT_FEAT_C_RESET);
-			dum->port_status[rhport] &=
-				~(1 << USB_PORT_FEAT_RESET);
-			dum->re_timeout = 0;
-
-			if (dum->vdev[rhport].ud.status ==
-			    VDEV_ST_NOTASSIGNED) {
-				usbip_dbg_vhci_rh(
-					" enable rhport %d (status %u)\n",
-					rhport,
-					dum->vdev[rhport].ud.status);
+		if (dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) {
+		    if (time_after(jiffies, dum->re_timeout)) {
 				dum->port_status[rhport] |=
-					USB_PORT_STAT_ENABLE;
+					(1 << USB_PORT_FEAT_C_RESET);
+				dum->port_status[rhport] &=
+					~(1 << USB_PORT_FEAT_RESET);
+				dum->re_timeout = 0;
+
+				if (dum->vdev[rhport].ud.status ==
+					VDEV_ST_NOTASSIGNED) {
+					usbip_dbg_vhci_rh(
+						" enable rhport %d (status %u)\n",
+						rhport,
+						dum->vdev[rhport].ud.status);
+					dum->port_status[rhport] |=
+						USB_PORT_STAT_ENABLE;
+				}
 			}
+		} else {
+			/* Port would be disabled by clearing FEAT_ENABLE bit,
+			 * make it enabled here. No more thing should be done.
 */
+			if (dum->vdev[rhport].ud.status == VDEV_ST_USED)
+					dum->port_status[rhport] |=
+						USB_PORT_STAT_ENABLE;
 		}
+
 		((__le16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
drivers/usb/usbip/vhci_hcd.c +0 -1
 		((__le16 *) buf)[1] =
 			cpu_to_le16(dum->port_status[rhport] >> 16);
--

2.7.4

#2 lore raw
Quoted 6 lines · Pei

Add maintainers

********* *****
BRs,
Pei Zhang

Please resend the patch to include everybody get_maintainers.pl lists.

thanks,
-- Shuah