[PATCH v2] net: phy: fix duplicate eth_phy binding
Pranav Tilak
pranav.vinaytilak at amd.com
Wed Apr 8 10:58:12 CEST 2026
When both CONFIG_PHY_ETHERNET_ID and CONFIG_DM_ETH_PHY are enabled,
eth_phy_binds_nodes() called from eth_post_bind() already binds the
ethernet PHY node to eth_phy_generic_drv. However, phy_connect_phy_id()
called via zynq_phy_init() -> phy_connect() cannot attach to the already
bound PHY device and creates a second instance, resulting in duplicate
entries in the dm tree:
Fix this by guarding the phy_connect_phy_id() call in phy_connect()
with uclass_get_device_by_phandle() to skip re-binding if the PHY
node is already registered in UCLASS_ETH_PHY.
Fixes: 68a4d1506109 ("net: phy: Bind ETH_PHY uclass driver to each new PHY")
Signed-off-by: Pranav Tilak <pranav.vinaytilak at amd.com>
---
Changes in v2:
- Move duplicate binding check to caller phy_connect()
- Update commit description
drivers/net/phy/phy.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d7e0c4fe02d..cfca8328f1c 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -938,8 +938,13 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
#endif
#ifdef CONFIG_PHY_ETHERNET_ID
- if (!phydev)
- phydev = phy_connect_phy_id(bus, dev, addr);
+ if (!phydev) {
+ struct udevice *phy_dev;
+
+ if (uclass_get_device_by_phandle(UCLASS_ETH_PHY, dev,
+ "phy-handle", &phy_dev))
+ phydev = phy_connect_phy_id(bus, dev, addr);
+ }
#endif
#ifdef CONFIG_PHY_XILINX_GMII2RGMII
--
2.34.1
More information about the U-Boot
mailing list