diff options
| author | Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | 2026-01-16 14:57:41 +0200 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2026-02-06 16:53:57 -0600 |
| commit | f06e0ad226fdb875cfd6278882ef28fe817283c5 (patch) | |
| tree | 13275dbcfebbca95add7d01fadb77e24cce8816f | |
| parent | 183c291caa34cc1e721a571058a3f972c5b35122 (diff) | |
| download | linux-f06e0ad226fdb875cfd6278882ef28fe817283c5.tar.gz linux-f06e0ad226fdb875cfd6278882ef28fe817283c5.zip | |
PCI: Use device_lock_assert() to verify device lock is held
Multiple function comments say the function should be called with
device_lock held. Check that by calling device_lock_assert().
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260116125742.1890-3-ilpo.jarvinen@linux.intel.com
| -rw-r--r-- | drivers/pci/pci.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index edcc22dc95d3..5c109f62eb4a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4970,6 +4970,7 @@ static void pci_dev_save_and_disable(struct pci_dev *dev) * races with ->remove() by the device lock, which must be held by * the caller. */ + device_lock_assert(&dev->dev); if (err_handler && err_handler->reset_prepare) err_handler->reset_prepare(dev); else if (dev->driver) @@ -5040,7 +5041,9 @@ const struct pci_reset_fn_method pci_reset_fn_methods[] = { * device including MSI, bus mastering, BARs, decoding IO and memory spaces, * etc. * - * Returns 0 if the device function was successfully reset or negative if the + * Context: The caller must hold the device lock. + * + * Return: 0 if the device function was successfully reset or negative if the * device doesn't support resetting a single function. */ int __pci_reset_function_locked(struct pci_dev *dev) @@ -5049,6 +5052,7 @@ int __pci_reset_function_locked(struct pci_dev *dev) const struct pci_reset_fn_method *method; might_sleep(); + device_lock_assert(&dev->dev); /* * A reset method returns -ENOTTY if it doesn't support this device and @@ -5171,13 +5175,17 @@ EXPORT_SYMBOL_GPL(pci_reset_function); * over the reset. It also differs from pci_reset_function() in that it * requires the PCI device lock to be held. * - * Returns 0 if the device function was successfully reset or negative if the + * Context: The caller must hold the device lock. + * + * Return: 0 if the device function was successfully reset or negative if the * device doesn't support resetting a single function. */ int pci_reset_function_locked(struct pci_dev *dev) { int rc; + device_lock_assert(&dev->dev); + if (!pci_reset_supported(dev)) return -ENOTTY; |
