Skip to contentSkip to conversation

net: phy: ethernet_id: fix duplicate eth_phy binding

PATCH Superseded Pranav Tilak 2 participants 3 messages Apr 6 – Apr 7

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: ethernet_id: fix duplicate eth_phy binding

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 bind/probe block in phy_connect_phy_id() with uclass_get_device_by_ofnode() 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")
---
 drivers/net/phy/ethernet_id.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/phy/ethernet_id.c +3 -1
index 2f8454ca27d..7b232ab37f6 100644
@@ -8,6 +8,7 @@
 #include <dm/device_compat.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <dm/uclass.h>
 #include <phy.h>
 #include <linux/delay.h>
 #include <asm/gpio.h>
@@ -51,7 +52,8 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
 	if (phydev)
 		phydev->node = node;
 
-	if (IS_ENABLED(CONFIG_DM_ETH_PHY) && ofnode_valid(node)) {
+	if (IS_ENABLED(CONFIG_DM_ETH_PHY) && ofnode_valid(node) &&
+	    uclass_get_device_by_ofnode(UCLASS_ETH_PHY, node, &pdev)) {
 		node_name = ofnode_get_name(node);
 		ret = device_bind_driver_to_node(dev, "eth_phy_generic_drv",
 						 node_name, node,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 10 lines · Pranav Tilak

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 bind/probe block in phy_connect_phy_id() with uclass_get_device_by_ofnode() to skip re-binding if the PHY node is already registered in UCLASS_ETH_PHY.

Shouldn't phy_connect() check whether the PHY isn't already bound and bail early if it is ?

#2 lore raw

[Public]

Hi @Marek Vasut,

Quoted 20 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Monday, April 6, 2026 9:35 PM
To: Vinay Tilak, Pranav <[email protected]>; [email protected]; Simek, Michal <[email protected]>
Cc: git (AMD-Xilinx) <[email protected]>; Begari, Padmarao <[email protected]>; Jerome Forissier <[email protected]>; Tom Rini <[email protected]>; Marek Vasut <[email protected]>; Ramon Fried <[email protected]>
Subject: Re: [PATCH] net: phy: ethernet_id: fix duplicate eth_phy binding

Quoted 1 line · Pranav Tilak

When both CONFIG_PHY_ETHERNET_ID and CONFIG_DM_ETH_PHY are

enabled,

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

Fix this by guarding the bind/probe block in phy_connect_phy_id() with uclass_get_device_by_ofnode() to skip re-binding if the PHY node is already registered in UCLASS_ETH_PHY.

Shouldn't phy_connect() check whether the PHY isn't already bound and bail early if it is ?

Yes, i checked we can move the duplicate binding check from phy_connect_phy_id() to its caller in phy_connect() and using uclass_get_device_by_phandle() to skip re-binding if the PHY node is already registered in UCLASS_ETH_PHY. Will update in v2.

Thanks,
Pranav Tilak.