Commit 97a90aee authored by Lukas Wunner's avatar Lukas Wunner Committed by Bjorn Helgaas

PCI: Consolidate conditions to allow runtime PM on PCIe ports

The conditions to allow runtime PM on PCIe ports are currently spread
across two different files:  The condition relating to hotplug ports is
located in portdrv_pci.c whereas all other conditions are located in pci.c.

Consolidate all conditions in a single place in pci.c, thus making it
easier to follow the logic and amend conditions down the road.

Note that the condition relating to hotplug ports is inserted *before* the
condition relating to the "pcie_port_pm=force" command line option, so
runtime PM is not afforded to hotplug ports even if this option is given.
That's exactly how the code behaved up until now.  If this is not desired,
the ordering of the conditions can simply be reversed.

No functional change intended.
Tested-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent c6a63307
...@@ -2243,6 +2243,17 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) ...@@ -2243,6 +2243,17 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
case PCI_EXP_TYPE_DOWNSTREAM: case PCI_EXP_TYPE_DOWNSTREAM:
if (pci_bridge_d3_disable) if (pci_bridge_d3_disable)
return false; return false;
/*
* Hotplug interrupts cannot be delivered if the link is down,
* so parents of a hotplug port must stay awake. In addition,
* hotplug ports handled by firmware in System Management Mode
* may not be put into D3 by the OS (Thunderbolt on non-Macs).
* For simplicity, disallow in general for now.
*/
if (bridge->is_hotplug_bridge)
return false;
if (pci_bridge_d3_force) if (pci_bridge_d3_force)
return true; return true;
......
...@@ -150,15 +150,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev, ...@@ -150,15 +150,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
pci_save_state(dev); pci_save_state(dev);
/* if (pci_bridge_d3_possible(dev)) {
* Prevent runtime PM if the port is advertising support for PCIe
* hotplug. Otherwise the BIOS hotplug SMI code might not be able
* to enumerate devices behind this port properly (the port is
* powered down preventing all config space accesses to the
* subordinate devices). We can't be sure for native PCIe hotplug
* either so prevent that as well.
*/
if (pci_bridge_d3_possible(dev) && !dev->is_hotplug_bridge) {
/* /*
* Keep the port resumed 100ms to make sure things like * Keep the port resumed 100ms to make sure things like
* config space accesses from userspace (lspci) will not * config space accesses from userspace (lspci) will not
...@@ -176,7 +168,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev, ...@@ -176,7 +168,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
static void pcie_portdrv_remove(struct pci_dev *dev) static void pcie_portdrv_remove(struct pci_dev *dev)
{ {
if (pci_bridge_d3_possible(dev) && !dev->is_hotplug_bridge) { if (pci_bridge_d3_possible(dev)) {
pm_runtime_forbid(&dev->dev); pm_runtime_forbid(&dev->dev);
pm_runtime_get_noresume(&dev->dev); pm_runtime_get_noresume(&dev->dev);
pm_runtime_dont_use_autosuspend(&dev->dev); pm_runtime_dont_use_autosuspend(&dev->dev);
......
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