Skip to content

Commit 60e7b5a

Browse files
niklas88bjorn-helgaas
authored andcommitted
PCI: Add lockdep assertion in pci_stop_and_remove_bus_device()
Removing a PCI devices requires holding pci_rescan_remove_lock. Prompted by this being missed in sriov_disable() and going unnoticed since its inception, add a lockdep assert so this doesn't get missed again in the future. Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Benjamin Block <bblock@linux.ibm.com> Reviewed-by: Julian Ruess <julianr@linux.ibm.com> Link: https://patch.msgid.link/20250826-pci_fix_sriov_disable-v1-2-2d0bc938f2a3@linux.ibm.com
1 parent 0570327 commit 60e7b5a

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/pci/pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ struct pcie_tlp_log;
8484
extern const unsigned char pcie_link_speed[];
8585
extern bool pci_early_dump;
8686

87+
extern struct mutex pci_rescan_remove_lock;
88+
8789
bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
8890
bool pcie_cap_has_lnkctl2(const struct pci_dev *dev);
8991
bool pcie_cap_has_rtctl(const struct pci_dev *dev);

drivers/pci/probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3469,7 +3469,7 @@ EXPORT_SYMBOL_GPL(pci_rescan_bus);
34693469
* pci_rescan_bus(), pci_rescan_bus_bridge_resize() and PCI device removal
34703470
* routines should always be executed under this mutex.
34713471
*/
3472-
static DEFINE_MUTEX(pci_rescan_remove_lock);
3472+
DEFINE_MUTEX(pci_rescan_remove_lock);
34733473

34743474
void pci_lock_rescan_remove(void)
34753475
{

drivers/pci/remove.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static void pci_remove_bus_device(struct pci_dev *dev)
138138
*/
139139
void pci_stop_and_remove_bus_device(struct pci_dev *dev)
140140
{
141+
lockdep_assert_held(&pci_rescan_remove_lock);
141142
pci_stop_bus_device(dev);
142143
pci_remove_bus_device(dev);
143144
}

0 commit comments

Comments
 (0)