linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: dwc3: move core validation to be after clks enable
@ 2019-05-08 10:52 Jun Li
  2019-05-23 15:15 ` Baruch Siach
  0 siblings, 1 reply; 4+ messages in thread
From: Jun Li @ 2019-05-08 10:52 UTC (permalink / raw)
  To: balbi@kernel.org, gregkh@linuxfoundation.org
  Cc: thinhn@synopsys.com, linux-usb@vger.kernel.org, dl-linux-imx

From: Jun Li <jun.li@nxp.com>

Register access in core validation may hang before the bulk
clks are enabled.

Fixes: b873e2d0ea1e ("usb: dwc3: Do core validation early on probe")
Signed-off-by: Jun Li <jun.li@nxp.com>
---

Change for v2:
- Update ret to be -ENODEV in case dwc3_core_is_valid() fail.

 drivers/usb/dwc3/core.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 4aff1d8..93b96e6 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1423,11 +1423,6 @@ static int dwc3_probe(struct platform_device *pdev)
 	dwc->regs	= regs;
 	dwc->regs_size	= resource_size(&dwc_res);
 
-	if (!dwc3_core_is_valid(dwc)) {
-		dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
-		return -ENODEV;
-	}
-
 	dwc3_get_properties(dwc);
 
 	dwc->reset = devm_reset_control_get_optional_shared(dev, NULL);
@@ -1460,6 +1455,12 @@ static int dwc3_probe(struct platform_device *pdev)
 	if (ret)
 		goto unprepare_clks;
 
+	if (!dwc3_core_is_valid(dwc)) {
+		dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
+		ret = -ENODEV;
+		goto disable_clks;
+	}
+
 	platform_set_drvdata(pdev, dwc);
 	dwc3_cache_hwparams(dwc);
 
@@ -1524,7 +1525,7 @@ static int dwc3_probe(struct platform_device *pdev)
 err1:
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-
+disable_clks:
 	clk_bulk_disable(dwc->num_clks, dwc->clks);
 unprepare_clks:
 	clk_bulk_unprepare(dwc->num_clks, dwc->clks);
-- 
2.7.4


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

* Re: [PATCH v2] usb: dwc3: move core validation to be after clks enable
  2019-05-08 10:52 [PATCH v2] usb: dwc3: move core validation to be after clks enable Jun Li
@ 2019-05-23 15:15 ` Baruch Siach
  2019-05-23 22:31   ` Thinh Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Baruch Siach @ 2019-05-23 15:15 UTC (permalink / raw)
  To: Jun Li
  Cc: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb,
	dl-linux-imx

Hi Jun Li,

On Wed, May 08, 2019 at 10:52:37AM +0000, Jun Li wrote:
> From: Jun Li <jun.li@nxp.com>
> 
> Register access in core validation may hang before the bulk
> clks are enabled.

This patch fixes the hang issue for on my i.MX8MQ based system.

Tested-by: Baruch Siach <baruch@tkos.co.il>

However, commit b873e2d0ea1e is meant to move dwc3_core_is_valid() before 
dwc3_get_dr_mode(). With this patch dwc3_get_dr_mode() is called from 
dwc3_get_properties() before dwc3_core_is_valid().

I guess we need a larger change in the initialization sequence.

Thanks,
baruch

> Fixes: b873e2d0ea1e ("usb: dwc3: Do core validation early on probe")
> Signed-off-by: Jun Li <jun.li@nxp.com>
> ---
> 
> Change for v2:
> - Update ret to be -ENODEV in case dwc3_core_is_valid() fail.
> 
>  drivers/usb/dwc3/core.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 4aff1d8..93b96e6 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1423,11 +1423,6 @@ static int dwc3_probe(struct platform_device *pdev)
>  	dwc->regs	= regs;
>  	dwc->regs_size	= resource_size(&dwc_res);
>  
> -	if (!dwc3_core_is_valid(dwc)) {
> -		dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
> -		return -ENODEV;
> -	}
> -
>  	dwc3_get_properties(dwc);
>  
>  	dwc->reset = devm_reset_control_get_optional_shared(dev, NULL);
> @@ -1460,6 +1455,12 @@ static int dwc3_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto unprepare_clks;
>  
> +	if (!dwc3_core_is_valid(dwc)) {
> +		dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
> +		ret = -ENODEV;
> +		goto disable_clks;
> +	}
> +
>  	platform_set_drvdata(pdev, dwc);
>  	dwc3_cache_hwparams(dwc);
>  
> @@ -1524,7 +1525,7 @@ static int dwc3_probe(struct platform_device *pdev)
>  err1:
>  	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -
> +disable_clks:
>  	clk_bulk_disable(dwc->num_clks, dwc->clks);
>  unprepare_clks:
>  	clk_bulk_unprepare(dwc->num_clks, dwc->clks);

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

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

* Re: [PATCH v2] usb: dwc3: move core validation to be after clks enable
  2019-05-23 15:15 ` Baruch Siach
