]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
PCI: Activate runtime PM on a PCIe port only if it can suspend
authorLukas Wunner <lukas@wunner.de>
Fri, 28 Oct 2016 08:52:06 +0000 (10:52 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 18 Nov 2016 00:46:06 +0000 (18:46 -0600)
Currently pcie_portdrv_probe() activates runtime PM on a PCIe port even
if it will never actually suspend because the BIOS is too old or the
"pcie_port_pm=off" option was specified on the kernel command line.

A few CPU cycles can be saved by not activating runtime PM at all in these
cases, because rpm_idle() and rpm_suspend() will bail out right at the
beginning when calling rpm_check_suspend_allowed(), instead of carrying out
various locking and assignments, invoking rpm_callback(), getting back
-EBUSY and rolling everything back.

The conditions checked in pci_bridge_d3_possible() are all static, they
never change during uptime of the system, hence it's safe to call this to
determine if runtime PM should be activated.

No functional change intended.

Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/pcie/portdrv_pci.c

index 4a7f6f54d669e52c15b82e30c4166f616d6313d1..720f7e27c3a8f08aea85636c05df253f2997e737 100644 (file)
@@ -2230,7 +2230,7 @@ void pci_config_pm_runtime_put(struct pci_dev *pdev)
  * This function checks if it is possible to move the bridge to D3.
  * Currently we only allow D3 for recent enough PCIe ports.
  */
-static bool pci_bridge_d3_possible(struct pci_dev *bridge)
+bool pci_bridge_d3_possible(struct pci_dev *bridge)
 {
        unsigned int year;
 
index 27048bb88783754d71fe10d606eed119d56d59ad..ffffef37ab613ab3a249be8ec81dbd9f7e61c06e 100644 (file)
@@ -85,6 +85,7 @@ void pci_pm_init(struct pci_dev *dev);
 void pci_ea_init(struct pci_dev *dev);
 void pci_allocate_cap_save_buffers(struct pci_dev *dev);
 void pci_free_cap_save_buffers(struct pci_dev *dev);
+bool pci_bridge_d3_possible(struct pci_dev *dev);
 void pci_bridge_d3_update(struct pci_dev *dev);
 
 static inline void pci_wakeup_event(struct pci_dev *dev)
index 79327cc14e7dbbc43cdcc964499e0083c483aba1..1ae712cb22eca35510556f45a7b163064b669160 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/dmi.h>
 #include <linux/pci-aspm.h>
 
+#include "../pci.h"
 #include "portdrv.h"
 #include "aer/aerdrv.h"
 
@@ -157,7 +158,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
         * subordinate devices).  We can't be sure for native PCIe hotplug
         * either so prevent that as well.
         */
-       if (!dev->is_hotplug_bridge) {
+       if (pci_bridge_d3_possible(dev) && !dev->is_hotplug_bridge) {
                /*
                 * Keep the port resumed 100ms to make sure things like
                 * config space accesses from userspace (lspci) will not
@@ -175,7 +176,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
 
 static void pcie_portdrv_remove(struct pci_dev *dev)
 {
-       if (!dev->is_hotplug_bridge) {
+       if (pci_bridge_d3_possible(dev) && !dev->is_hotplug_bridge) {
                pm_runtime_forbid(&dev->dev);
                pm_runtime_get_noresume(&dev->dev);
                pm_runtime_dont_use_autosuspend(&dev->dev);