Skip to content

Commit

Permalink
PCI: PM: Rearrange pci_target_state()
Browse files Browse the repository at this point in the history
Make pci_target_state() return D3cold or D0 without checking PME
support if the current power state of the device is D3cold or if it
does not support the standard PCI PM, respectively.

Next, drop the tergat_state local variable that has become redundant
from it.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Ferry Toth <fntoth@gmail.com>
  • Loading branch information
Rafael J. Wysocki committed Oct 5, 2021
1 parent f091837 commit bf39c92
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2583,8 +2583,6 @@ EXPORT_SYMBOL(pci_wake_from_d3);
*/
static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
{
pci_power_t target_state = PCI_D3hot;

if (platform_pci_power_manageable(dev)) {
/*
* Call the platform to find the target state for the device.
Expand All @@ -2594,32 +2592,29 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
switch (state) {
case PCI_POWER_ERROR:
case PCI_UNKNOWN:
break;
return PCI_D3hot;

case PCI_D1:
case PCI_D2:
if (pci_no_d1d2(dev))
break;
fallthrough;
default:
target_state = state;
return PCI_D3hot;
}

return target_state;
return state;
}

if (!dev->pm_cap)
target_state = PCI_D0;

/*
* If the device is in D3cold even though it's not power-manageable by
* the platform, it may have been powered down by non-standard means.
* Best to let it slumber.
*/
if (dev->current_state == PCI_D3cold)
target_state = PCI_D3cold;
return PCI_D3cold;
else if (!dev->pm_cap)
return PCI_D0;

if (wakeup && dev->pme_support) {
pci_power_t state = target_state;
pci_power_t state = PCI_D3hot;

/*
* Find the deepest state from which the device can generate
Expand All @@ -2634,7 +2629,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
return PCI_D0;
}

return target_state;
return PCI_D3hot;
}

/**
Expand Down

0 comments on commit bf39c92

Please sign in to comment.