[PATCH v1 4/9] ACPI: processor: idle: Move the initialization of state->flags to acpi_processor_setup_cstates

Huisong Li posted 9 patches 4 months, 1 week ago
There is a newer version of this series
[PATCH v1 4/9] ACPI: processor: idle: Move the initialization of state->flags to acpi_processor_setup_cstates
Posted by Huisong Li 4 months, 1 week ago
The acpi_processor_setup_cpuidle_cx() is called by
acpi_processor_setup_cpuidle_dev() which is used to setup cpuidle device.
However, acpi_processor_setup_cpuidle_cx() also initializes the states
in acpi_idle_driver, which isn't good. And acpi_processor_setup_cstates()
is aimed to initializes cstates in acpi_idle_driver. So the initialization
of state->flags should be here.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 drivers/acpi/processor_idle.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index f36f9514b6c7..5684925338b3 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -737,13 +737,11 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
 {
 	int i, count = ACPI_IDLE_STATE_START;
 	struct acpi_processor_cx *cx;
-	struct cpuidle_state *state;
 
 	if (max_cstate == 0)
 		max_cstate = 1;
 
 	for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
-		state = &acpi_idle_driver.states[count];
 		cx = &pr->power.states[i];
 
 		if (!cx->valid)
@@ -751,15 +749,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
 
 		per_cpu(acpi_cstate[count], dev->cpu) = cx;
 
-		if (lapic_timer_needs_broadcast(pr, cx))
-			state->flags |= CPUIDLE_FLAG_TIMER_STOP;
-
-		if (cx->type == ACPI_STATE_C3) {
-			state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
-			if (pr->flags.bm_check)
-				state->flags |= CPUIDLE_FLAG_RCU_IDLE;
-		}
-
 		count++;
 		if (count == CPUIDLE_STATE_MAX)
 			break;
@@ -818,6 +807,15 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
 		if (cx->type != ACPI_STATE_C1 && !acpi_idle_fallback_to_c1(pr))
 			state->enter_s2idle = acpi_idle_enter_s2idle;
 
+		if (lapic_timer_needs_broadcast(pr, cx))
+			state->flags |= CPUIDLE_FLAG_TIMER_STOP;
+
+		if (cx->type == ACPI_STATE_C3) {
+			state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
+			if (pr->flags.bm_check)
+				state->flags |= CPUIDLE_FLAG_RCU_IDLE;
+		}
+
 		count++;
 		if (count == CPUIDLE_STATE_MAX)
 			break;
-- 
2.33.0
Re: [PATCH v1 4/9] ACPI: processor: idle: Move the initialization of state->flags to acpi_processor_setup_cstates
Posted by Rafael J. Wysocki 3 months, 2 weeks ago
On Mon, Sep 29, 2025 at 11:38 AM Huisong Li <lihuisong@huawei.com> wrote:
>
> The acpi_processor_setup_cpuidle_cx() is called by
> acpi_processor_setup_cpuidle_dev() which is used to setup cpuidle device.
> However, acpi_processor_setup_cpuidle_cx() also initializes the states
> in acpi_idle_driver, which isn't good. And acpi_processor_setup_cstates()
> is aimed to initializes cstates in acpi_idle_driver. So the initialization
> of state->flags should be here.
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
>  drivers/acpi/processor_idle.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index f36f9514b6c7..5684925338b3 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -737,13 +737,11 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
>  {
>         int i, count = ACPI_IDLE_STATE_START;
>         struct acpi_processor_cx *cx;
> -       struct cpuidle_state *state;
>
>         if (max_cstate == 0)
>                 max_cstate = 1;
>
>         for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
> -               state = &acpi_idle_driver.states[count];
>                 cx = &pr->power.states[i];
>
>                 if (!cx->valid)
> @@ -751,15 +749,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
>
>                 per_cpu(acpi_cstate[count], dev->cpu) = cx;
>
> -               if (lapic_timer_needs_broadcast(pr, cx))
> -                       state->flags |= CPUIDLE_FLAG_TIMER_STOP;
> -
> -               if (cx->type == ACPI_STATE_C3) {
> -                       state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
> -                       if (pr->flags.bm_check)
> -                               state->flags |= CPUIDLE_FLAG_RCU_IDLE;
> -               }
> -
>                 count++;
>                 if (count == CPUIDLE_STATE_MAX)
>                         break;
> @@ -818,6 +807,15 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
>                 if (cx->type != ACPI_STATE_C1 && !acpi_idle_fallback_to_c1(pr))
>                         state->enter_s2idle = acpi_idle_enter_s2idle;
>
> +               if (lapic_timer_needs_broadcast(pr, cx))
> +                       state->flags |= CPUIDLE_FLAG_TIMER_STOP;
> +
> +               if (cx->type == ACPI_STATE_C3) {
> +                       state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
> +                       if (pr->flags.bm_check)
> +                               state->flags |= CPUIDLE_FLAG_RCU_IDLE;
> +               }
> +
>                 count++;
>                 if (count == CPUIDLE_STATE_MAX)
>                         break;
> --

Applied with rewritten subject and changelog as 6.19 material, thanks!