Skip to contentSkip to conversation

net: designware: Release the clocks if the PHY supply fails

PATCH In review Yuho Choi 2 participants 2 messages Nov 3 – Nov 6 Network drivers

lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 net: designware: Release the clocks if the PHY supply fails

designware_eth_probe() enables the clocks of the MAC before it enables the PHY supply. If regulator_set_enable_if_allowed() fails, or on NPCM8xx if setting "phy-supply-microvolt" fails, the probe returns directly and skips the clk_release_all() at the end of the function. A failed probe does not call designware_eth_remove(), so the clocks are left enabled.

Go to the error path instead, as the later failures in the probe do. This uses the mdio_err label, because clk_err only exists with CONFIG_CLK; nothing between the two labels has been set up yet. The PHY supply itself is still left enabled, as on the other error paths and in designware_eth_remove().

Fixes ba1f96672522 ("net: designware: add clock support")
Fixes 8897f91a5397 ("net: designware: support phy io micro voltage setting.")

---
Build-tested only, on nanopi-r2s-rk3328 and A20-OLinuXino-Lime2 (CLK=y, DM_REGULATOR=y), arbel_evb (NPCM8XX) and socfpga_arria10 (DM_REGULATOR=n), with no new warnings in designware.c at W=1. I also compiled designware.c with CONFIG_CLK undefined, since CLK is selected on all these boards. Not tested at runtime: I have no board where the PHY supply fails.

 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/designware.c +4 -2
index 9470804ebd1..52dd08da82a 100644
@@ -927,7 +927,8 @@ int designware_eth_probe(struct udevice *dev)
 		ret = regulator_set_enable_if_allowed(phy_supply, true);
 		if (ret) {
 			puts("Error enabling phy supply\n");
-			return ret;
+			err = ret;
+			goto mdio_err;
 		}
 #if IS_ENABLED(CONFIG_ARCH_NPCM8XX)
 		int phy_uv;
@@ -937,7 +938,8 @@ int designware_eth_probe(struct udevice *dev)
 			ret = regulator_set_value(phy_supply, phy_uv);
 			if (ret) {
 				puts("Error setting phy voltage\n");
-				return ret;
+				err = ret;
+				goto mdio_err;
 			}
 		}
 #endif
Signature · 1 line
2.43.0
#1 lore raw
Quoted 24 lines

designware_eth_probe() enables the clocks of the MAC before it enables the PHY supply. If regulator_set_enable_if_allowed() fails, or on NPCM8xx if setting "phy-supply-microvolt" fails, the probe returns directly and skips the clk_release_all() at the end of the function. A failed probe does not call designware_eth_remove(), so the clocks are left enabled.

Go to the error path instead, as the later failures in the probe do. This uses the mdio_err label, because clk_err only exists with CONFIG_CLK; nothing between the two labels has been set up yet. The PHY supply itself is still left enabled, as on the other error paths and in designware_eth_remove().

Fixes ba1f96672522 ("net: designware: add clock support")
Fixes 8897f91a5397 ("net: designware: support phy io micro voltage setting.")

---
Build-tested only, on nanopi-r2s-rk3328 and A20-OLinuXino-Lime2 (CLK=y, DM_REGULATOR=y), arbel_evb (NPCM8XX) and socfpga_arria10 (DM_REGULATOR=n), with no new warnings in designware.c at W=1. I also compiled designware.c with CONFIG_CLK undefined, since CLK is selected on all these boards. Not tested at runtime: I have no board where the PHY supply fails.

Quoted 2 lines
 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Applied to u-boot-net branch for-main [1], thanks!

[1] https://git.u-boot-project.org/u-boot/custodians/u-boot-net/-/commits/for-main

[1/1] net: designware: Release the clocks if the PHY supply fails

      commit: db5a66481335850a00e74932c8993fb5561b83cc

Best regards,

Signature · 1 line
Jerome Forissier <[email protected]>