Skip to content

Commit 4d6035f

Browse files
committed
Revert "PCI: PM: Do not read power state in pci_enable_device_flags()"
Revert commit 4514d99 ("PCI: PM: Do not read power state in pci_enable_device_flags()") that is reported to cause PCI device initialization issues on some systems. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213481 Link: https://lore.kernel.org/linux-acpi/[email protected] Reported-by: Michael <[email protected]> Reported-by: Salvatore Bonaccorso <[email protected]> Fixes: 4514d99 ("PCI: PM: Do not read power state in pci_enable_device_flags()") Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 13311e7 commit 4d6035f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

drivers/pci/pci.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,11 +1900,21 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
19001900
int err;
19011901
int i, bars = 0;
19021902

1903-
if (atomic_inc_return(&dev->enable_cnt) > 1) {
1904-
pci_update_current_state(dev, dev->current_state);
1905-
return 0; /* already enabled */
1903+
/*
1904+
* Power state could be unknown at this point, either due to a fresh
1905+
* boot or a device removal call. So get the current power state
1906+
* so that things like MSI message writing will behave as expected
1907+
* (e.g. if the device really is in D0 at enable time).
1908+
*/
1909+
if (dev->pm_cap) {
1910+
u16 pmcsr;
1911+
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
1912+
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
19061913
}
19071914

1915+
if (atomic_inc_return(&dev->enable_cnt) > 1)
1916+
return 0; /* already enabled */
1917+
19081918
bridge = pci_upstream_bridge(dev);
19091919
if (bridge)
19101920
pci_enable_bridge(bridge);

0 commit comments

Comments
 (0)