linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: pei.zhang@intel.com
To: valentina.manea.m@gmail.com, shuah@kernel.org,
	gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pei Zhang <pei.zhang@intel.com>
Subject: [PATCH V2] USBIP: return correct port ENABLE status
Date: Tue, 19 Dec 2017 14:00:59 +0800	[thread overview]
Message-ID: <1513663259-8726-1-git-send-email-pei.zhang@intel.com> (raw)

From: Pei Zhang <pei.zhang@intel.com>

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, Logitech webcam C920.

V2: send again to all related maintainers.

Signed-off-by: Pei Zhang <pei.zhang@intel.com>
---
 drivers/usb/usbip/vhci_hcd.c | 63 ++++++++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 713e941..7970bab 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -430,38 +430,45 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			vhci_hcd->re_timeout = 0;
 		}
 
-		if ((vhci_hcd->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) !=
-		    0 && time_after(jiffies, vhci_hcd->re_timeout)) {
-			vhci_hcd->port_status[rhport] |= (1 << USB_PORT_FEAT_C_RESET);
-			vhci_hcd->port_status[rhport] &= ~(1 << USB_PORT_FEAT_RESET);
-			vhci_hcd->re_timeout = 0;
-
-			if (vhci_hcd->vdev[rhport].ud.status ==
-			    VDEV_ST_NOTASSIGNED) {
-				usbip_dbg_vhci_rh(
-					" enable rhport %d (status %u)\n",
-					rhport,
-					vhci_hcd->vdev[rhport].ud.status);
-				vhci_hcd->port_status[rhport] |=
-					USB_PORT_STAT_ENABLE;
-			}
-
-			if (hcd->speed < HCD_USB3) {
-				switch (vhci_hcd->vdev[rhport].speed) {
-				case USB_SPEED_HIGH:
-					vhci_hcd->port_status[rhport] |=
-					      USB_PORT_STAT_HIGH_SPEED;
-					break;
-				case USB_SPEED_LOW:
+		if ((vhci_hcd->port_status[rhport] & (1 << USB_PORT_FEAT_RESET))) {
+			if (time_after(jiffies, vhci_hcd->re_timeout)) {
+				vhci_hcd->port_status[rhport] |= (1 << USB_PORT_FEAT_C_RESET);
+				vhci_hcd->port_status[rhport] &= ~(1 << USB_PORT_FEAT_RESET);
+				vhci_hcd->re_timeout = 0;
+
+				if (vhci_hcd->vdev[rhport].ud.status ==
+						VDEV_ST_NOTASSIGNED) {
+					usbip_dbg_vhci_rh(
+						" enable rhport %d (status %u)\n",
+						rhport,	vhci_hcd->vdev[rhport].ud.status);
 					vhci_hcd->port_status[rhport] |=
-						USB_PORT_STAT_LOW_SPEED;
-					break;
-				default:
-					pr_err("vhci_device speed not set\n");
-					break;
+						USB_PORT_STAT_ENABLE;
+				}
+
+				if (hcd->speed < HCD_USB3) {
+					switch (vhci_hcd->vdev[rhport].speed) {
+					case USB_SPEED_HIGH:
+						vhci_hcd->port_status[rhport] |=
+							USB_PORT_STAT_HIGH_SPEED;
+						break;
+					case USB_SPEED_LOW:
+						vhci_hcd->port_status[rhport] |=
+							USB_PORT_STAT_LOW_SPEED;
+						break;
+					default:
+						pr_err("vhci_device speed not set\n");
+						break;
+					}
 				}
 			}
+		} else {
+			/* Port would be disabled by clearing FEAT_ENABLE,
+			 * make it enabled again here.
+			 */
+			if (vhci_hcd->vdev[rhport].ud.status == VDEV_ST_USED)
+				vhci_hcd->port_status[rhport] |= USB_PORT_STAT_ENABLE;
 		}
+
 		((__le16 *) buf)[0] = cpu_to_le16(vhci_hcd->port_status[rhport]);
 		((__le16 *) buf)[1] =
 			cpu_to_le16(vhci_hcd->port_status[rhport] >> 16);
-- 
2.7.4

             reply	other threads:[~2017-12-19  5:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19  6:00 pei.zhang [this message]
2018-01-09 17:44 ` [PATCH V2] USBIP: return correct port ENABLE status Shuah Khan
2018-01-10  8:12   ` Zhang, Pei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1513663259-8726-1-git-send-email-pei.zhang@intel.com \
    --to=pei.zhang@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=valentina.manea.m@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).