Commit 4d6035f9 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Revert "PCI: PM: Do not read power state in pci_enable_device_flags()"

Revert commit 4514d991 ("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/YNDoGICcg0V8HhpQ@eldamar.lanReported-by: default avatarMichael <phyre@rogers.com>
Reported-by: default avatarSalvatore Bonaccorso <carnil@debian.org>
Fixes: 4514d991 ("PCI: PM: Do not read power state in pci_enable_device_flags()")
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 13311e74
...@@ -1900,11 +1900,21 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags) ...@@ -1900,11 +1900,21 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
int err; int err;
int i, bars = 0; int i, bars = 0;
if (atomic_inc_return(&dev->enable_cnt) > 1) { /*
pci_update_current_state(dev, dev->current_state); * Power state could be unknown at this point, either due to a fresh
return 0; /* already enabled */ * boot or a device removal call. So get the current power state
* so that things like MSI message writing will behave as expected
* (e.g. if the device really is in D0 at enable time).
*/
if (dev->pm_cap) {
u16 pmcsr;
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
} }
if (atomic_inc_return(&dev->enable_cnt) > 1)
return 0; /* already enabled */
bridge = pci_upstream_bridge(dev); bridge = pci_upstream_bridge(dev);
if (bridge) if (bridge)
pci_enable_bridge(bridge); pci_enable_bridge(bridge);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment