aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/pci.c21
-rw-r--r--include/linux/pci.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7325d43bf030..43d87b26ec5b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3305,8 +3305,27 @@ static void pci_dev_unlock(struct pci_dev *dev)
3305 pci_cfg_access_unlock(dev); 3305 pci_cfg_access_unlock(dev);
3306} 3306}
3307 3307
3308/**
3309 * pci_reset_notify - notify device driver of reset
3310 * @dev: device to be notified of reset
3311 * @prepare: 'true' if device is about to be reset; 'false' if reset attempt
3312 * completed
3313 *
3314 * Must be called prior to device access being disabled and after device
3315 * access is restored.
3316 */
3317static void pci_reset_notify(struct pci_dev *dev, bool prepare)
3318{
3319 const struct pci_error_handlers *err_handler =
3320 dev->driver ? dev->driver->err_handler : NULL;
3321 if (err_handler && err_handler->reset_notify)
3322 err_handler->reset_notify(dev, prepare);
3323}
3324
3308static void pci_dev_save_and_disable(struct pci_dev *dev) 3325static void pci_dev_save_and_disable(struct pci_dev *dev)
3309{ 3326{
3327 pci_reset_notify(dev, true);
3328
3310 /* 3329 /*
3311 * Wake-up device prior to save. PM registers default to D0 after 3330 * Wake-up device prior to save. PM registers default to D0 after
3312 * reset and a simple register restore doesn't reliably return 3331 * reset and a simple register restore doesn't reliably return
@@ -3328,6 +3347,7 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)
3328static void pci_dev_restore(struct pci_dev *dev) 3347static void pci_dev_restore(struct pci_dev *dev)
3329{ 3348{
3330 pci_restore_state(dev); 3349 pci_restore_state(dev);
3350 pci_reset_notify(dev, false);
3331} 3351}
3332 3352
3333static int pci_dev_reset(struct pci_dev *dev, int probe) 3353static int pci_dev_reset(struct pci_dev *dev, int probe)
@@ -3344,6 +3364,7 @@ static int pci_dev_reset(struct pci_dev *dev, int probe)
3344 3364
3345 return rc; 3365 return rc;
3346} 3366}
3367
3347/** 3368/**
3348 * __pci_reset_function - reset a PCI device function 3369 * __pci_reset_function - reset a PCI device function
3349 * @dev: PCI device to reset 3370 * @dev: PCI device to reset
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aab57b4abe7f..31c43093e538 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -603,6 +603,9 @@ struct pci_error_handlers {
603 /* PCI slot has been reset */ 603 /* PCI slot has been reset */
604 pci_ers_result_t (*slot_reset)(struct pci_dev *dev); 604 pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
605 605
606 /* PCI function reset prepare or completed */
607 void (*reset_notify)(struct pci_dev *dev, bool prepare);
608
606 /* Device driver may resume normal operations */ 609 /* Device driver may resume normal operations */
607 void (*resume)(struct pci_dev *dev); 610 void (*resume)(struct pci_dev *dev);
608}; 611};