* [PATCH v2 1/2] net: enetc: fix incorrect fallback PHY address handling
2026-03-05 3:12 [PATCH v2 0/2] net: enetc: fix fallback PHY address handling and do not skip setting for addr 0 Wei Fang
@ 2026-03-05 3:12 ` Wei Fang
2026-03-05 3:12 ` [PATCH v2 2/2] net: enetc: do not skip setting LaBCR[MDIO_PHYAD_PRTAD] for addr 0 Wei Fang
2026-03-10 10:00 ` [PATCH v2 0/2] net: enetc: fix fallback PHY address handling and do not skip setting " patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Wei Fang @ 2026-03-05 3:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni, alexander.stein
Cc: aziz.sellami, netdev, linux-kernel, imx
The current netc_get_phy_addr() implementation falls back to PHY address
0 when the "mdio" node or the PHY child node is missing. On i.MX95, this
causes failures when a real PHY is actually assigned address 0 and is
managed through the EMDIO interface. Because the bit 0 of phy_mask will
be set, leading imx95_enetc_mdio_phyaddr_config() to return an error, and
the netc_blk_ctrl driver probe subsequently fails. Fix this by returning
-ENODEV when neither an "mdio" node nor any PHY node is present, it means
that ENETC port MDIO is not used to manage the PHY, so there is no need
to configure LaBCR[MDIO_PHYAD_PRTAD].
Reported-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Closes: https://lore.kernel.org/all/7825188.GXAFRqVoOG@steina-w
Fixes: 6633df05f3ad ("net: enetc: set the external PHY address in IERB for port MDIO usage")
Reviewed-by: Clark Wang <xiaoning.wang@nxp.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
index 7fd39f895290..f0e103615e88 100644
--- a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
+++ b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
@@ -333,11 +333,13 @@ static int netc_get_phy_addr(struct device_node *np)
mdio_node = of_get_child_by_name(np, "mdio");
if (!mdio_node)
- return 0;
+ return -ENODEV;
phy_node = of_get_next_child(mdio_node, NULL);
- if (!phy_node)
+ if (!phy_node) {
+ err = -ENODEV;
goto of_put_mdio_node;
+ }
err = of_property_read_u32(phy_node, "reg", &addr);
if (err)
@@ -423,6 +425,9 @@ static int imx95_enetc_mdio_phyaddr_config(struct platform_device *pdev)
addr = netc_get_phy_addr(gchild);
if (addr < 0) {
+ if (addr == -ENODEV)
+ continue;
+
dev_err(dev, "Failed to get PHY address\n");
return addr;
}
@@ -578,6 +583,9 @@ static int imx94_enetc_mdio_phyaddr_config(struct netc_blk_ctrl *priv,
addr = netc_get_phy_addr(np);
if (addr < 0) {
+ if (addr == -ENODEV)
+ return 0;
+
dev_err(dev, "Failed to get PHY address\n");
return addr;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] net: enetc: do not skip setting LaBCR[MDIO_PHYAD_PRTAD] for addr 0
2026-03-05 3:12 [PATCH v2 0/2] net: enetc: fix fallback PHY address handling and do not skip setting for addr 0 Wei Fang
2026-03-05 3:12 ` [PATCH v2 1/2] net: enetc: fix incorrect fallback PHY address handling Wei Fang
@ 2026-03-05 3:12 ` Wei Fang
2026-03-10 10:00 ` [PATCH v2 0/2] net: enetc: fix fallback PHY address handling and do not skip setting " patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Wei Fang @ 2026-03-05 3:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni, alexander.stein
Cc: aziz.sellami, netdev, linux-kernel, imx
Given that some platforms may use PHY address 0 (I suppose the PHY may
not treat address 0 as a broadcast address or default response address).
It is possible for some boards to connect multiple PHYs to the same
ENETC MAC, for example:
- a PHY with a non-zero address connects to ENETC MAC through SGMII
interface (selected via DTS_A)
- a PHY with address 0 connects to ENETC MAC through RGMII interface
(selected via DTS_B)
For the case where the ENETC port MDIO is used to manage the PHY, when
switching from DTS_A to DTS_B via soft reboot, LaBCR[MDIO_PHYAD_PRTAD]
must be updated to 0 because the NETCMIX block is not reset during soft
reboot. However, the current driver explicitly skips configuring address
0, causing LaBCR[MDIO_PHYAD_PRTAD] to retain its old value.
Therefore, remove the special-case skip of PHY address 0 so that valid
configurations using address 0 are properly supported.
Fixes: 6633df05f3ad ("net: enetc: set the external PHY address in IERB for port MDIO usage")
Fixes: 50bfd9c06f0f ("net: enetc: set external PHY address in IERB for i.MX94 ENETC")
Reviewed-by: Clark Wang <xiaoning.wang@nxp.com>
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
index f0e103615e88..92a0f824dae7 100644
--- a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
+++ b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
@@ -438,12 +438,6 @@ static int imx95_enetc_mdio_phyaddr_config(struct platform_device *pdev)
return -EINVAL;
}
- /* The default value of LaBCR[MDIO_PHYAD_PRTAD ] is
- * 0, so no need to set the register.
- */
- if (!addr)
- continue;
-
switch (bus_devfn) {
case IMX95_ENETC0_BUS_DEVFN:
netc_reg_write(priv->ierb, IERB_LBCR(0),
@@ -590,12 +584,6 @@ static int imx94_enetc_mdio_phyaddr_config(struct netc_blk_ctrl *priv,
return addr;
}
- /* The default value of LaBCR[MDIO_PHYAD_PRTAD] is 0,
- * so no need to set the register.
- */
- if (!addr)
- return 0;
-
if (phy_mask & BIT(addr)) {
dev_err(dev,
"Find same PHY address in EMDIO and ENETC node\n");
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 0/2] net: enetc: fix fallback PHY address handling and do not skip setting for addr 0
2026-03-05 3:12 [PATCH v2 0/2] net: enetc: fix fallback PHY address handling and do not skip setting for addr 0 Wei Fang
2026-03-05 3:12 ` [PATCH v2 1/2] net: enetc: fix incorrect fallback PHY address handling Wei Fang
2026-03-05 3:12 ` [PATCH v2 2/2] net: enetc: do not skip setting LaBCR[MDIO_PHYAD_PRTAD] for addr 0 Wei Fang
@ 2026-03-10 10:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-10 10:00 UTC (permalink / raw)
To: Wei Fang
Cc: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni, alexander.stein, aziz.sellami,
netdev, linux-kernel, imx
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Thu, 5 Mar 2026 11:12:09 +0800 you wrote:
> There are two potential issues when PHY address 0 is used on the board,
> see the commit messages of the patches for more details.
>
> ---
> v2:
> 1. No functional changes, only split the v1 patch into two patches.
> 2. Collect tags.
> v1 link: https://lore.kernel.org/imx/20260303103047.228005-1-wei.fang@nxp.com/
>
> [...]
Here is the summary with links:
- [v2,1/2] net: enetc: fix incorrect fallback PHY address handling
https://git.kernel.org/netdev/net/c/246953f33e8c
- [v2,2/2] net: enetc: do not skip setting LaBCR[MDIO_PHYAD_PRTAD] for addr 0
https://git.kernel.org/netdev/net/c/dbe17e7783cb
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread