lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0hG0pfuz_WUfZAwd1iKumjxsX_+K5ZAfsOs2iSHdGwNrA@mail.gmail.com>
Date: Thu, 24 Jul 2025 12:00:50 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: "Guan-Chun.Wu" <409411716@....tku.edu.tw>
Cc: rafael@...nel.org, lenb@...nel.org, linux-acpi@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ACPI: PM: Use nearest power-manageable ancestor

On Thu, Jul 24, 2025 at 11:21 AM Guan-Chun.Wu <409411716@....tku.edu.tw> wrote:
>
> When a device’s power_manageable flag is false, we currently only
> fall back to the direct parent’s power state.  In a deep hierarchy
> there may be a more distant ancestor that does support power
> management.
>
> Walk up the parent chain until we find the closest power_manageable
> ancestor and use its power state.  If none is found, default to
> ACPI_STATE_D0 (fully on).

Is there a specific use case in the field in which this change is needed?

If there's none, let's not make it.

> Signed-off-by: Guan-Chun.Wu <409411716@....tku.edu.tw>
> ---
>  drivers/acpi/device_pm.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> index dbd4446025ec..81b47fb00e80 100644
> --- a/drivers/acpi/device_pm.c
> +++ b/drivers/acpi/device_pm.c
> @@ -84,8 +84,23 @@ int acpi_device_get_power(struct acpi_device *device, int *state)
>         parent = acpi_dev_parent(device);
>
>         if (!device->flags.power_manageable) {
> -               /* TBD: Non-recursive algorithm for walking up hierarchy. */
> -               *state = parent ? parent->power.state : ACPI_STATE_D0;
> +               /*
> +                * If the device itself is not power-manageable,
> +                * walk up the parent hierarchy to find the closest
> +                * ancestor that is power-manageable.
> +                * Use that ancestor's power state as an estimate
> +                * for this device. If no such ancestor exists,
> +                * default to D0 (Fully On).
> +                */
> +               struct acpi_device *ancestor = parent;
> +               /*
> +                * Keep traversing up until a power-manageable ancestor
> +                * is found or the root is reached
> +                */
> +               while (ancestor && !ancestor->flags.power_manageable)
> +                       ancestor = acpi_dev_parent(ancestor);
> +               /* Use the found ancestor's power state, or D0 if none is found */
> +               *state = ancestor ? ancestor->power.state : ACPI_STATE_D0;
>                 goto out;
>         }
>
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