PCI: Do not poll for PME if the device is in D3cold
authorMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 12 Jun 2019 10:57:39 +0000 (13:57 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 17 Jun 2019 23:40:41 +0000 (01:40 +0200)
commit000dd5316e1c756a1c028f22e01d06a38249dd4d
treebfbd415a0ca3620bb98be40f179b9b9959235db7
parentc2bf1fc212f7e6f25ace1af8f0b3ac061ea48ba5
PCI: Do not poll for PME if the device is in D3cold

PME polling does not take into account that a device that is directly
connected to the host bridge may go into D3cold as well. This leads to a
situation where the PME poll thread reads from a config space of a
device that is in D3cold and gets incorrect information because the
config space is not accessible.

Here is an example from Intel Ice Lake system where two PCIe root ports
are in D3cold (I've instrumented the kernel to log the PMCSR register
contents):

  [   62.971442] pcieport 0000:00:07.1: Check PME status, PMCSR=0xffff
  [   62.971504] pcieport 0000:00:07.0: Check PME status, PMCSR=0xffff

Since 0xffff is interpreted so that PME is pending, the root ports will
be runtime resumed. This repeats over and over again essentially
blocking all runtime power management.

Prevent this from happening by checking whether the device is in D3cold
before its PME status is read.

Fixes: 71a83bd727cc ("PCI/PM: add runtime PM support to PCIe port")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Cc: 3.6+ <stable@vger.kernel.org> # v3.6+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/pci/pci.c