mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Doug Anderson <dianders@chromium.org>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Saravana Kannan <saravanak@kernel.org>,
	stable@vger.kernel.org, driver-core@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] driver core: Don't link the device to the bus until we're ready to probe
Date: Sat, 21 Mar 2026 08:42:18 +0100	[thread overview]
Message-ID: <2026032114-unlocked-unmoving-091b@gregkh> (raw)
In-Reply-To: <CAD=FV=Wag5qx9RXkAHrf+zbwtQgVQW1UUc6DRhUzudBtjbD8ug@mail.gmail.com>

On Sat, Mar 21, 2026 at 12:35:32AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Fri, Mar 20, 2026 at 10:41 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Mar 20, 2026 at 08:06:58PM -0700, Douglas Anderson wrote:
> > > The moment we link a "struct device" into the list of devices for the
> > > bus, it's possible probe can happen. This is because another thread
> > > can load the driver at any time and that can cause the device to
> > > probe. This has been seen in practice with a stack crawl that looks
> > > like this [1]:
> > >
> > >   really_probe()
> > >   __driver_probe_device()
> > >   driver_probe_device()
> > >   __driver_attach()
> > >   bus_for_each_dev()
> > >   driver_attach()
> > >   bus_add_driver()
> > >   driver_register()
> > >   __platform_driver_register()
> > >   init_module() [some module]
> > >   do_one_initcall()
> > >   do_init_module()
> > >   load_module()
> > >   __arm64_sys_finit_module()
> > >   invoke_syscall()
> >
> > Are you sure this isn't just a platform bus issue?  A bus should NOT be
> > allowing a driver to be added at the same time a device is being added
> > for that bus, ideally there should be a bus-specific lock somewhere for
> > this.
> 
> Sure, if the right fix for this is somewhere in the platform bus code
> then I'd be happy with a patch there to fix it. ...but from my quick
> glance (admittedly, it's Friday night and I'm tired), it seems like
> the problem is just with driver_register() being called at the same
> time as device_add().
> 
> Certainly adding some sort of locking could be a solution (happy for
> someone to tell me where to place them), but we'd have to make sure we
> aren't regressing performance for the normal case...
> 
> 
> > When a device is added to the bus, yes, a probe can happen, and is
> > expected to happen, for that device, so this feels odd.
> >
> > that being said, your patch does seem sane, and I don't see anything
> > obviously wrong with it.  But it feels odd that this is just now showing
> > up for something that has been this way for a few decades...
> 
> I suspect it's a latent bug that was triggered by a new Android
> feature. It's showing up on phones that have
> "ro.boot.load_modules_parallel" set. I think you can get to the
> relevant source code at:
> 
> https://cs.android.com/android/platform/superproject/main/+/main:system/core/libmodprobe/libmodprobe.cpp?q=LoadModulesParallel
> 
> I suspect the bug is never triggered with more normal module loading
> schemes. Indeed, one phone that has nearly the same set of drivers but
> has parallel module loading turned off has no reports of this
> problem...

Ah, I think we always assumed that modules can NOT be loaded in
parallel, isn't there an internal module lock that prevents this from
happening?

So yes, that might be the root problem here.

> I'd also note that the only actual symptom we're seeing is with
> fw_devlink misbehaving (because dev->fwnode->dev wasn't set early
> enough). fw_devlink is a "new" (ish) feature, is officially optional,
> and isn't used on all hardware.

That's true too, can we set that earlier?

thanks,

greg k-h

  reply	other threads:[~2026-03-21  7:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21  3:06 Douglas Anderson
2026-03-21  5:41 ` Greg Kroah-Hartman
2026-03-21  7:35   ` Doug Anderson
2026-03-21  7:42     ` Greg Kroah-Hartman [this message]
2026-03-21  8:05       ` Doug Anderson
2026-03-21 15:54         ` Alan Stern
2026-03-23 17:07           ` Doug Anderson
2026-03-23 17:47             ` Alan Stern
2026-03-23 22:24               ` Doug Anderson
2026-03-24 15:21                 ` Alan Stern
2026-03-26 21:49                   ` Doug Anderson
2026-03-27 18:46                     ` Alan Stern
2026-03-27 19:30                       ` Doug Anderson
2026-03-28  1:35                         ` Alan Stern
2026-03-30 14:31                           ` Doug Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026032114-unlocked-unmoving-091b@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dakr@kernel.org \
    --cc=dianders@chromium.org \
    --cc=driver-core@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=saravanak@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®