Re: [PATCH 2/2] ACPI: processor: Remove redundant static variable and rename cstate check function

From: Rafael J. Wysocki

Date: Thu Mar 05 2026 - 13:38:27 EST


On Thu, Jan 29, 2026 at 5:14 AM Huisong Li <lihuisong@xxxxxxxxxx> wrote:
>
> The function acpi_processor_cstate_first_run_checks() is currently called
> only once during initialization in acpi_processor_register_idle_driver().

Not really, it is called in every iteration of the
for_each_possible_cpu() loop in there.

You need to move it out of that loop so the static var can be dropped from it.

> Because its execution is already limited by the caller's lifecycle, the
> internal static 'first_run' variable is redundant and can be safely
> removed. Additionally, the current function name is no longer descriptive
> of its behavior. Rename the function to acpi_processor_update_max_cstate()
> to better reflect its actual purpose.
>
> Signed-off-by: Huisong Li <lihuisong@xxxxxxxxxx>
> ---
> drivers/acpi/processor_idle.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index 083f85c0d530..35b55081bc10 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -819,19 +819,13 @@ static void acpi_processor_setup_cstates(struct acpi_processor *pr)
> drv->state_count = count;
> }
>
> -static inline void acpi_processor_cstate_first_run_checks(void)
> +static inline void acpi_processor_update_max_cstate(void)
> {
> - static int first_run;
> -
> - if (first_run)
> - return;
> dmi_check_system(processor_power_dmi_table);
> max_cstate = acpi_processor_cstate_check(max_cstate);
> if (max_cstate < ACPI_C_STATES_MAX)
> pr_notice("processor limited to max C-state %d\n", max_cstate);
>
> - first_run++;
> -
> if (nocst)
> return;
>
> @@ -840,7 +834,7 @@ static inline void acpi_processor_cstate_first_run_checks(void)
> #else
>
> static inline int disabled_by_idle_boot_param(void) { return 0; }
> -static inline void acpi_processor_cstate_first_run_checks(void) { }
> +static inline void acpi_processor_update_max_cstate(void) { }
> static int acpi_processor_get_cstate_info(struct acpi_processor *pr)
> {
> return -ENODEV;
> @@ -1391,7 +1385,7 @@ void acpi_processor_register_idle_driver(void)
> if (!pr)
> continue;
>
> - acpi_processor_cstate_first_run_checks();
> + acpi_processor_update_max_cstate();
> ret = acpi_processor_get_power_info(pr);
> if (!ret) {
> pr->flags.power_setup_done = 1;
> --
> 2.33.0
>
>