Skip to contentSkip to conversation

ACPI / hotplug / PCI: Take runtime PM autosuspend into account

PATCH In review Mika Westerberg 2 participants 2 messages Nov 13, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI / hotplug / PCI: Take runtime PM autosuspend into account

PCIe ports (the only ones we do runtime PM) are using runtime PM autosuspend to keep the port powered on for a while after it becomes idle. However, ACPI hotplug does not take this into account so if we get multiple hotplug events in a short period of time we may be powering ports on and off and then back on unnecessarily.

For this reason call pm_runtime_put_autosuspend() for them (with the accompanying pm_runtime_mark_last_busy()).

---
 drivers/pci/hotplug/acpiphp_glue.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +6 -3
index b3869951c0eb..c8264af40643 100644
@@ -672,7 +672,8 @@ static void trim_stale_devices(struct pci_dev *dev)
 		list_for_each_entry_safe_reverse(child, tmp, &bus->devices, bus_list)
 			trim_stale_devices(child);
 
-		pm_runtime_put(&dev->dev);
+		pm_runtime_mark_last_busy(&dev->dev);
+		pm_runtime_put_autosuspend(&dev->dev);
 	}
 }
 
@@ -714,8 +715,10 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
 		}
 	}
 
-	if (bridge->pci_dev)
-		pm_runtime_put(&bridge->pci_dev->dev);
+	if (bridge->pci_dev) {
+		pm_runtime_mark_last_busy(&bridge->pci_dev->dev);
+		pm_runtime_put_autosuspend(&bridge->pci_dev->dev);
+	}
 }
 
 /*
Signature · 1 line
2.24.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Mika Westerberg

PCIe ports (the only ones we do runtime PM) are using runtime PM autosuspend to keep the port powered on for a while after it becomes idle. However, ACPI hotplug does not take this into account so if we get multiple hotplug events in a short period of time we may be powering ports on and off and then back on unnecessarily.

For this reason call pm_runtime_put_autosuspend() for them (with the accompanying pm_runtime_mark_last_busy()).

Makes sense:

Quoted 32 lines
---
 drivers/pci/hotplug/acpiphp_glue.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +6 -4
index b3869951c0eb..c8264af40643 100644
@@ -672,7 +672,8 @@ static void trim_stale_devices(struct pci_dev *dev)
                list_for_each_entry_safe_reverse(child, tmp, &bus->devices, bus_list)
                        trim_stale_devices(child);
 
-               pm_runtime_put(&dev->dev);
+               pm_runtime_mark_last_busy(&dev->dev);
+               pm_runtime_put_autosuspend(&dev->dev);
        }
 }
 
@@ -714,8 +715,10 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
                }
        }
 
-       if (bridge->pci_dev)
-               pm_runtime_put(&bridge->pci_dev->dev);
+       if (bridge->pci_dev) {
+               pm_runtime_mark_last_busy(&bridge->pci_dev->dev);
+               pm_runtime_put_autosuspend(&bridge->pci_dev->dev);
+       }
 }
 
 /*
--