linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] usb: dwc3: fix maximum_speed check for usb2.0-only core
@ 2020-07-09  8:10 Chunfeng Yun
  2020-07-09 22:17 ` Thinh Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Chunfeng Yun @ 2020-07-09  8:10 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Greg Kroah-Hartman, Matthias Brugger, linux-usb, linux-kernel,
	linux-arm-kernel, linux-mediatek, Chunfeng Yun

The maximum_speed will be USB_SPEED_SUPER_PLUS, but the
maximum_speed check for usb2.0-only core doesn't consider it,
so fix it, and move the ckeck into dwc3_check_params().

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
Note:

When I look at the code, find that this may be a problem, but no
platform to test it.
---
 drivers/usb/dwc3/core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 25c686a7..ffd5ab3 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -930,13 +930,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 	 */
 	dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
 
-	/* Handle USB2.0-only core configuration */
-	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
-			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
-		if (dwc->maximum_speed == USB_SPEED_SUPER)
-			dwc->maximum_speed = USB_SPEED_HIGH;
-	}
-
 	ret = dwc3_phy_setup(dwc);
 	if (ret)
 		goto err0;
@@ -1426,6 +1419,13 @@ static void dwc3_check_params(struct dwc3 *dwc)
 
 		break;
 	}
+
+	/* Handle USB2.0-only core configuration */
+	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
+			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
+		if (dwc->maximum_speed > USB_SPEED_HIGH)
+			dwc->maximum_speed = USB_SPEED_HIGH;
+	}
 }
 
 static int dwc3_probe(struct platform_device *pdev)
-- 
1.9.1

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

* Re: [RFC PATCH] usb: dwc3: fix maximum_speed check for usb2.0-only core
  2020-07-09  8:10 [RFC PATCH] usb: dwc3: fix maximum_speed check for usb2.0-only core Chunfeng Yun
@ 2020-07-09 22:17 ` Thinh Nguyen
  2020-07-24  3:32   ` Thinh Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Thinh Nguyen @ 2020-07-09 22:17 UTC (permalink / raw)
  To: Chunfeng Yun, Felipe Balbi
  Cc: Greg Kroah-Hartman, Matthias Brugger, linux-usb, linux-kernel,
	linux-arm-kernel, linux-mediatek

Hi,

Chunfeng Yun wrote:
> The maximum_speed will be USB_SPEED_SUPER_PLUS, but the
> maximum_speed check for usb2.0-only core doesn't consider it,
> so fix it, and move the ckeck into dwc3_check_params().
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> Note:
>
> When I look at the code, find that this may be a problem, but no
> platform to test it.
> ---
>   drivers/usb/dwc3/core.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 25c686a7..ffd5ab3 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -930,13 +930,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
>   	 */
>   	dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
>   
> -	/* Handle USB2.0-only core configuration */
> -	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
> -			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
> -		if (dwc->maximum_speed == USB_SPEED_SUPER)
> -			dwc->maximum_speed = USB_SPEED_HIGH;
> -	}
> -
>   	ret = dwc3_phy_setup(dwc);
>   	if (ret)
>   		goto err0;
> @@ -1426,6 +1419,13 @@ static void dwc3_check_params(struct dwc3 *dwc)
>   
>   		break;
>   	}
> +
> +	/* Handle USB2.0-only core configuration */
> +	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
> +			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
> +		if (dwc->maximum_speed > USB_SPEED_HIGH)
> +			dwc->maximum_speed = USB_SPEED_HIGH;
> +	}
>   }
>   
>   static int dwc3_probe(struct platform_device *pdev)

Actually, the dwc->maximum_speed captures the maximum speed device 
property value. It maybe be set based on the phy's capability if there's 
no property specifying it (i.e. maximum_speed is USB_SPEED_UNKNOWN).

So, this code should be removed. The fix should be in the check of 
dwc3_check_params(). If maximum_speed = USB_SPEED_UNKNOWN and the phy's 
capability is only up to highspeed, then set the maximum_speed to 
highspeed only.

Thanks,
Thinh

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

* Re: [RFC PATCH] usb: dwc3: fix maximum_speed check for usb2.0-only core
  2020-07-09 22:17 ` Thinh Nguyen
@ 2020-07-24  3:32   ` Thinh Nguyen
  2020-07-24  8:27     ` Chunfeng Yun
  0 siblings, 1 reply; 4+ messages in thread
From: Thinh Nguyen @ 2020-07-24  3:32 UTC (permalink / raw)
  To: Thinh Nguyen, Chunfeng Yun, Felipe Balbi
  Cc: Greg Kroah-Hartman, Matthias Brugger, linux-usb, linux-kernel,
	linux-arm-kernel, linux-mediatek

Hi,

