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@xxxxxxxxxx> --- drivers/pci/pci.c | 14 ++++++++++---- include/linux/pci.h | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ccd69f5d01f3..17b10c33cb53 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -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; } diff --git a/include/linux/pci.h b/include/linux/pci.h index fedd34a5af77..ad5996d521eb 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -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) -- 2.19.0