Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Mario Peter <mario.peter@leica-geosystems.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	driver-core@lists.linux.dev, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] driver core: Take parent lock in async device attach
Date: Mon, 12 Oct 2026 14:50:02 +0200	[thread overview]
Message-ID: <aszXeki0LK1LYL6P@hovoldconsulting.com> (raw)
In-Reply-To: <20261007131514.1260696-1-mario.peter@leica-geosystems.com>

On Wed, Oct 07, 2026 at 01:15:14PM +0000, Mario Peter wrote:
> On buses with need_parent_lock set (only USB), probe() must run with the
> parent device locked. A synchronous attach after device_add() gets this
> from the caller, e.g. usb_set_configuration() holds the udev lock while
> adding interfaces. __device_attach_async_helper() runs the probe from an
> async worker instead, where that lock isn't held, and only takes
> device_lock(dev).

> Take the parent lock in __device_attach_async_helper() as well, like
> __driver_attach_async_helper() does, and move
> __device_driver_lock/unlock() up for that. With this the warning was
> gone in 300 boots on the board and in 6000 iterations in QEMU.
> 
> Fixes: 765230b5f084 ("driver-core: add asynchronous probing support for drivers")
> Assisted-by: LLM
> Signed-off-by: Mario Peter <mario.peter@leica-geosystems.com>
> ---
> v2:
> - Describe the race in more detail
> - Keep the multi-TT detail, but say why the hub has to be multi-TT
>   for this symptom
> - Reproduce and test on v7.3-rc6 in QEMU
> 
> In the same QEMU setup, a debug-only device_lock_assert(&udev->dev) in
> usb_probe_interface() fired on every async probe of a hub interface
> without this patch (52 of 52) and never with it (0 of 102). The hub
> emulator and the test scripts are small, I can post them if that helps.

Thanks for fixing this, USB interfaces should indeed always be probed
with the parent lock held:

Reviewed-by: Johan Hovold <johan@kernel.org>

I believe we want this in stable too:

Cc: stable@vger.kernel.org

> Not covered: deferred_probe_work_func() also re-probes via
> __device_attach() without the parent lock.

Thanks for reporting this as well. I've started preparing a patch to
address it.

Johan

  reply	other threads:[~2026-10-12 12:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 13:15 [PATCH v2] driver core: Take parent lock in async device attach Mario Peter
2026-10-12 12:50 ` Johan Hovold [this message]
2026-10-12 14:13   ` Danilo Krummrich
2026-10-12 15:12     ` Johan Hovold

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=aszXeki0LK1LYL6P@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=dakr@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mario.peter@leica-geosystems.com \
    --cc=rafael@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