Skip to contentSkip to conversation

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

PATCH In review Jun Li 3 participants 4 messages May 8, 2019 – May 24, 2019

Subsystems (2)
lore
Share & tools
lore

Jun Li

author
#0 lore raw

PATCH v2 1/1 usb: dwc3: move core validation to be after clks enable

From: Jun Li <[email protected]>

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

Fixes b873e2d0ea1e ("usb: dwc3: Do core validation early on probe")

---

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(-)
drivers/usb/dwc3/core.c +7 -6
index 4aff1d8..93b96e6 100644
@@ -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);
Signature · 1 line
2.7.4
Tested-by on v2 1/1
#1 lore raw

Hi Jun Li,

Quoted 4 lines · Jun Li

From: Jun Li <[email protected]>

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.

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

Quoted 48 lines
Fixes b873e2d0ea1e ("usb: dwc3: Do core validation early on probe")

---

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(-)
drivers/usb/dwc3/core.c +7 -6
index 4aff1d8..93b96e6 100644
@@ -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);
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -
maintainer
#2 lore raw

Hi Baruch,

Quoted 11 lines · Baruch Siach

Hi Jun Li,

Quoted 4 lines · Jun Li

From: Jun Li <[email protected]>

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.

Quoted 9 lines

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

#3 lore raw

Hi Thinh,

Quoted 16 lines · Thinh Nguyen
Quoted 15 lines · Baruch Siach

Hi Jun Li,

Quoted 4 lines · Jun Li

From: Jun Li <[email protected]>

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.

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

Quoted 8 lines
Quoted 4 lines

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

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -