[PATCH 2/2] PCI: Fix missing lockdep annotation for pci_cfg_access_trylock()
Imre Deak
imre.deak at intel.com
Wed May 29 14:07:22 UTC 2024
From: Dan Williams <dan.j.williams at intel.com>
Alex reports a new vfio-pci lockdep warning resulting from the
cfg_access_lock lock_map added recently.
Add the missing annotation to pci_cfg_access_trylock() and adjust the
lock_map acquisition to be symmetrical relative to pci_lock.
Fixes: 7e89efc6e9e4 ("PCI: Lock upstream bridge for pci_reset_function()")
Reported-by: Alex Williamson <alex.williamson at redhat.com>
Closes: http://lore.kernel.org/r/20240523131005.5578e3de.alex.williamson@redhat.com
Tested-by: Alex Williamson <alex.williamson at redhat.com>
Cc: Dave Jiang <dave.jiang at intel.com>
Cc: Bjorn Helgaas <bhelgaas at google.com>
Signed-off-by: Dan Williams <dan.j.williams at intel.com>
Reviewed-by: Dave Jiang <dave.jiang at intel.com>
---
drivers/pci/access.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 30f031de9cfe8..3595130ff719d 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -289,11 +289,10 @@ void pci_cfg_access_lock(struct pci_dev *dev)
{
might_sleep();
- lock_map_acquire(&dev->cfg_access_lock);
-
raw_spin_lock_irq(&pci_lock);
if (dev->block_cfg_access)
pci_wait_cfg(dev);
+ lock_map_acquire(&dev->cfg_access_lock);
dev->block_cfg_access = 1;
raw_spin_unlock_irq(&pci_lock);
}
@@ -315,8 +314,10 @@ bool pci_cfg_access_trylock(struct pci_dev *dev)
raw_spin_lock_irqsave(&pci_lock, flags);
if (dev->block_cfg_access)
locked = false;
- else
+ else {
+ lock_map_acquire(&dev->cfg_access_lock);
dev->block_cfg_access = 1;
+ }
raw_spin_unlock_irqrestore(&pci_lock, flags);
return locked;
@@ -342,11 +343,10 @@ void pci_cfg_access_unlock(struct pci_dev *dev)
WARN_ON(!dev->block_cfg_access);
dev->block_cfg_access = 0;
- raw_spin_unlock_irqrestore(&pci_lock, flags);
-
- wake_up_all(&pci_cfg_wait);
-
lock_map_release(&dev->cfg_access_lock);
+ raw_spin_unlock_irqrestore(&pci_lock, flags);
+
+ wake_up_all(&pci_cfg_wait);
}
EXPORT_SYMBOL_GPL(pci_cfg_access_unlock);
--
2.43.3
More information about the Intel-gfx-trybot
mailing list