Re: [PATCH net v1 1] net: macb: Avoid 20s boot delay by skipping MDIO bus registration for fixed-link PHY

From: Andrew Lunn
Date: Sat Oct 12 2024 - 14:15:05 EST


> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index f06babec04a0b..e4ee55bc53ba7 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -930,9 +930,6 @@ static int macb_mdiobus_register(struct macb *bp)
> return ret;
> }
>
> - if (of_phy_is_fixed_link(np))
> - return mdiobus_register(bp->mii_bus);
> -
> /* Only create the PHY from the device tree if at least one PHY is
> * described. Otherwise scan the entire MDIO bus. We do this to support
> * 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)
>
> static int macb_mii_init(struct macb *bp)
> {
> + struct device_node *child, *np = bp->pdev->dev.of_node;
> int err = -ENXIO;
>
> + /* With fixed-link, we don't need to register the MDIO bus,
> + * except if we have a child named "mdio" in the device tree.
> + * In that case, some PHYs may be attached to the MACB's MDIO bus.

nitpick. It could be a switch on the MDIO bus, so "some devices may
be"

> + */
> + child = of_get_child_by_name(np, "mdio");
> + if (child)
> + of_node_put(child);

The code now gets this node twice. You could add an optimisation patch
which passed child to macb_mdiobus_register().

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Andrew