Re: [PATCH] driver core: Avoid pointless deferred probe attempts

From: Saravana Kannan
Date: Thu Feb 18 2021 - 14:18:47 EST


On Thu, Feb 18, 2021 at 9:24 AM Saravana Kannan <saravanak@xxxxxxxxxx> wrote:
>
> On Thu, Feb 18, 2021 at 9:18 AM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
> >
> > On Thu, Feb 18, 2021 at 12:51 AM Saravana Kannan <saravanak@xxxxxxxxxx> wrote:
> > >
> > > There's no point in adding a device to the deferred probe list if we
> > > know for sure that it doesn't have a matching driver. So, check if a
> > > device can match with a driver before adding it to the deferred probe
> > > list.
> >
> > What if a matching driver module loads in the meantime?
>
> Driver registration always triggers a match attempt and this flag will
> get set at that point. Yes, the user can disable autoprobe, but
> that'll block deferred probes too.
>

Btw, this can wait for 5.13. Doesn't need to go into 5.12-rcX.

> > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> > > index 9179825ff646..f18963f42e21 100644
> > > --- a/drivers/base/dd.c
> > > +++ b/drivers/base/dd.c
> > > @@ -123,6 +123,9 @@ static DECLARE_WORK(deferred_probe_work, deferred_probe_work_func);
> > >
> > > void driver_deferred_probe_add(struct device *dev)
> > > {
> > > + if (!dev->can_match)
> > > + return;
> > > +

Also, if you are worried about this check, for now, I can move it
inside device_links_driver_bound() which is the only place that
currently adds a device to the deferred probe list before the driver
is present. But it seemed like a good check in general to have in
driver_deferred_probe_add(), so I put it there.

-Saravana