diff mbox series

usb: dwc3: move core validation to be after clks enable

Message ID 1557288102-26129-1-git-send-email-jun.li@nxp.com (mailing list archive)
State Superseded
Headers show
Series usb: dwc3: move core validation to be after clks enable | expand

Commit Message

Jun Li May 8, 2019, 4:24 a.m. UTC
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>
---
 drivers/usb/dwc3/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Sriharsha Allenki May 8, 2019, 10:25 a.m. UTC | #1
Hi Jun Li,

On 5/8/2019 9:54 AM, Jun Li wrote:
> 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>
> ---
>   drivers/usb/dwc3/core.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 4aff1d8..0e49ff3 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,11 @@ 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");

Please update "ret" here with -ENODEV, else the probe call will return 
success (ret is 0).

> +		goto disable_clks;
> +	}
> +
>   	platform_set_drvdata(pdev, dwc);
>   	dwc3_cache_hwparams(dwc);
>   
> @@ -1524,7 +1524,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);

Regards,

Sriharsha
Jun Li May 8, 2019, 10:43 a.m. UTC | #2
Hi Sriharsha,

> -----Original Message-----
> From: Sriharsha Allenki <sallenki@codeaurora.org>
> Sent: 2019年5月8日 18:26
> To: Jun Li <jun.li@nxp.com>; balbi@kernel.org; gregkh@linuxfoundation.org
> Cc: thinhn@synopsys.com; linux-usb@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>
> Subject: Re: [PATCH] usb: dwc3: move core validation to be after clks enable
> 
> Hi Jun Li,
> 
> On 5/8/2019 9:54 AM, Jun Li wrote:
> > 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>
> > ---
> >   drivers/usb/dwc3/core.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
> > 4aff1d8..0e49ff3 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,11 @@ 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");
> 
> Please update "ret" here with -ENODEV, else the probe call will return success (ret
> is 0).

Correct, I will update and send V2.

Thanks
Jun

> 
> > +		goto disable_clks;
> > +	}
> > +
> >   	platform_set_drvdata(pdev, dwc);
> >   	dwc3_cache_hwparams(dwc);
> >
> > @@ -1524,7 +1524,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);
> 
> Regards,
> 
> Sriharsha
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 4aff1d8..0e49ff3 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,11 @@  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");
+		goto disable_clks;
+	}
+
 	platform_set_drvdata(pdev, dwc);
 	dwc3_cache_hwparams(dwc);
 
@@ -1524,7 +1524,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);