aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2009-01-07 07:03:42 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-01-07 14:14:40 -0500
commitfa58d305d9925b01830e535896a7227a868a9e15 (patch)
tree6b0509663958c9fc6c3b201e6a3b061af784ffa9 /drivers/pci/pci-driver.c
parentc9b9972b3c88272be02d971346285d1c67fbb95f (diff)
PCI PM: Add suspend counterpart of pci_reenable_device
PCI devices without drivers are not disabled during suspend and hibernation, but they are enabled during resume, with the help of pci_reenable_device(), so there is an unbalanced execution of pcibios_enable_device() in the resume code path. To correct this introduce function pci_disable_enabled_device() that will disable the argument device, if it is enabled when the function is being run, without updating the device's pci_dev structure and use it in the suspend code path to balance the pci_reenable_device() executed during resume. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 23bdf64411e5..57cb0015a470 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -324,9 +324,19 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
324 324
325/* 325/*
326 * Default "suspend" method for devices that have no driver provided suspend, 326 * Default "suspend" method for devices that have no driver provided suspend,
327 * or not even a driver at all. 327 * or not even a driver at all (first part).
328 */
329static void pci_default_pm_suspend_early(struct pci_dev *pci_dev)
330{
331 /* If device is enabled at this point, disable it */
332 pci_disable_enabled_device(pci_dev);
333}
334
335/*
336 * Default "suspend" method for devices that have no driver provided suspend,
337 * or not even a driver at all (second part).
328 */ 338 */
329static void pci_default_pm_suspend(struct pci_dev *pci_dev) 339static void pci_default_pm_suspend_late(struct pci_dev *pci_dev)
330{ 340{
331 pci_save_state(pci_dev); 341 pci_save_state(pci_dev);
332 /* 342 /*
@@ -377,7 +387,11 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
377 i = drv->suspend(pci_dev, state); 387 i = drv->suspend(pci_dev, state);
378 suspend_report_result(drv->suspend, i); 388 suspend_report_result(drv->suspend, i);
379 } else { 389 } else {
380 pci_default_pm_suspend(pci_dev); 390 /*
391 * For compatibility with existing code with legacy PM support
392 * don't call pci_default_pm_suspend_early() here.
393 */
394 pci_default_pm_suspend_late(pci_dev);
381 } 395 }
382 return i; 396 return i;
383} 397}
@@ -455,7 +469,10 @@ static int pci_pm_suspend(struct device *dev)
455 } 469 }
456 } else if (pci_has_legacy_pm_support(pci_dev)) { 470 } else if (pci_has_legacy_pm_support(pci_dev)) {
457 error = pci_legacy_suspend(dev, PMSG_SUSPEND); 471 error = pci_legacy_suspend(dev, PMSG_SUSPEND);
472 } else {
473 pci_default_pm_suspend_early(pci_dev);
458 } 474 }
475
459 pci_fixup_device(pci_fixup_suspend, pci_dev); 476 pci_fixup_device(pci_fixup_suspend, pci_dev);
460 477
461 return error; 478 return error;
@@ -475,7 +492,7 @@ static int pci_pm_suspend_noirq(struct device *dev)
475 } else if (pci_has_legacy_pm_support(pci_dev)) { 492 } else if (pci_has_legacy_pm_support(pci_dev)) {
476 error = pci_legacy_suspend_late(dev, PMSG_SUSPEND); 493 error = pci_legacy_suspend_late(dev, PMSG_SUSPEND);
477 } else { 494 } else {
478 pci_default_pm_suspend(pci_dev); 495 pci_default_pm_suspend_late(pci_dev);
479 } 496 }
480 497
481 return error; 498 return error;
@@ -546,6 +563,8 @@ static int pci_pm_freeze(struct device *dev)
546 } else if (pci_has_legacy_pm_support(pci_dev)) { 563 } else if (pci_has_legacy_pm_support(pci_dev)) {
547 error = pci_legacy_suspend(dev, PMSG_FREEZE); 564 error = pci_legacy_suspend(dev, PMSG_FREEZE);
548 pci_fixup_device(pci_fixup_suspend, pci_dev); 565 pci_fixup_device(pci_fixup_suspend, pci_dev);
566 } else {
567 pci_default_pm_suspend_early(pci_dev);
549 } 568 }
550 569
551 return error; 570 return error;
@@ -565,7 +584,7 @@ static int pci_pm_freeze_noirq(struct device *dev)
565 } else if (pci_has_legacy_pm_support(pci_dev)) { 584 } else if (pci_has_legacy_pm_support(pci_dev)) {
566 error = pci_legacy_suspend_late(dev, PMSG_FREEZE); 585 error = pci_legacy_suspend_late(dev, PMSG_FREEZE);
567 } else { 586 } else {
568 pci_default_pm_suspend(pci_dev); 587 pci_default_pm_suspend_late(pci_dev);
569 } 588 }
570 589
571 return error; 590 return error;
@@ -583,6 +602,8 @@ static int pci_pm_thaw(struct device *dev)
583 } else if (pci_has_legacy_pm_support(pci_dev)) { 602 } else if (pci_has_legacy_pm_support(pci_dev)) {
584 pci_fixup_device(pci_fixup_resume, pci_dev); 603 pci_fixup_device(pci_fixup_resume, pci_dev);
585 error = pci_legacy_resume(dev); 604 error = pci_legacy_resume(dev);
605 } else {
606 pci_default_pm_resume_late(pci_dev);
586 } 607 }
587 608
588 return error; 609 return error;
@@ -600,6 +621,8 @@ static int pci_pm_thaw_noirq(struct device *dev)
600 } else if (pci_has_legacy_pm_support(pci_dev)) { 621 } else if (pci_has_legacy_pm_support(pci_dev)) {
601 pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev)); 622 pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev));
602 error = pci_legacy_resume_early(dev); 623 error = pci_legacy_resume_early(dev);
624 } else {
625 pci_default_pm_resume_early(pci_dev);
603 } 626 }
604 627
605 return error; 628 return error;
@@ -618,6 +641,8 @@ static int pci_pm_poweroff(struct device *dev)
618 } 641 }
619 } else if (pci_has_legacy_pm_support(pci_dev)) { 642 } else if (pci_has_legacy_pm_support(pci_dev)) {
620 error = pci_legacy_suspend(dev, PMSG_HIBERNATE); 643 error = pci_legacy_suspend(dev, PMSG_HIBERNATE);
644 } else {
645 pci_default_pm_suspend_early(pci_dev);
621 } 646 }
622 647
623 pci_fixup_device(pci_fixup_suspend, pci_dev); 648 pci_fixup_device(pci_fixup_suspend, pci_dev);