]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: PCI: PM: Rework root bus notification setup
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 15 Dec 2025 12:48:14 +0000 (13:48 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 17 Dec 2025 12:52:53 +0000 (13:52 +0100)
Since pci_acpi_add_bus_pm_notifier() is only suitable for adding ACPI
PM notifiers to root buses, rename it to pci_acpi_add_root_pm_notifier()
and modify it to take an additional "root" argument, which is then used
for passing a PCI root bridge device pointer to acpi_add_pm_notifier().

That function uses it to populate the "dev" field in the context
structure attached to the ACPI device object that will receive the
ACPI "wake" notifications on behalf of the given PCI root bus.  The
context structure in question is passed to pci_acpi_wake_bus(), so
the latter can be simplified quite a bit now because the target PCI
host bridge structure address can be derived from "dev".

No intentional functional impact.

This change will also facilitate a subsequent update related to the
registration of wakeup sources.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
[ rjw: Kerneldoc comment fixup ]
Link: https://patch.msgid.link/2395263.ElGaqSPkdT@rafael.j.wysocki
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/pci_root.c
drivers/pci/pci-acpi.c
include/linux/pci-acpi.h

index 74ade416031457603be1234403a966e5757b1fe1..9d7f85dadc48f7144190bb820bd18d9afd3291c8 100644 (file)
@@ -738,7 +738,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
        if (no_aspm)
                pcie_no_aspm();
 
-       pci_acpi_add_bus_pm_notifier(device);
+       pci_acpi_add_root_pm_notifier(device, root);
        device_set_wakeup_capable(root->bus->bridge, device->wakeup.flags.valid);
 
        if (hotadd) {
index 9369377725fa030b6137df19caab0e298de87e60..79980203a1fbdbe77a55de246f64afe0c047ac4b 100644 (file)
@@ -847,12 +847,7 @@ bool shpchp_is_native(struct pci_dev *bridge)
  */
 static void pci_acpi_wake_bus(struct acpi_device_wakeup_context *context)
 {
-       struct acpi_device *adev;
-       struct acpi_pci_root *root;
-
-       adev = container_of(context, struct acpi_device, wakeup.context);
-       root = acpi_driver_data(adev);
-       pci_pme_wakeup_bus(root->bus);
+       pci_pme_wakeup_bus(to_pci_host_bridge(context->dev)->bus);
 }
 
 /**
@@ -885,12 +880,14 @@ static void pci_acpi_wake_dev(struct acpi_device_wakeup_context *context)
 }
 
 /**
- * pci_acpi_add_bus_pm_notifier - Register PM notifier for root PCI bus.
+ * pci_acpi_add_root_pm_notifier - Register PM notifier for root PCI bus.
  * @dev: PCI root bridge ACPI device.
+ * @root: PCI root corresponding to @dev.
  */
-acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev)
+acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev,
+                                         struct acpi_pci_root *root)
 {
-       return acpi_add_pm_notifier(dev, NULL, pci_acpi_wake_bus);
+       return acpi_add_pm_notifier(dev, root->bus->bridge, pci_acpi_wake_bus);
 }
 
 /**
index 078225b514d4848a57f7548be112166d84021e11..c0c54baadf04edae0c6ec19ceaf433ee314daded 100644 (file)
@@ -12,7 +12,8 @@
 #include <linux/acpi.h>
 
 #ifdef CONFIG_ACPI
-extern acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev);
+extern acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev,
+                                                struct acpi_pci_root *pci_root);
 static inline acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev)
 {
        return acpi_remove_pm_notifier(dev);