Skip to content

Commit 95cddea

Browse files
committed
Merge branch 'pci/pm'
- Only read PCI_PM_CTRL register when available, to avoid reading the wrong register and corrupting dev->current_state (Feiyang Chen) * pci/pm: PCI/PM: Only read PCI_PM_CTRL register when available
2 parents 8b52451 + 5694ba1 commit 95cddea

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/pci/pci.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,10 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)
12261226
*
12271227
* On success, return 0 or 1, depending on whether or not it is necessary to
12281228
* restore the device's BARs subsequently (1 is returned in that case).
1229+
*
1230+
* On failure, return a negative error code. Always return failure if @dev
1231+
* lacks a Power Management Capability, even if the platform was able to
1232+
* put the device in D0 via non-PCI means.
12291233
*/
12301234
int pci_power_up(struct pci_dev *dev)
12311235
{
@@ -1242,9 +1246,6 @@ int pci_power_up(struct pci_dev *dev)
12421246
else
12431247
dev->current_state = state;
12441248

1245-
if (state == PCI_D0)
1246-
return 0;
1247-
12481249
return -EIO;
12491250
}
12501251

@@ -1302,8 +1303,12 @@ static int pci_set_full_power_state(struct pci_dev *dev)
13021303
int ret;
13031304

13041305
ret = pci_power_up(dev);
1305-
if (ret < 0)
1306+
if (ret < 0) {
1307+
if (dev->current_state == PCI_D0)
1308+
return 0;
1309+
13061310
return ret;
1311+
}
13071312

13081313
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
13091314
dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK;

0 commit comments

Comments
 (0)