All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] usb: xhci: Don't drive port 2.0 reset while resuming
@ 2016-10-25 10:45 Sriram Dash
  2016-10-25 12:58 ` Mathias Nyman
  0 siblings, 1 reply; 4+ messages in thread
From: Sriram Dash @ 2016-10-25 10:45 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: mathias.nyman, gregkh, suresh.gupta, felipe.balbi, stern,
	Sriram Dash, Rajat Srivastava, Rajesh Bhagat

For the USB3.0 controller, USB 2.0 reset not driven while
port is in Resume state. So, do not program the USB 2.0 reset
(PORTSC[PR]=1) while in Resume state.

Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
Signed-off-by: Sriram Dash <sriram.dash@nxp.com>
Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
---
Changes in v2:
  - Remove the quirk and make it generic to xhci.
  - Edit the title and comment


 drivers/usb/host/xhci-hub.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 730b9fd..a27dbb4 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -878,7 +878,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	int max_ports;
 	unsigned long flags;
-	u32 temp, status;
+	u32 temp, status, tmp_status = 0;
 	int retval = 0;
 	__le32 __iomem **port_array;
 	int slot_id;
@@ -1098,6 +1098,21 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			spin_lock_irqsave(&xhci->lock, flags);
 			break;
 		case USB_PORT_FEAT_RESET:
+			/*
+			 * Do not drive a reset signal when the port
+			 * is resuming
+			 */
+			tmp_status = readl(port_array[wIndex]);
+			spin_unlock_irqrestore(&xhci->lock, flags);
+			if (!DEV_SUPERSPEED(tmp_status)	&&
+			    (tmp_status & PORT_PLS_MASK) == XDEV_RESUME) {
+				xhci_err(xhci, "skip port reset\n");
+				spin_lock_irqsave(&xhci->lock, flags);
+				retval = -EPERM;
+				break;
+			}
+			spin_lock_irqsave(&xhci->lock, flags);
+
 			temp = (temp | PORT_RESET);
 			writel(temp, port_array[wIndex]);
 
-- 
2.1.0

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

* Re: [PATCH v2] usb: xhci: Don't drive port 2.0 reset while resuming
  2016-10-25 10:45 [PATCH v2] usb: xhci: Don't drive port 2.0 reset while resuming Sriram Dash
@ 2016-10-25 12:58 ` Mathias Nyman
  2016-10-26 12:34   ` Sriram Dash
  0 siblings, 1 reply; 4+ messages in thread
From: Mathias Nyman @ 2016-10-25 12:58 UTC (permalink / raw)
  To: Sriram Dash, linux-kernel, linux-usb
  Cc: mathias.nyman, gregkh, suresh.gupta, felipe.balbi, stern,
	Rajat Srivastava, Rajesh Bhagat

On 25.10.2016 13:45, Sriram Dash wrote:
> For the USB3.0 controller, USB 2.0 reset not driven while
> port is in Resume state. So, do not program the USB 2.0 reset
> (PORTSC[PR]=1) while in Resume state.
>
> Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
> Signed-off-by: Sriram Dash <sriram.dash@nxp.com>
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
> ---

What is the actual issue that you are fixing here?
Is there some device that is in resume (PLS==XDEV_RESUME) while driving reset?

I just sent a pach for increasing the resume time signaling to 40ms when clearing the
PORT_FEAT_SUSPEND.
Does that work for you?

If not, then we should look closer at why clearing the suspend does not work properly.
One issue could be that ClearPortFeature PORT_FEAT_SUSPEND does not really read or wait for
for changes in port status. It blindly sets the states based on time passed.

Or if it's after system suspend there might be something in bus_resume that is not working.

I don't think usb core tries to drive reset while port is still resuming

-Mathias   

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

* RE: [PATCH v2] usb: xhci: Don't drive port 2.0 reset while resuming
  2016-10-25 12:58 ` Mathias Nyman
@ 2016-10-26 12:34   ` Sriram Dash
  2016-10-26 14:39     ` Alan Stern
  0 siblings, 1 reply; 4+ messages in thread
From: Sriram Dash @ 2016-10-26 12:34 UTC (permalink / raw)
  To: Mathias Nyman, linux-kernel, linux-usb
  Cc: mathias.nyman, gregkh, Suresh Gupta, felipe.balbi, stern,
	Rajat Srivastava, Rajesh Bhagat

>From: Mathias Nyman [mailto:mathias.nyman@linux.intel.com]
>On 25.10.2016 13:45, Sriram Dash wrote:
>> For the USB3.0 controller, USB 2.0 reset not driven while port is in
>> Resume state. So, do not program the USB 2.0 reset
>> (PORTSC[PR]=1) while in Resume state.
>>
>> Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
>> Signed-off-by: Sriram Dash <sriram.dash@nxp.com>
>> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
>> ---
>
>What is the actual issue that you are fixing here?

This was an erratum from Synopsis STAR: 9000962562

>Is there some device that is in resume (PLS==XDEV_RESUME) while driving reset?
>

We have not reproduced this as such.

>I just sent a pach for increasing the resume time signaling to 40ms when clearing
>the PORT_FEAT_SUSPEND.
>Does that work for you?
>
>If not, then we should look closer at why clearing the suspend does not work
>properly.
>One issue could be that ClearPortFeature PORT_FEAT_SUSPEND does not really
>read or wait for for changes in port status. It blindly sets the states based on time
>passed.
>
>Or if it's after system suspend there might be something in bus_resume that is not
>working.
>
>I don't think usb core tries to drive reset while port is still resuming
>

I am skeptical about it and hope somebody may help us on this.

>-Mathias
>

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

* RE: [PATCH v2] usb: xhci: Don't drive port 2.0 reset while resuming
  2016-10-26 12:34   ` Sriram Dash
@ 2016-10-26 14:39     ` Alan Stern
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2016-10-26 14:39 UTC (permalink / raw)
  To: Sriram Dash
  Cc: Mathias Nyman, linux-kernel, linux-usb, mathias.nyman, gregkh,
	Suresh Gupta, felipe.balbi, Rajat Srivastava, Rajesh Bhagat

On Wed, 26 Oct 2016, Sriram Dash wrote:

> >From: Mathias Nyman [mailto:mathias.nyman@linux.intel.com]

> >I don't think usb core tries to drive reset while port is still resuming
> >
> 
> I am skeptical about it and hope somebody may help us on this.

You can see for yourself.  In drivers/usb/core/hub.c, the 
usb_reset_device() routine calls usb_autoresume_device() before calling 
usb_reset_and_verify_device().  Therefore the port will have finished
resuming before the reset signal is sent.

Alan Stern

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

end of thread, other threads:[~2016-10-26 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 10:45 [PATCH v2] usb: xhci: Don't drive port 2.0 reset while resuming Sriram Dash
2016-10-25 12:58 ` Mathias Nyman
2016-10-26 12:34   ` Sriram Dash
2016-10-26 14:39     ` Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.