From: Maciej S. Szmigiero Date: Sun, 3 Aug 2025 19:18:11 +0000 (+0200) Subject: ACPI: PM: Add power resource init function X-Git-Tag: v6.18-rc1~151^2~2^4~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3bc3dc166dd23404bb2091292cd4e17f87678ca6;p=thirdparty%2Fkernel%2Fstable.git ACPI: PM: Add power resource init function This way DMI based quirk matching and quirk flag initialization can be done just once - in the newly introduced acpi_power_resources_init() function, which is similar to existing acpi_*_init() functions. Convert the single already existing DMI match-based quirk in this ACPI power resource handler ("leave unused power resources on" quirk) to such one-time initialization in acpi_power_resources_init() function instead of re-running that DMI match each time acpi_turn_off_unused_power_resources() gets called. Signed-off-by: Maciej S. Szmigiero Link: https://patch.msgid.link/b173a6987f0b35597fd82400cb28f289786e03d0.1754243159.git.mail@maciej.szmigiero.name Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index e2781864fdceb..63354972ab0b8 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -140,6 +140,7 @@ int __acpi_device_uevent_modalias(const struct acpi_device *adev, /* -------------------------------------------------------------------------- Power Resource -------------------------------------------------------------------------- */ +void acpi_power_resources_init(void); void acpi_power_resources_list_free(struct list_head *list); int acpi_extract_power_resources(union acpi_object *package, unsigned int start, struct list_head *list); diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index b7243d7563b1b..cd9380b1f9516 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -63,6 +63,8 @@ struct acpi_power_resource_entry { struct acpi_power_resource *resource; }; +static bool unused_power_resources_quirk; + static LIST_HEAD(acpi_power_resource_list); static DEFINE_MUTEX(power_resource_list_lock); @@ -1046,7 +1048,7 @@ void acpi_turn_off_unused_power_resources(void) { struct acpi_power_resource *resource; - if (dmi_check_system(dmi_leave_unused_power_resources_on)) + if (unused_power_resources_quirk) return; mutex_lock(&power_resource_list_lock); @@ -1065,3 +1067,9 @@ void acpi_turn_off_unused_power_resources(void) mutex_unlock(&power_resource_list_lock); } + +void __init acpi_power_resources_init(void) +{ + unused_power_resources_quirk = + dmi_check_system(dmi_leave_unused_power_resources_on); +} diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index fb1fe9f3b1a36..bb74e78344358 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2702,6 +2702,7 @@ void __init acpi_scan_init(void) acpi_memory_hotplug_init(); acpi_watchdog_init(); acpi_pnp_init(); + acpi_power_resources_init(); acpi_int340x_thermal_init(); acpi_init_lpit();