Re: [PATCH 1/4] PCI: Move declaration of pci_rescan_remove_lock into public pci.h

From: Benjamin Block

Date: Fri Mar 06 2026 - 13:02:35 EST


On Fri, Mar 06, 2026 at 10:31:45AM -0700, Keith Busch wrote:
> On Fri, Mar 06, 2026 at 05:49:13PM +0100, Benjamin Block wrote:
> > So far it is possible to use and call the functions
> > pci_lock_rescan_remove() and pci_unlock_rescan_remove() from any PCI
> > code, including modules and architecture code; but the lock
> > `pci_rescan_remove_lock` itself is private to objects residing in
> > `drivers/pci/` via the header `drivers/pci/pci.h`.
> >
> > With that setup it is not possible to use lockdep annotations such as
> > lockdep_assert_held(), or sparse annotations such as __must_hold() in
> > modules or architecture code for PCI.
> >
> > Since it is useful for `pci_rescan_remove_lock` to have such
> > annotations, move the variable declaration into `include/linux/pci.h`.
>
> This big lock for pci scanning is way to easy to misuse to create
> deadlocks, many of which still exist today,

I can fully appreciate that, having had to deal with bug reports that
stem from it's use for several months at this point.

> so I'm not sure making it easier to access is the right direction.

The thing is, I really would love to be able to annotate our
architecture code where appropriate, and I didn't see any other option.
Explicit annotations in the code highlight far better than putting a
comment in the function/-header.

--
Best Regards und Beste Grüße, Benjamin Block
PGP KeyID: 9610 2BB8 2E17 6F65 2362 6DF2 46E0 4E05 67A3 2E9E