]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: enetc: fix incorrect fallback PHY address handling
authorWei Fang <wei.fang@nxp.com>
Thu, 5 Mar 2026 03:12:10 +0000 (11:12 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 10 Mar 2026 09:36:46 +0000 (10:36 +0100)
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>
Link: https://patch.msgid.link/20260305031211.904812-2-wei.fang@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c

index 7fd39f89529014aa5f09378c39bfb6589f2868c6..f0e103615e884fd2243194dce9920f9578d28732 100644 (file)
@@ -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;
        }