aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 9de07b75b993..ab1d615425a8 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -370,6 +370,7 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
370 } 370 }
371 371
372 pci_save_state(pci_dev); 372 pci_save_state(pci_dev);
373 pci_dev->state_saved = true;
373 /* 374 /*
374 * This is for compatibility with existing code with legacy PM support. 375 * This is for compatibility with existing code with legacy PM support.
375 */ 376 */
@@ -419,6 +420,7 @@ static int pci_legacy_resume(struct device *dev)
419static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev) 420static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
420{ 421{
421 pci_restore_standard_config(pci_dev); 422 pci_restore_standard_config(pci_dev);
423 pci_dev->state_saved = false;
422 pci_fixup_device(pci_fixup_resume_early, pci_dev); 424 pci_fixup_device(pci_fixup_resume_early, pci_dev);
423} 425}
424 426
@@ -555,6 +557,13 @@ static int pci_pm_resume(struct device *dev)
555 struct device_driver *drv = dev->driver; 557 struct device_driver *drv = dev->driver;
556 int error = 0; 558 int error = 0;
557 559
560 /*
561 * This is necessary for the suspend error path in which resume is
562 * called without restoring the standard config registers of the device.
563 */
564 if (pci_dev->state_saved)
565 pci_restore_standard_config(pci_dev);
566
558 if (pci_has_legacy_pm_support(pci_dev)) 567 if (pci_has_legacy_pm_support(pci_dev))
559 return pci_legacy_resume(dev); 568 return pci_legacy_resume(dev);
560 569
@@ -660,7 +669,10 @@ static int pci_pm_poweroff(struct device *dev)
660 if (pci_has_legacy_pm_support(pci_dev)) 669 if (pci_has_legacy_pm_support(pci_dev))
661 return pci_legacy_suspend(dev, PMSG_HIBERNATE); 670 return pci_legacy_suspend(dev, PMSG_HIBERNATE);
662 671
663 if (drv && drv->pm && drv->pm->poweroff) { 672 if (!drv || !drv->pm)
673 return 0;
674
675 if (drv->pm->poweroff) {
664 error = drv->pm->poweroff(dev); 676 error = drv->pm->poweroff(dev);
665 suspend_report_result(drv->pm->poweroff, error); 677 suspend_report_result(drv->pm->poweroff, error);
666 } 678 }
@@ -710,6 +722,13 @@ static int pci_pm_restore(struct device *dev)
710 struct device_driver *drv = dev->driver; 722 struct device_driver *drv = dev->driver;
711 int error = 0; 723 int error = 0;
712 724
725 /*
726 * This is necessary for the hibernation error path in which restore is
727 * called without restoring the standard config registers of the device.
728 */
729 if (pci_dev->state_saved)
730 pci_restore_standard_config(pci_dev);
731
713 if (pci_has_legacy_pm_support(pci_dev)) 732 if (pci_has_legacy_pm_support(pci_dev))
714 return pci_legacy_resume(dev); 733 return pci_legacy_resume(dev);
715 734