Skip to content

Commit d0c3601

Browse files
oleremkuba-moo
authored andcommitted
net: macb: Avoid 20s boot delay by skipping MDIO bus registration for fixed-link PHY
A boot delay was introduced by commit 79540d1 ("net: macb: Fix handling of fixed-link node"). This delay was caused by the call to `mdiobus_register()` in cases where a fixed-link PHY was present. The MDIO bus registration triggered unnecessary PHY address scans, leading to a 20-second delay due to attempts to detect Clause 45 (C45) compatible PHYs, despite no MDIO bus being attached. The commit 79540d1 ("net: macb: Fix handling of fixed-link node") was originally introduced to fix a regression caused by commit 7897b07 ("net: macb: convert to phylink"), which caused the driver to misinterpret fixed-link nodes as PHY nodes. This resulted in warnings like: mdio_bus f0028000.ethernet-ffffffff: fixed-link has invalid PHY address mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 0 ... mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 31 This patch reworks the logic to avoid registering and allocation of the MDIO bus when: - The device tree contains a fixed-link node. - There is no "mdio" child node in the device tree. If a child node named "mdio" exists, the MDIO bus will be registered to support PHYs attached to the MACB's MDIO bus. Otherwise, with only a fixed-link, the MDIO bus is skipped. Tested on a sama5d35 based system with a ksz8863 switch attached to macb0. Fixes: 79540d1 ("net: macb: Fix handling of fixed-link node") Signed-off-by: Oleksij Rempel <[email protected]> Cc: [email protected] Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent cf57b5d commit d0c3601

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/net/ethernet/cadence/macb_main.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,6 @@ static int macb_mdiobus_register(struct macb *bp)
930930
return ret;
931931
}
932932

933-
if (of_phy_is_fixed_link(np))
934-
return mdiobus_register(bp->mii_bus);
935-
936933
/* Only create the PHY from the device tree if at least one PHY is
937934
* described. Otherwise scan the entire MDIO bus. We do this to support
938935
* old device tree that did not follow the best practices and did not
@@ -953,8 +950,19 @@ static int macb_mdiobus_register(struct macb *bp)
953950

954951
static int macb_mii_init(struct macb *bp)
955952
{
953+
struct device_node *child, *np = bp->pdev->dev.of_node;
956954
int err = -ENXIO;
957955

956+
/* With fixed-link, we don't need to register the MDIO bus,
957+
* except if we have a child named "mdio" in the device tree.
958+
* In that case, some devices may be attached to the MACB's MDIO bus.
959+
*/
960+
child = of_get_child_by_name(np, "mdio");
961+
if (child)
962+
of_node_put(child);
963+
else if (of_phy_is_fixed_link(np))
964+
return macb_mii_probe(bp->dev);
965+
958966
/* Enable management port */
959967
macb_writel(bp, NCR, MACB_BIT(MPE));
960968

0 commit comments

Comments
 (0)