@@ -4819,13 +4819,19 @@ int pci_reset_function(struct pci_dev *dev, u32 reset_type)
if (!dev->reset_fn)
return -ENOTTY;
- pci_dev_lock(dev);
- pci_dev_save_and_disable(dev);
+ if (!(reset_type & PCI_RESET_ALREADYLOCKED))
+ pci_dev_lock(dev);
+
+ if (!(reset_type & PCI_RESET_NOSAVERESTORE))
+ pci_dev_save_and_disable(dev);
rc = __pci_reset_function_locked(dev, reset_type);
- pci_dev_restore(dev);
- pci_dev_unlock(dev);
+ if (!(reset_type & PCI_RESET_NOSAVERESTORE))
+ pci_dev_restore(dev);
+
+ if (!(reset_type & PCI_RESET_ALREADYLOCKED))
+ pci_dev_unlock(dev);
return rc;
}
@@ -896,6 +896,9 @@ enum {
*
* PCI_RESET_NOSAVERESTORE tells the PCI core to not save the card context
* before performing a reset and restore the values after reset.
+ *
+ * PCI_RESET_ALREADYLOCKED indicates that caller is holding the device lock and
+ * PCI core should not try to lock again.
*/
#define PCI_RESET_DEV_SPECIFIC (1 << 0)
#define PCI_RESET_FLR (1 << 1)
@@ -903,6 +906,7 @@ enum {
#define PCI_RESET_SLOT (1 << 3)
#define PCI_RESET_BUS (1 << 4)
#define PCI_RESET_NOSAVERESTORE (1 << 5)
+#define PCI_RESET_ALREADYLOCKED (1 << 6)
#define PCI_RESET_FUNC (PCI_RESET_DEV_SPECIFIC | \
PCI_RESET_FLR | PCI_RESET_PM)
Getting ready to deprecate pci_reset_function_locked(). Add saverestore and locked parameters to pci_reset_function() function and add saverestore = true and locked = false to all existing callers. Signed-off-by: Sinan Kaya <okaya@kernel.org> --- drivers/pci/pci.c | 14 ++++++++++---- include/linux/pci.h | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-)