2024-06-13 22:02:34

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH] fec_main: Register net device before initializing the MDIO bus

On Thu, Jun 13, 2024 at 04:41:11PM +0200, Paul Geurts wrote:
> Registration of the FEC MDIO bus triggers a probe of all devices
> connected to that bus. DSA based Ethernet switch devices connect to the
> uplink Ethernet port during probe. When a DSA based, MDIO controlled
> Ethernet switch is connected to FEC, it cannot connect the uplink port,
> as the FEC MDIO port is registered before the net device is being
> registered. This causes an unnecessary defer of the Ethernet switch
> driver probe.
>
> Register the net device before initializing and registering the MDIO
> bus.

The problem with this is, as soon as you call register_netdev(), the
device is alive and sending packets. It can be sending packets even
before register_netdev() returns, e.g. in the case of NFS root. So
fec_enet_open() gets called, and tried to find its PHY. But the MDIO
bus is not registered yet....

So yes, DSA ends up doing an EPROBE_DEFER cycle. Not much we can do
about that. We can try to keep the DSA probe functions as cheap as
possible, and put all the expensive stuff in setup(), which will only
be called once we have all the needed resources.

Andrew

---
pw-bot: cr