Thinh Nguyen wrote:
> Hi,
>
> Chunfeng Yun wrote:
>> The maximum_speed will be USB_SPEED_SUPER_PLUS, but the
>> maximum_speed check for usb2.0-only core doesn't consider it,
>> so fix it, and move the ckeck into dwc3_check_params().
>>
>> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
>> ---
>> Note:
>>
>> When I look at the code, find that this may be a problem, but no
>> platform to test it.
>> ---
>>    drivers/usb/dwc3/core.c | 14 +++++++-------
>>    1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 25c686a7..ffd5ab3 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -930,13 +930,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
>>    	 */
>>    	dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
>>    
>> -	/* Handle USB2.0-only core configuration */
>> -	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
>> -			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
>> -		if (dwc->maximum_speed == USB_SPEED_SUPER)
>> -			dwc->maximum_speed = USB_SPEED_HIGH;
>> -	}
>> -
>>    	ret = dwc3_phy_setup(dwc);
>>    	if (ret)
>>    		goto err0;
>> @@ -1426,6 +1419,13 @@ static void dwc3_check_params(struct dwc3 *dwc)
>>    
>>    		break;
>>    	}
>> +
>> +	/* Handle USB2.0-only core configuration */
>> +	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
>> +			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
>> +		if (dwc->maximum_speed > USB_SPEED_HIGH)
>> +			dwc->maximum_speed = USB_SPEED_HIGH;
>> +	}
>>    }
>>    
>>    static int dwc3_probe(struct platform_device *pdev)
> Actually, the dwc->maximum_speed captures the maximum speed device
> property value. It maybe be set based on the phy's capability if there's
> no property specifying it (i.e. maximum_speed is USB_SPEED_UNKNOWN).
>
> So, this code should be removed. The fix should be in the check of
> dwc3_check_params(). If maximum_speed = USB_SPEED_UNKNOWN and the phy's
> capability is only up to highspeed, then set the maximum_speed to
> highspeed only.
>

Are you going into update and resend this patch? If not I can create one 
and add your "Reported-by"

BR,
Thinh

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

* Re: [RFC PATCH] usb: dwc3: fix maximum_speed check for usb2.0-only core
  2020-07-24  3:32   ` Thinh Nguyen
@ 2020-07-24  8:27     ` Chunfeng Yun
  0 siblings, 0 replies; 4+ messages in thread
From: Chunfeng Yun @ 2020-07-24  8:27 UTC (permalink / raw)
  To: Thinh Nguyen
  Cc: Felipe Balbi, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
	linux-kernel, linux-arm-kernel, linux-mediatek

On Fri, 2020-07-24 at 03:32 +0000, Thinh Nguyen wrote:
> Hi,
> 
> Thinh Nguyen wrote:
> > Hi,
> >
> > Chunfeng Yun wrote:
> >> The maximum_speed will be USB_SPEED_SUPER_PLUS, but the
> >> maximum_speed check for usb2.0-only core doesn't consider it,
> >> so fix it, and move the ckeck into dwc3_check_params().
> >>
> >> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> >> ---
> >> Note:
> >>
> >> When I look at the code, find that this may be a problem, but no
> >> platform to test it.
> >> ---
> >>    drivers/usb/dwc3/core.c | 14 +++++++-------
> >>    1 file changed, 7 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> >> index 25c686a7..ffd5ab3 100644
> >> --- a/drivers/usb/dwc3/core.c
> >> +++ b/drivers/usb/dwc3/core.c
> >> @@ -930,13 +930,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
> >>    	 */
> >>    	dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
> >>    
> >> -	/* Handle USB2.0-only core configuration */
> >> -	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
> >> -			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
> >> -		if (dwc->maximum_speed == USB_SPEED_SUPER)
> >> -			dwc->maximum_speed = USB_SPEED_HIGH;
> >> -	}
> >> -
> >>    	ret = dwc3_phy_setup(dwc);
> >>    	if (ret)
> >>    		goto err0;
> >> @@ -1426,6 +1419,13 @@ static void dwc3_check_params(struct dwc3 *dwc)
> >>    
> >>    		break;
> >>    	}
> >> +
> >> +	/* Handle USB2.0-only core configuration */
> >> +	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
> >> +			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
> >> +		if (dwc->maximum_speed > USB_SPEED_HIGH)
> >> +			dwc->maximum_speed = USB_SPEED_HIGH;
> >> +	}
> >>    }
> >>    
> >>    static int dwc3_probe(struct platform_device *pdev)
> > Actually, the dwc->maximum_speed captures the maximum speed device
> > property value. It maybe be set based on the phy's capability if there's
> > no property specifying it (i.e. maximum_speed is USB_SPEED_UNKNOWN).
> >
> > So, this code should be removed. The fix should be in the check of
> > dwc3_check_params(). If maximum_speed = USB_SPEED_UNKNOWN and the phy's
> > capability is only up to highspeed, then set the maximum_speed to
> > highspeed only.
Sorry for the late reply, my outlook lose your email.
> >
> 
> Are you going into update and resend this patch?
I don't know how to check "the phy's capability is only up to highspeed"

>  If not I can create one 
> and add your "Reported-by"
Ok, thanks

> 
> BR,
> Thinh


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

end of thread, other threads:[~2020-07-24  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09  8:10 [RFC PATCH] usb: dwc3: fix maximum_speed check for usb2.0-only core Chunfeng Yun
2020-07-09 22:17 ` Thinh Nguyen
2020-07-24  3:32   ` Thinh Nguyen
2020-07-24  8:27     ` Chunfeng Yun

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