Skip to contentSkip to conversation

usb: dwc2: fix wrong order of phy_power_on and phy_init

PATCH Superseded Heiner Kallweit 2 participants 4 messages Aug 20, 2022 – Aug 22, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc2: fix wrong order of phy_power_on and phy_init

Since 1599069a62c6 ("phy: core: Warn when phy_power_on is called before phy_init") the driver complains. In my case (Amlogic SoC) the warning
is: phy phy-fe03e000.phy.2: phy_power_on was called before phy_init So change the order of the two calls.

Fixes 09a75e857790 ("usb: dwc2: refactor common low-level hw code to platform.c")
---
 drivers/usb/dwc2/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc2/platform.c +2 -2
index c8ba87df7..4db7a18a5 100644
@@ -154,9 +154,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
 	} else if (hsotg->plat && hsotg->plat->phy_init) {
 		ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 	} else {
-		ret = phy_power_on(hsotg->phy);
+		ret = phy_init(hsotg->phy);
 		if (ret == 0)
-			ret = phy_init(hsotg->phy);
+			ret = phy_power_on(hsotg->phy);
 	}
 
 	return ret;
Signature · 1 line
2.37.2
#1 lore raw

Hi Heiner,

Quoted 6 lines · Heiner Kallweit

Since 1599069a62c6 ("phy: core: Warn when phy_power_on is called before phy_init") the driver complains. In my case (Amlogic SoC) the warning
is: phy phy-fe03e000.phy.2: phy_power_on was called before phy_init So change the order of the two calls.

Fixes 09a75e857790 ("usb: dwc2: refactor common low-level hw code to platform.c")

Added CC: Marek Szyprowski <[email protected]>

Quoted 12 lines
---
  drivers/usb/dwc2/platform.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc2/platform.c +0 -0
index c8ba87df7..4db7a18a5 100644
@@ -154,9 +154,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
  	} else if (hsotg->plat && hsotg->plat->phy_init) {

drivers/usb/dwc2/platform.c static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) · line 162

Quoted 10 lines
drivers/usb/dwc2/platform.c +2 -2
  		ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
  	} else {
-		ret = phy_power_on(hsotg->phy);
+		ret = phy_init(hsotg->phy);
  		if (ret == 0)
-			ret = phy_init(hsotg->phy);
+			ret = phy_power_on(hsotg->phy);
  	}
 
  	return ret;

Shouldn't be updated function __dwc2_lowlevel_hw_disable() similarly,
according: phy_power_off must be called before phy_exit()?

Thanks,
Minas

#2 lore raw
Quoted 32 lines · Minas Harutyunyan

Hi Heiner,

Quoted 6 lines · Heiner Kallweit

Since 1599069a62c6 ("phy: core: Warn when phy_power_on is called before phy_init") the driver complains. In my case (Amlogic SoC) the warning
is: phy phy-fe03e000.phy.2: phy_power_on was called before phy_init So change the order of the two calls.

Fixes 09a75e857790 ("usb: dwc2: refactor common low-level hw code to platform.c")

Added CC: Marek Szyprowski <[email protected]>

Quoted 21 lines
---
  drivers/usb/dwc2/platform.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc2/platform.c +2 -2
index c8ba87df7..4db7a18a5 100644
@@ -154,9 +154,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
  	} else if (hsotg->plat && hsotg->plat->phy_init) {
  		ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
  	} else {
-		ret = phy_power_on(hsotg->phy);
+		ret = phy_init(hsotg->phy);
  		if (ret == 0)
-			ret = phy_init(hsotg->phy);
+			ret = phy_power_on(hsotg->phy);
  	}
 
Quoted 5 lines

drivers/usb/dwc2/platform.c static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) · line 162

Quoted 1 line
drivers/usb/dwc2/platform.c +0 -0
  	return ret;

Shouldn't be updated function __dwc2_lowlevel_hw_disable() similarly,
according: phy_power_off must be called before phy_exit()?

Indeed, this should be changed accordingly.
See kernel doc:

* phy_exit - Phy internal un-initialization
* @phy: the phy returned by phy_get()
*
* Must be called after phy_power_off().

Quoted 3 lines

Thanks,
Minas

#3 lore raw
Quoted 33 lines · Heiner Kallweit
Quoted 32 lines · Minas Harutyunyan

Hi Heiner,

Quoted 6 lines · Heiner Kallweit

Since 1599069a62c6 ("phy: core: Warn when phy_power_on is called before phy_init") the driver complains. In my case (Amlogic SoC) the warning
is: phy phy-fe03e000.phy.2: phy_power_on was called before phy_init So change the order of the two calls.

Fixes 09a75e857790 ("usb: dwc2: refactor common low-level hw code to platform.c")

Added CC: Marek Szyprowski <[email protected]>

Quoted 21 lines
---
   drivers/usb/dwc2/platform.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc2/platform.c +2 -2
index c8ba87df7..4db7a18a5 100644
@@ -154,9 +154,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
   	} else if (hsotg->plat && hsotg->plat->phy_init) {
   		ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
   	} else {
-		ret = phy_power_on(hsotg->phy);
+		ret = phy_init(hsotg->phy);
   		if (ret == 0)
-			ret = phy_init(hsotg->phy);
+			ret = phy_power_on(hsotg->phy);
   	}
 
Quoted 6 lines
Quoted 5 lines

drivers/usb/dwc2/platform.c static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) · line 162

Quoted 1 line
drivers/usb/dwc2/platform.c +0 -0
   	return ret;

Shouldn't be updated function __dwc2_lowlevel_hw_disable() similarly,
according: phy_power_off must be called before phy_exit()?

Indeed, this should be changed accordingly.

Could you please add to your patch fixes for
__dwc2_lowlevel_hw_disable() too and re-submit.

Thanks,
Minas

Quoted 11 lines

See kernel doc:

* phy_exit - Phy internal un-initialization
* @phy: the phy returned by phy_get()
*
* Must be called after phy_power_off().

Quoted 3 lines

Thanks,
Minas