public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pranav Tilak <pranav.vinaytilak@amd.com>
To: <u-boot@lists.denx.de>, <michal.simek@amd.com>
Cc: <git@amd.com>, <padmarao.begari@amd.com>,
	<marek.vasut@mailbox.org>,
	Pranav Tilak <pranav.vinaytilak@amd.com>,
	Jerome Forissier <jerome.forissier@arm.com>,
	Tom Rini <trini@konsulko.com>, Peng Fan <peng.fan@nxp.com>,
	Lucien.Jheng <lucienzx159@gmail.com>, Yao Zi <me@ziyao.cc>,
	SkyLake.Huang <skylake.huang@mediatek.com>,
	"Siddharth Vadapalli" <s-vadapalli@ti.com>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Ramon Fried <rfried.dev@gmail.com>
Subject: [PATCH v2] net: phy: fix duplicate eth_phy binding
Date: Wed, 8 Apr 2026 14:28:12 +0530	[thread overview]
Message-ID: <20260408085844.2942463-1-pranav.vinaytilak@amd.com> (raw)

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@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


             reply	other threads:[~2026-04-08  8:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08  8:58 Pranav Tilak [this message]
2026-04-08 16:31 ` [PATCH v2] net: phy: fix duplicate eth_phy binding Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260408085844.2942463-1-pranav.vinaytilak@amd.com \
    --to=pranav.vinaytilak@amd.com \
    --cc=git@amd.com \
    --cc=jerome.forissier@arm.com \
    --cc=lucienzx159@gmail.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=marek.vasut@mailbox.org \
    --cc=me@ziyao.cc \
    --cc=michal.simek@amd.com \
    --cc=padmarao.begari@amd.com \
    --cc=peng.fan@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=s-vadapalli@ti.com \
    --cc=skylake.huang@mediatek.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox