Re: [PATCH] driver core: take parent lock on deferred probe

From: Johan Hovold

Date: Thu Oct 15 2026 - 02:50:24 EST


On Thu, Oct 15, 2026 at 12:40:42AM +0200, Danilo Krummrich wrote:
> On Wed Oct 14, 2026 at 5:14 PM CEST, Johan Hovold wrote:
> > On Wed, Oct 14, 2026 at 04:42:09PM +0200, Danilo Krummrich wrote:

> > I understand your concern, but my reasoning is that this feature is only
> > needed when devices are tightly coupled with their parents and where it
> > therefore probably always make sense to pin the parent.
> >
> > Note that the need_parent_lock flag is now set in the device type struct
> > which also holds a pointer to the release function that drops the
> > reference. So it's pretty easy to check any theoretical further users.
> >
> >> Please, let's not add this API contract. Let's have the driver core deal with
> >> this internally.
> >
> > I can take another look at it, but the alternatives seemed either error
> > prone or a bit icky (e.g. a helper that returns a reference to the
> > parent after checking the dead flag under the device lock).
>
> I thought some more about this, and since it is only the USB device type using
> it it's probably fine for now. Should we ever gain new users of this API (which
> I do not hope), we can still change it and add something like the diff below.

Sounds good. It was variations of your two diffs that I had in mind as
well.

> I'd suggest to also add a comment in the USB code, explaining that this
> reference count (also) serves the purpose to fulfill the driver core API
> contract.

Sure, I'll do that.

Johan