linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: xhci: Workaround for erratum-A010129
@ 2016-10-21 14:11 Sriram Dash
  2016-10-21 16:44 ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Sriram Dash @ 2016-10-21 14:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: mathias.nyman, gregkh, suresh.gupta, felipe.balbi, 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>
---
 drivers/usb/host/xhci-hub.c | 28 +++++++++++++++++++++++++++-
 drivers/usb/host/xhci.h     |  1 +
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 730b9fd..3def0dd 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,32 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			spin_lock_irqsave(&xhci->lock, flags);
 			break;
 		case USB_PORT_FEAT_RESET:
+			/*
+			 * Erratum : A010129
+			 * Synopsys STAR 9000962562.
+			 * USB 2.0 Reset Not Driven While Port in Resume
+			 * While in USB 2.0 resume state (the PORTSC.PLS
+			 * register bit is set to 4'd15), if the xHCI driver
+			 * programs the PORTSC.PR register bit to 1, the
+			 * controller does not drive a USB 2.0 reset
+			 * and it does not generate a PORTSC.PRC=1 interrupt.
+			 * So, The xHCI driver should not program a USB
+			 * 2.0 reset (PORTSC.PR=1) while in resume
+			 * (PORTSC.PLS=4'd15).
+			 */
+			if (xhci->quirks & XHCI_PORT_RST_ON_RESUME) {
+				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);
+					break;
+				}
+				spin_lock_irqsave(&xhci->lock, flags);
+			}
+
 			temp = (temp | PORT_RESET);
 			writel(temp, port_array[wIndex]);
 
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index b2c1dc5..c07e267 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1653,6 +1653,7 @@ struct xhci_hcd {
 #define XHCI_MTK_HOST		(1 << 21)
 #define XHCI_SSIC_PORT_UNUSED	(1 << 22)
 #define XHCI_NO_64BIT_SUPPORT	(1 << 23)
+#define XHCI_PORT_RST_ON_RESUME	(1 << 24)
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
 	/* There are two roothubs to keep track of bus suspend info for */
-- 
2.1.0

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

* Re: [PATCH] usb: xhci: Workaround for erratum-A010129
  2016-10-21 14:11 [PATCH] usb: xhci: Workaround for erratum-A010129 Sriram Dash
@ 2016-10-21 16:44 ` Alan Stern
  2016-10-23  6:47   ` Sriram Dash
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2016-10-21 16:44 UTC (permalink / raw)
  To: Sriram Dash
  Cc: linux-kernel, linux-usb, mathias.nyman, gregkh, suresh.gupta,
	felipe.balbi, Rajat Srivastava, Rajesh Bhagat

On Fri, 21 Oct 2016, 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>
> ---
>  drivers/usb/host/xhci-hub.c | 28 +++++++++++++++++++++++++++-
>  drivers/usb/host/xhci.h     |  1 +
>  2 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
> index 730b9fd..3def0dd 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,32 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
>  			spin_lock_irqsave(&xhci->lock, flags);
>  			break;
>  		case USB_PORT_FEAT_RESET:
> +			/*
> +			 * Erratum : A010129
> +			 * Synopsys STAR 9000962562.
> +			 * USB 2.0 Reset Not Driven While Port in Resume
> +			 * While in USB 2.0 resume state (the PORTSC.PLS
> +			 * register bit is set to 4'd15), if the xHCI driver
> +			 * programs the PORTSC.PR register bit to 1, the
> +			 * controller does not drive a USB 2.0 reset
> +			 * and it does not generate a PORTSC.PRC=1 interrupt.
> +			 * So, The xHCI driver should not program a USB
> +			 * 2.0 reset (PORTSC.PR=1) while in resume
> +			 * (PORTSC.PLS=4'd15).
> +			 */
> +			if (xhci->quirks & XHCI_PORT_RST_ON_RESUME) {

It's always a bad idea to drive a reset signal while a port is 
resuming.  We don't need a quirk flag for this.  The HCD should never 
do it, and the USB core should never tell the HCD to do it.

Alan Stern

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

* RE: [PATCH] usb: xhci: Workaround for erratum-A010129
  2016-10-21 16:44 ` Alan Stern
@ 2016-10-23  6:47   ` Sriram Dash
  0 siblings, 0 replies; 3+ messages in thread
From: Sriram Dash @ 2016-10-23  6:47 UTC (permalink / raw)
  To: Alan Stern
  Cc: linux-kernel, linux-usb, mathias.nyman, gregkh, Suresh Gupta,
	felipe.balbi, Rajat Srivastava, Rajesh Bhagat

>From: Alan Stern [mailto:stern@rowland.harvard.edu]
>On Fri, 21 Oct 2016, 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>
>> ---
>>  drivers/usb/host/xhci-hub.c | 28 +++++++++++++++++++++++++++-
>>  drivers/usb/host/xhci.h     |  1 +
>>  2 files changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
>> index 730b9fd..3def0dd 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,32 @@ int xhci_hub_control(struct usb_hcd *hcd, u16
>typeReq, u16 wValue,
>>  			spin_lock_irqsave(&xhci->lock, flags);
>>  			break;
>>  		case USB_PORT_FEAT_RESET:
>> +			/*
>> +			 * Erratum : A010129
>> +			 * Synopsys STAR 9000962562.
>> +			 * USB 2.0 Reset Not Driven While Port in Resume
>> +			 * While in USB 2.0 resume state (the PORTSC.PLS
>> +			 * register bit is set to 4'd15), if the xHCI driver
>> +			 * programs the PORTSC.PR register bit to 1, the
>> +			 * controller does not drive a USB 2.0 reset
>> +			 * and it does not generate a PORTSC.PRC=1 interrupt.
>> +			 * So, The xHCI driver should not program a USB
>> +			 * 2.0 reset (PORTSC.PR=1) while in resume
>> +			 * (PORTSC.PLS=4'd15).
>> +			 */
>> +			if (xhci->quirks & XHCI_PORT_RST_ON_RESUME) {
>
>It's always a bad idea to drive a reset signal while a port is resuming.  We don't
>need a quirk flag for this.  

Hi Alan,

Ok. Then I will make it generic for xhci in the next version.

>The HCD should never do it, and the USB core should
>never tell the HCD to do it.
>
>Alan Stern

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

end of thread, other threads:[~2016-10-23 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21 14:11 [PATCH] usb: xhci: Workaround for erratum-A010129 Sriram Dash
2016-10-21 16:44 ` Alan Stern
2016-10-23  6:47   ` Sriram Dash

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