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

From: Keith Busch

Date: Fri Mar 06 2026 - 12:39:22 EST


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, so I'm not sure making it
easier to access is the right direction.