Linux ACPI
 help / color / mirror / Atom feed
* [RESEND][PATCH v1 0/2] PCI: ACPI: PM: Rework root bus wakeup notification setup and wakeup source registration
@ 2025-12-15 12:45 Rafael J. Wysocki
  2025-12-15 12:48 ` [RESEND][PATCH v1 1/2] ACPI: PCI: PM: Rework root bus notification setup Rafael J. Wysocki
  2025-12-15 12:49 ` [RESEND][PATCH v1 2/2] ACPI: PM: Register wakeup sources under physical devices Rafael J. Wysocki
  0 siblings, 2 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2025-12-15 12:45 UTC (permalink / raw)
  To: Linux ACPI; +Cc: Linux PM, Linux PCI, LKML, Bjorn Helgaas, Armin Wolf

Hi All,

This is a resend of

https://lore.kernel.org/linux-acpi/2395536.ElGaqSPkdT@rafael.j.wysocki/

which was sent in the middle of the merge window.

I have added R-bys from Armin to both patches, but otherwise there are no
changes, so the version is still 1.  I'd appreciate feedback, but if there's
none, I'll be queuing up these patches for 6.20.

The description below still applies.

Patch [1/2] updates the registration of PCI root bus wakeup notification setup
in order to simplify code in pci_acpi_wake_bus() and to prepare for the other
change.  This is not expected to affect functionality.

Patch [2/2] modifies the ACPI PM notifier registration to add wakeup sources
under devices that are going to be affected by wakeup handling instead of
registering them under ACPI companions of those devices (rationale explained
in the patch changelog).  This will change the sysfs layout (wakeup source
devices associated with PCI wakeup are now going to appear under PCI devices
and the host bridge device), but it is not expected to affect user space
adversely.

Thanks!




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RESEND][PATCH v1 1/2] ACPI: PCI: PM: Rework root bus notification setup
  2025-12-15 12:45 [RESEND][PATCH v1 0/2] PCI: ACPI: PM: Rework root bus wakeup notification setup and wakeup source registration Rafael J. Wysocki
@ 2025-12-15 12:48 ` Rafael J. Wysocki
  2025-12-15 12:49 ` [RESEND][PATCH v1 2/2] ACPI: PM: Register wakeup sources under physical devices Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2025-12-15 12:48 UTC (permalink / raw)
  To: Linux ACPI; +Cc: Linux PM, Linux PCI, LKML, Bjorn Helgaas, Armin Wolf

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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>
---
 drivers/acpi/pci_root.c  |    2 +-
 drivers/pci/pci-acpi.c   |   15 ++++++---------
 include/linux/pci-acpi.h |    3 ++-
 3 files changed, 9 insertions(+), 11 deletions(-)

--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -738,7 +738,7 @@ static int acpi_pci_root_add(struct acpi
 	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) {
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -847,12 +847,7 @@ bool shpchp_is_native(struct pci_dev *br
  */
 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 acp
 }
 
 /**
- * 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.
+ * @pci_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);
 }
 
 /**
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -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);




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RESEND][PATCH v1 2/2] ACPI: PM: Register wakeup sources under physical devices
  2025-12-15 12:45 [RESEND][PATCH v1 0/2] PCI: ACPI: PM: Rework root bus wakeup notification setup and wakeup source registration Rafael J. Wysocki
  2025-12-15 12:48 ` [RESEND][PATCH v1 1/2] ACPI: PCI: PM: Rework root bus notification setup Rafael J. Wysocki
@ 2025-12-15 12:49 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2025-12-15 12:49 UTC (permalink / raw)
  To: Linux ACPI; +Cc: Linux PM, Linux PCI, LKML, Bjorn Helgaas, Armin Wolf

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Currently, acpi_add_pm_notifier() registers wakeup sources under
ACPI companions of the devices affected by the handling of wakeup
events which goes against the rule that a struct acpi_device
can only be a parent of another struct acpi_device.

Moreover, it would be more logically consistent to register wakeup
sources under the devices affected by wakeup events handling which
would cause them to appear in more suitable places in sysfs and would
help to identify the devices they are associated with more easily.

Accordingly, update acpi_add_pm_notifier() to register wakeup sources
under the "target" devices directly instead of registering them under
the ACPI companions of those devices.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/acpi/device_pm.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -586,8 +586,7 @@ acpi_status acpi_add_pm_notifier(struct
 		goto out;
 
 	mutex_lock(&acpi_pm_notifier_lock);
-	adev->wakeup.ws = wakeup_source_register(&adev->dev,
-						 dev_name(&adev->dev));
+	adev->wakeup.ws = wakeup_source_register(dev, dev_name(&adev->dev));
 	adev->wakeup.context.dev = dev;
 	adev->wakeup.context.func = func;
 	adev->wakeup.flags.notifier_present = true;




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-15 12:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-15 12:45 [RESEND][PATCH v1 0/2] PCI: ACPI: PM: Rework root bus wakeup notification setup and wakeup source registration Rafael J. Wysocki
2025-12-15 12:48 ` [RESEND][PATCH v1 1/2] ACPI: PCI: PM: Rework root bus notification setup Rafael J. Wysocki
2025-12-15 12:49 ` [RESEND][PATCH v1 2/2] ACPI: PM: Register wakeup sources under physical devices Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox