linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: dwc3: gadget: Do link recovery for SS and SSP
@ 2019-12-11  2:26 Thinh Nguyen
  2020-02-01  0:25 ` [RESEND PATCH " Thinh Nguyen
  2020-03-31  2:12 ` Thinh Nguyen
  0 siblings, 2 replies; 4+ messages in thread
From: Thinh Nguyen @ 2019-12-11  2:26 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: John Youn, Thinh Nguyen, linux-usb

The controller always supports link recovery for device in SS and SSP.
Remove the speed limit check. Also, when the device is in RESUME or
RESET state, it means the controller received the resume/reset request.
The driver must send the link recovery to acknowledge the request. They
are valid states for the driver to send link recovery.

Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
Fixes: ee5cd41c9117 ("usb: dwc3: Update speed checks for SuperSpeedPlus")
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
Changes in v2 -
  Added Fixes tags

 drivers/usb/dwc3/gadget.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a9aba716bf80..3dcdde9080f5 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1712,7 +1712,6 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
 	u32			reg;
 
 	u8			link_state;
-	u8			speed;
 
 	/*
 	 * According to the Databook Remote wakeup request should
@@ -1722,16 +1721,13 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
 	 */
 	reg = dwc3_readl(dwc->regs, DWC3_DSTS);
 