@ 2019-05-23 22:31   ` Thinh Nguyen
  2019-05-24  2:57     ` Baruch Siach
  0 siblings, 1 reply; 4+ messages in thread
From: Thinh Nguyen @ 2019-05-23 22:31 UTC (permalink / raw)
  To: Baruch Siach, Jun Li
  Cc: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen,
	linux-usb@vger.kernel.org, dl-linux-imx

Hi Baruch,

Baruch Siach wrote:
> Hi Jun Li,
>
> On Wed, May 08, 2019 at 10:52:37AM +0000, Jun Li wrote:
>> From: Jun Li <jun.li@nxp.com>
>>
>> Register access in core validation may hang before the bulk
>> clks are enabled.
> This patch fixes the hang issue for on my i.MX8MQ based system.
>
> Tested-by: Baruch Siach <baruch@tkos.co.il>
>
> However, commit b873e2d0ea1e is meant to move dwc3_core_is_valid() before 
> dwc3_get_dr_mode(). With this patch dwc3_get_dr_mode() is called from 
> dwc3_get_properties() before dwc3_core_is_valid().
>
> I guess we need a larger change in the initialization sequence.
>
> Thanks,
> baruch
>

Look again. dwc3_get_dr_mode() is not called from dwc3_get_properties().

This patch is fine.

BR,
Thinh

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

* Re: [PATCH v2] usb: dwc3: move core validation to be after clks enable
  2019-05-23 22:31   ` Thinh Nguyen
@ 2019-05-24  2:57     ` Baruch Siach
  0 siblings, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2019-05-24  2:57 UTC (permalink / raw)
  To: Thinh Nguyen
  Cc: Jun Li, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb@vger.kernel.org, dl-linux-imx

Hi Thinh,

On Fri, May 24 2019, Thinh Nguyen wrote:
> Baruch Siach wrote:
>> Hi Jun Li,
>>
>> On Wed, May 08, 2019 at 10:52:37AM +0000, Jun Li wrote:
>>> From: Jun Li <jun.li@nxp.com>
>>>
>>> Register access in core validation may hang before the bulk
>>> clks are enabled.
>> This patch fixes the hang issue for on my i.MX8MQ based system.
>>
>> Tested-by: Baruch Siach <baruch@tkos.co.il>
>>
>> However, commit b873e2d0ea1e is meant to move dwc3_core_is_valid() before 
>> dwc3_get_dr_mode(). With this patch dwc3_get_dr_mode() is called from 
>> dwc3_get_properties() before dwc3_core_is_valid().
>>
>> I guess we need a larger change in the initialization sequence.
>>
>> Thanks,
>> baruch
>
> Look again. dwc3_get_dr_mode() is not called from dwc3_get_properties().
>
> This patch is fine.

Your are right. The usb_get_dr_mode() call confused me.

Thanks,
baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

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

end of thread, other threads:[~2019-05-24  2:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-08 10:52 [PATCH v2] usb: dwc3: move core validation to be after clks enable Jun Li
2019-05-23 15:15 ` Baruch Siach
2019-05-23 22:31   ` Thinh Nguyen
2019-05-24  2:57     ` Baruch Siach

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