linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] USBIP: return correct port ENABLE status
@ 2017-12-19  6:00 pei.zhang
  2018-01-09 17:44 ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: pei.zhang @ 2017-12-19  6:00 UTC (permalink / raw)
  To: valentina.manea.m, shuah, gregkh; +Cc: linux-usb, linux-kernel, Pei Zhang

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] USBIP: return correct port ENABLE status
  2017-12-19  6:00 [PATCH V2] USBIP: return correct port ENABLE status pei.zhang
@ 2018-01-09 17:44 ` Shuah Khan
  2018-01-10  8:12   ` Zhang, Pei
  0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2018-01-09 17:44 UTC (permalink / raw)
  To: pei.zhang, valentina.manea.m, gregkh
  Cc: linux-usb, linux-kernel, Shuah Khan, Shuah Khan

On 12/18/2017 11:00 PM, pei.zhang@intel.com wrote:
> 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>

Hi Pei Zhang,

Can you elaborate on how you can trigger this condition? Can you send me
more information on how to recreate the problem and demsg from server and
client side when this problem happens.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH V2] USBIP: return correct port ENABLE status
  2018-01-09 17:44 ` Shuah Khan
@ 2018-01-10  8:12   ` Zhang, Pei
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Pei @ 2018-01-10  8:12 UTC (permalink / raw)
  To: shuah, valentina.manea.m, gregkh; +Cc: linux-usb, linux-kernel, Shuah Khan

Hi Shuah,

Thanks for your response. It's on KVM hypervisor platform, while the Dom0 is the usbip server, and a DomU act as the client. This issue could be 100% reproduced with the specified devices referred in my patch comment.

I will prepare the environment and then send you related information later. 

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

> -----Original Message-----
> From: Shuah Khan [mailto:shuah@kernel.org]
> Sent: Wednesday, January 10, 2018 1:44 AM
> To: Zhang, Pei <pei.zhang@intel.com>; valentina.manea.m@gmail.com;
> gregkh@linuxfoundation.org
> Cc: linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; Shuah Khan
> <shuahkh@osg.samsung.com>; Shuah Khan <shuah@kernel.org>
> Subject: Re: [PATCH V2] USBIP: return correct port ENABLE status
> 
> On 12/18/2017 11:00 PM, pei.zhang@intel.com wrote:
> > 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>
> 
> Hi Pei Zhang,
> 
> Can you elaborate on how you can trigger this condition? Can you send me
> more information on how to recreate the problem and demsg from server
> and client side when this problem happens.
> 
> thanks,
> -- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-10  8:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19  6:00 [PATCH V2] USBIP: return correct port ENABLE status pei.zhang
2018-01-09 17:44 ` Shuah Khan
2018-01-10  8:12   ` Zhang, Pei

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).