-	speed = reg & DWC3_DSTS_CONNECTSPD;
-	if ((speed == DWC3_DSTS_SUPERSPEED) ||
-	    (speed == DWC3_DSTS_SUPERSPEED_PLUS))
-		return 0;
-
 	link_state = DWC3_DSTS_USBLNKST(reg);
 
 	switch (link_state) {
+	case DWC3_LINK_STATE_RESET:
 	case DWC3_LINK_STATE_RX_DET:	/* in HS, means Early Suspend */
 	case DWC3_LINK_STATE_U3:	/* in HS, means SUSPEND */
+	case DWC3_LINK_STATE_RESUME:
 		break;
 	default:
 		return -EINVAL;
-- 
2.11.0


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

* [RESEND PATCH v2] usb: dwc3: gadget: Do link recovery for SS and SSP
  2019-12-11  2:26 [PATCH v2] usb: dwc3: gadget: Do link recovery for SS and SSP Thinh Nguyen
@ 2020-02-01  0:25 ` Thinh Nguyen
  2020-03-31  2:12 ` Thinh Nguyen
  1 sibling, 0 replies; 4+ messages in thread
From: Thinh Nguyen @ 2020-02-01  0:25 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: John Youn, Thinh Nguyen, linux-usb

The controller always supports link recovery for device in SS and SSP.
Remove the speed limit check. Also, when the device is in RESUME or
RESET state, it means the controller received the resume/reset request.
The driver must send the link recovery to acknowledge the request. They
are valid states for the driver to send link recovery.

Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
Fixes: ee5cd41c9117 ("usb: dwc3: Update speed checks for SuperSpeedPlus")
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---

Resend note -
  This was on Felipe's next branch some time ago,
  but it was lost somehow.

Changes in v2 -
  Added Fixes tags

 drivers/usb/dwc3/gadget.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a9aba716bf80..3dcdde9080f5 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1712,7 +1712,6 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
 	u32			reg;
 
 	u8			link_state;
-	u8			speed;
 
 	/*
 	 * According to the Databook Remote wakeup request should
@@ -1722,16 +1721,13 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
 	 */
 	reg = dwc3_readl(dwc->regs, DWC3_DSTS);
 
-	speed = reg & DWC3_DSTS_CONNECTSPD;
-	if ((speed == DWC3_DSTS_SUPERSPEED) ||
-	    (speed == DWC3_DSTS_SUPERSPEED_PLUS))
-		return 0;
-
 	link_state = DWC3_DSTS_USBLNKST(reg);
 
 	switch (link_state) {
+	case DWC3_LINK_STATE_RESET:
 	case DWC3_LINK_STATE_RX_DET:	/* in HS, means Early Suspend */
 	case DWC3_LINK_STATE_U3:	/* in HS, means SUSPEND */
+	case DWC3_LINK_STATE_RESUME:
 		break;
 	default:
 		return -EINVAL;
-- 
2.11.0


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

* Re: [RESEND PATCH v2] usb: dwc3: gadget: Do link recovery for SS and SSP
  2019-12-11  2:26 [PATCH v2] usb: dwc3: gadget: Do link recovery for SS and SSP Thinh Nguyen
  2020-02-01  0:25 ` [RESEND PATCH " Thinh Nguyen
@ 2020-03-31  2:12 ` Thinh Nguyen
  2020-03-31  8:11   ` Felipe Balbi
  1 sibling, 1 reply; 4+ messages in thread
From: Thinh Nguyen @ 2020-03-31  2:12 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: John Youn, linux-usb

Hi,

Thinh Nguyen wrote:
> The controller always supports link recovery for device in SS and SSP.
> Remove the speed limit check. Also, when the device is in RESUME or
> RESET state, it means the controller received the resume/reset request.
> The driver must send the link recovery to acknowledge the request. They
> are valid states for the driver to send link recovery.
>
> Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
> Fixes: ee5cd41c9117 ("usb: dwc3: Update speed checks for SuperSpeedPlus")
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
> ---
>
> Resend note -
>    This was on Felipe's next branch some time ago,
>    but it was lost somehow.
>
> Changes in v2 -
>    Added Fixes tags
>
>   drivers/usb/dwc3/gadget.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index a9aba716bf80..3dcdde9080f5 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1712,7 +1712,6 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
>   	u32			reg;
>   
>   	u8			link_state;
> -	u8			speed;
>   
>   	/*
>   	 * According to the Databook Remote wakeup request should
> @@ -1722,16 +1721,13 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
>   	 */
>   	reg = dwc3_readl(dwc->regs, DWC3_DSTS);
>   
> -	speed = reg & DWC3_DSTS_CONNECTSPD;
> -	if ((speed == DWC3_DSTS_SUPERSPEED) ||
> -	    (speed == DWC3_DSTS_SUPERSPEED_PLUS))
> -		return 0;
> -
>   	link_state = DWC3_DSTS_USBLNKST(reg);
>   
>   	switch (link_state) {
> +	case DWC3_LINK_STATE_RESET:
>   	case DWC3_LINK_STATE_RX_DET:	/* in HS, means Early Suspend */
>   	case DWC3_LINK_STATE_U3:	/* in HS, means SUSPEND */
> +	case DWC3_LINK_STATE_RESUME:
>   		break;
>   	default:
>   		return -EINVAL;

Maybe this patch was lost somewhere. Let me know if there's any issue 
with this patch.

Thanks,
Thinh

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

* Re: [RESEND PATCH v2] usb: dwc3: gadget: Do link recovery for SS and SSP
  2020-03-31  2:12 ` Thinh Nguyen
@ 2020-03-31  8:11   ` Felipe Balbi
  0 siblings, 0 replies; 4+ messages in thread
From: Felipe Balbi @ 2020-03-31  8:11 UTC (permalink / raw)
  To: Thinh Nguyen; +Cc: John Youn, linux-usb

[-- Attachment #1: Type: text/plain, Size: 2107 bytes --]


Hi,

Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
> Thinh Nguyen wrote:
>> The controller always supports link recovery for device in SS and SSP.
>> Remove the speed limit check. Also, when the device is in RESUME or
>> RESET state, it means the controller received the resume/reset request.
>> The driver must send the link recovery to acknowledge the request. They
>> are valid states for the driver to send link recovery.
>>
>> Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
>> Fixes: ee5cd41c9117 ("usb: dwc3: Update speed checks for SuperSpeedPlus")
>> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
>> ---
>>
>> Resend note -
>>    This was on Felipe's next branch some time ago,
>>    but it was lost somehow.
>>
>> Changes in v2 -
>>    Added Fixes tags
>>
>>   drivers/usb/dwc3/gadget.c | 8 ++------
>>   1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index a9aba716bf80..3dcdde9080f5 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -1712,7 +1712,6 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
>>   	u32			reg;
>>   
>>   	u8			link_state;
>> -	u8			speed;
>>   
>>   	/*
>>   	 * According to the Databook Remote wakeup request should
>> @@ -1722,16 +1721,13 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
>>   	 */
>>   	reg = dwc3_readl(dwc->regs, DWC3_DSTS);
>>   
>> -	speed = reg & DWC3_DSTS_CONNECTSPD;
>> -	if ((speed == DWC3_DSTS_SUPERSPEED) ||
>> -	    (speed == DWC3_DSTS_SUPERSPEED_PLUS))
>> -		return 0;
>> -
>>   	link_state = DWC3_DSTS_USBLNKST(reg);
>>   
>>   	switch (link_state) {
>> +	case DWC3_LINK_STATE_RESET:
>>   	case DWC3_LINK_STATE_RX_DET:	/* in HS, means Early Suspend */
>>   	case DWC3_LINK_STATE_U3:	/* in HS, means SUSPEND */
>> +	case DWC3_LINK_STATE_RESUME:
>>   		break;
>>   	default:
>>   		return -EINVAL;
>
> Maybe this patch was lost somewhere. Let me know if there's any issue 
> with this patch.

It's now in my testing/fixes

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

end of thread, other threads:[~2020-03-31  8:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11  2:26 [PATCH v2] usb: dwc3: gadget: Do link recovery for SS and SSP Thinh Nguyen
2020-02-01  0:25 ` [RESEND PATCH " Thinh Nguyen
2020-03-31  2:12 ` Thinh Nguyen
2020-03-31  8:11   ` Felipe Balbi

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