diff options
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a4ecc2f15126..979ceb1d37e8 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -439,6 +439,10 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
439 | u16 pmcsr; | 439 | u16 pmcsr; |
440 | bool need_restore = false; | 440 | bool need_restore = false; |
441 | 441 | ||
442 | /* Check if we're already there */ | ||
443 | if (dev->current_state == state) | ||
444 | return 0; | ||
445 | |||
442 | if (!dev->pm_cap) | 446 | if (!dev->pm_cap) |
443 | return -EIO; | 447 | return -EIO; |
444 | 448 | ||
@@ -449,10 +453,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
449 | * Can enter D0 from any state, but if we can only go deeper | 453 | * Can enter D0 from any state, but if we can only go deeper |
450 | * to sleep if we're already in a low power state | 454 | * to sleep if we're already in a low power state |
451 | */ | 455 | */ |
452 | if (dev->current_state == state) { | 456 | if (state != PCI_D0 && dev->current_state <= PCI_D3cold |
453 | /* we're already there */ | ||
454 | return 0; | ||
455 | } else if (state != PCI_D0 && dev->current_state <= PCI_D3cold | ||
456 | && dev->current_state > state) { | 457 | && dev->current_state > state) { |
457 | dev_err(&dev->dev, "invalid power transition " | 458 | dev_err(&dev->dev, "invalid power transition " |
458 | "(from state %d to %d)\n", dev->current_state, state); | 459 | "(from state %d to %d)\n", dev->current_state, state); |
@@ -570,12 +571,17 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
570 | */ | 571 | */ |
571 | return 0; | 572 | return 0; |
572 | 573 | ||
573 | if (state == PCI_D0 && platform_pci_power_manageable(dev)) { | 574 | /* Check if we're already there */ |
575 | if (dev->current_state == state) | ||
576 | return 0; | ||
577 | |||
578 | if (state == PCI_D0) { | ||
574 | /* | 579 | /* |
575 | * Allow the platform to change the state, for example via ACPI | 580 | * Allow the platform to change the state, for example via ACPI |
576 | * _PR0, _PS0 and some such, but do not trust it. | 581 | * _PR0, _PS0 and some such, but do not trust it. |
577 | */ | 582 | */ |
578 | int ret = platform_pci_set_power_state(dev, PCI_D0); | 583 | int ret = platform_pci_power_manageable(dev) ? |
584 | platform_pci_set_power_state(dev, PCI_D0) : 0; | ||
579 | if (!ret) | 585 | if (!ret) |
580 | pci_update_current_state(dev, PCI_D0); | 586 | pci_update_current_state(dev, PCI_D0); |
581 | } | 587 | } |