diff mbox series

[v2] usb: dwc2: fix wrong order of phy_power_on and phy_init

Message ID dfcc6b40-2274-4e86-e73c-5c5e6aa3e046@gmail.com (mailing list archive)
State Accepted
Commit f9b995b49a07bd0d43b0e490f59be84415c745ae
Headers show
Series [v2] usb: dwc2: fix wrong order of phy_power_on and phy_init | expand

Commit Message

Heiner Kallweit Aug. 23, 2022, 5:58 p.m. UTC
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. The same change has to be done
to the order of phy_exit() and phy_power_off().

Fixes: 09a75e857790 ("usb: dwc2: refactor common low-level hw code to platform.c")
Cc: stable@vger.kernel.org
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- switch the order of phy_power_off() and phy_exit() too
---
 drivers/usb/dwc2/platform.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Minas Harutyunyan Aug. 24, 2022, 4:50 a.m. UTC | #1
On 8/23/2022 9:58 PM, Heiner Kallweit wrote:
> 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. The same change has to be done
> to the order of phy_exit() and phy_power_off().
> 
> Fixes: 09a75e857790 ("usb: dwc2: refactor common low-level hw code to platform.c")
> Cc: stable@vger.kernel.org
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Acked-by: Minas Harutyunyan <hminas@synopsys.com>

> ---
> v2:
> - switch the order of phy_power_off() and phy_exit() too
> ---
>   drivers/usb/dwc2/platform.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index c8ba87df7..91febf0e1 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -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;
> @@ -188,9 +188,9 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
>   	} else if (hsotg->plat && hsotg->plat->phy_exit) {
>   		ret = hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
>   	} else {
> -		ret = phy_exit(hsotg->phy);
> +		ret = phy_power_off(hsotg->phy);
>   		if (ret == 0)
> -			ret = phy_power_off(hsotg->phy);
> +			ret = phy_exit(hsotg->phy);
>   	}
>   	if (ret)
>   		return ret;
Marek Szyprowski Aug. 25, 2022, 7:07 a.m. UTC | #2
On 23.08.2022 19:58, Heiner Kallweit wrote:
> 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. The same change has to be done
> to the order of phy_exit() and phy_power_off().
>
> Fixes: 09a75e857790 ("usb: dwc2: refactor common low-level hw code to platform.c")
> Cc: stable@vger.kernel.org
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

I was about to send similar patch some time ago, but I didn't have time 
to check if all PHY drivers that are used by DWC2 would work fine after 
such change. It works fine on Exynos based SoCs though (init/exit 
callbacks are noop in this case), so:

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
> v2:
> - switch the order of phy_power_off() and phy_exit() too
> ---
>   drivers/usb/dwc2/platform.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index c8ba87df7..91febf0e1 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -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;
> @@ -188,9 +188,9 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
>   	} else if (hsotg->plat && hsotg->plat->phy_exit) {
>   		ret = hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
>   	} else {
> -		ret = phy_exit(hsotg->phy);
> +		ret = phy_power_off(hsotg->phy);
>   		if (ret == 0)
> -			ret = phy_power_off(hsotg->phy);
> +			ret = phy_exit(hsotg->phy);
>   	}
>   	if (ret)
>   		return ret;

Best regards
diff mbox series

Patch

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index c8ba87df7..91febf0e1 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -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;
@@ -188,9 +188,9 @@  static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
 	} else if (hsotg->plat && hsotg->plat->phy_exit) {
 		ret = hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 	} else {
-		ret = phy_exit(hsotg->phy);
+		ret = phy_power_off(hsotg->phy);
 		if (ret == 0)
-			ret = phy_power_off(hsotg->phy);
+			ret = phy_exit(hsotg->phy);
 	}
 	if (ret)
 		return ret;