* [PATCH v2] ACPI: PM: Avoid initializing power management for absent devices
@ 2026-11-17 17:58 Rafael J. Wysocki
2026-11-17 18:25 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2026-11-17 17:58 UTC (permalink / raw)
To: Linux ACPI; +Cc: Linux PM, Linux PCI, Mika Westerberg, Alan Borzeszkowski
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Commit 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power()
early") removed a device presence check from acpi_bus_init_power() which
in some cases causes power management to be initialized for an ACPI
device object and never used going forward. That in turn may prevent
power management from working as expected for other devices.
Namely, if a given ACPI device object is not enabled according to its
_STA, find_child_checks() will return an error for it which will prevent
it from being used as an ACPI companion for a PCI device. Thus if
acpi_device_init_power() initializes power management for it and its
initial power state turns out to be different from D3cold, it may stay
in that power state forever. If it has power resources and they are
"on" during the initialization, they may be reference-counted and never
turned off. If they are shared with other devices, they will prevent
power from going down after attempting to put the other devices into
low-power states.
To prevent that from happening, restore the device presence check in
acpi_bus_init_power(), but also adjust find_child_checks() to return
an error for absent devices (instead of doing that for disabled devices)
in accordance with acpi_bus_init_power() and the existing check in
acpi_bus_attach().
Fixes: 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power() early")
Reported-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Tested-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v1 -> v2:
* Clear power_manageable when returning an error early from
acpi_bus_init_power() (Sashiko)
* Print debug message when that happens
* Added Tested-by from Alan (thanks!)
Quick turnaround because it fixes a recent regression.
---
drivers/acpi/device_pm.c | 7 +++++++
drivers/acpi/glue.c | 8 ++------
2 files changed, 9 insertions(+), 6 deletions(-)
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -360,6 +360,13 @@ int acpi_bus_init_power(struct acpi_devi
if (device->power.state != ACPI_STATE_UNKNOWN)
return 0;
+ if (!acpi_device_is_present(device)) {
+ device->flags.power_manageable = 0;
+ acpi_handle_debug(device->handle,
+ "Device not present, ACPI PM disabled\n");
+ return -ENXIO;
+ }
+
/*
* The ACPI device power state can be only initialized once. If this
* fails, ACPI power management will not be used for the device going
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -109,14 +109,10 @@ static bool acpi_dev_has_children(struct
static int find_child_checks(struct acpi_device *adev, bool check_children)
{
- unsigned long long sta;
- acpi_status status;
-
if (check_children && !acpi_dev_has_children(adev))
return -ENODEV;
- status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
- if (status == AE_NOT_FOUND) {
+ if (!acpi_has_method(adev->handle, METHOD_NAME__STA)) {
/*
* Special case: backlight device objects without _STA are
* preferred to other objects with the same _ADR value, because
@@ -128,7 +124,7 @@ static int find_child_checks(struct acpi
return FIND_CHILD_MIN_SCORE;
}
- if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
+ if (!acpi_device_is_present(adev))
return -ENODEV;
/*
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] ACPI: PM: Avoid initializing power management for absent devices
2026-11-17 17:58 [PATCH v2] ACPI: PM: Avoid initializing power management for absent devices Rafael J. Wysocki
@ 2026-11-17 18:25 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-17 18:25 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Linux PCI
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ACPI: PM: acpi_bus_init_power() clears power_manageable without
poisoning state
--
commit 0fdc7a0041a301b9912e9f5aa11b4ed9de27fe02
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI: PM: Avoid initializing power management for absent devices
This commit restores the device presence check in acpi_bus_init_power() and
updates find_child_checks() to reject absent devices rather than disabled
ones.
> diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> index 76104f715efa1..ac2f8579110f0 100644
> --- a/drivers/acpi/device_pm.c
> +++ b/drivers/acpi/device_pm.c
> @@ -360,6 +360,13 @@ int acpi_bus_init_power(struct acpi_device *device)
> if (device->power.state != ACPI_STATE_UNKNOWN)
> return 0;
>
> + if (!acpi_device_is_present(device)) {
> + device->flags.power_manageable = 0;
> + acpi_handle_debug(device->handle,
> + "Device not present, ACPI PM disabled\n");
> + return -ENXIO;
> + }
[Severity: High]
Can clearing device->flags.power_manageable while leaving
device->power.state as ACPI_STATE_UNKNOWN break ACPI PM and leak D0 power
resource references if the device later becomes present?
If acpi_bus_init_power() is called while a device is absent (for example
via acpi_power_up_if_adr_present() before a parent bridge is powered up or
during hotplug) and called again in acpi_bus_attach() after
acpi_bus_get_status() refreshes _STA, the second call proceeds to
acpi_device_init_power() with device->flags.power_manageable still set to 0
because 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power()
early") removed the re-initialization of power_manageable from
acpi_bus_attach().
Inside acpi_device_init_power(), acpi_device_get_power() sees
!device->flags.power_manageable and reports the parent's state (D0), after
which acpi_device_init_power() checks device->power.flags.power_resources
and calls acpi_power_on_resources() for D0:
drivers/acpi/device_pm.c:acpi_device_init_power() {
...
result = acpi_device_get_power(device, &state);
if (result)
return result;
if (state < ACPI_STATE_D3_COLD && device->power.flags.power_resources) {
/* Reference count the power resources. */
result = acpi_power_on_resources(device, state);
...
}
Because device->flags.power_manageable remains 0, subsequent calls to
acpi_device_set_power() fail with -EINVAL, leaving ACPI PM disabled for the
device and permanently leaking the D0 power resource references acquired
above.
--
Sashiko AI review · https://sashiko.dev/#/patchset/2859265.mvXUDI8C0e@rafael.j.wysocki?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-17 18:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 17:58 [PATCH v2] ACPI: PM: Avoid initializing power management for absent devices Rafael J. Wysocki
2026-11-17 18:25 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox