Re: [PATCH] driver core: Prevent deferred probe loops

From: Sean Anderson
Date: Tue Jun 10 2025 - 19:44:49 EST


On 6/10/25 19:32, Saravana Kannan wrote:
> On Tue, Jun 10, 2025 at 11:35 AM Sean Anderson <sean.anderson@xxxxxxxxx> wrote:
>>
>> A deferred probe loop can occur when a device returns EPROBE_DEFER after
>> registering a bus with children:
>
> This is a broken driver. A parent device shouldn't register child
> devices unless it is fully read itself. It's not logical to say the
> child devices are available, if the parent itself isn't fully ready.
> So, adding child devices/the bus should be the last thing done in the
> parent's probe function.
>
> I know there are odd exceptions where the parent depends on the child,
> so they might add the child a bit earlier in the probe

This is exactly the case here. So the bus probing cannot happen any
later than it already does.

> but in those cases, the parent's probe should still do all the checks
> ahead of time.

Such as what? How is the parent going to know the resource is missing
without checking for it?

> Can you be more specific about the actual failure you are seeing?

MAC is looking for a PCS that's on its internal MDIO bus, but that PCS's
driver isn't loaded. The PCS has to be loaded at probe time because
phylink_create needs it, and phylink is necessary to register the
netdev. The latter situation is not ideal, but it would be quite a bit
of work to untangle.

--Sean