diff mbox series

[3/7] intel_idle: further 'intel_idle_init_cstates_icpu()' cleanup

Message ID 20230419143947.1342730-4-dedekind1@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series misc intel_idle cleanups | expand

Commit Message

Artem Bityutskiy April 19, 2023, 2:39 p.m. UTC
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Introduce a temporary 'state' variable for referencing the currently
processed C-state in the 'intel_idle_init_cstates_icpu()' function.

This makes code lines shorter and easier to read.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 drivers/idle/intel_idle.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

Comments

Zhang Rui April 20, 2023, 8:22 a.m. UTC | #1
On Wed, 2023-04-19 at 17:39 +0300, Artem Bityutskiy wrote:
> From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> 
> Introduce a temporary 'state' variable for referencing the currently
> processed C-state in the 'intel_idle_init_cstates_icpu()' function.
> 
> This makes code lines shorter and easier to read.
> 
> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Reviewed-by: Zhang Rui <rui.zhang@intel.com>

thanks,
rui
> ---
>  drivers/idle/intel_idle.c | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
> index 190410fc9ce5..73ddb1d8cfcf 100644
> --- a/drivers/idle/intel_idle.c
> +++ b/drivers/idle/intel_idle.c
> @@ -1871,6 +1871,7 @@ static void __init
> intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
>  	}
>  
>  	for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
> +		struct cpuidle_state *state;
>  		unsigned int mwait_hint;
>  
>  		if (intel_idle_max_cstate_reached(cstate))
> @@ -1893,29 +1894,30 @@ static void __init
> intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
>  
>  		/* Structure copy. */
>  		drv->states[drv->state_count] =
> cpuidle_state_table[cstate];
> +		state = &drv->states[drv->state_count];
>  
> -		if ((drv->states[drv->state_count].flags &
> CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) {
> +		if ((state->flags & CPUIDLE_FLAG_IRQ_ENABLE) ||
> force_irq_on) {
>  			pr_info("forced intel_idle_irq for state %d\n",
> cstate);
> -			drv->states[drv->state_count].enter =
> intel_idle_irq;
> +			state->enter = intel_idle_irq;
>  		}
>  
>  		if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) &&
> -		    drv->states[drv->state_count].flags &
> CPUIDLE_FLAG_IBRS) {
> -			WARN_ON_ONCE(drv->states[drv-
> >state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE);
> -			drv->states[drv->state_count].enter =
> intel_idle_ibrs;
> +		    state->flags & CPUIDLE_FLAG_IBRS) {
> +			WARN_ON_ONCE(state->flags &
> CPUIDLE_FLAG_IRQ_ENABLE);
> +			state->enter = intel_idle_ibrs;
>  		}
>  
> -		if (drv->states[drv->state_count].flags &
> CPUIDLE_FLAG_INIT_XSTATE)
> -			drv->states[drv->state_count].enter =
> intel_idle_xstate;
> +		if (state->flags & CPUIDLE_FLAG_INIT_XSTATE)
> +			state->enter = intel_idle_xstate;
>  
>  		if ((disabled_states_mask & BIT(drv->state_count)) ||
>  		    ((icpu->use_acpi || force_use_acpi) &&
>  		     intel_idle_off_by_default(mwait_hint) &&
> -		     !(drv->states[drv->state_count].flags &
> CPUIDLE_FLAG_ALWAYS_ENABLE)))
> -			drv->states[drv->state_count].flags |=
> CPUIDLE_FLAG_OFF;
> +		     !(state->flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
> +			state->flags |= CPUIDLE_FLAG_OFF;
>  
> -		if (intel_idle_state_needs_timer_stop(&drv->states[drv-
> >state_count]))
> -			drv->states[drv->state_count].flags |=
> CPUIDLE_FLAG_TIMER_STOP;
> +		if (intel_idle_state_needs_timer_stop(state))
> +			state->flags |= CPUIDLE_FLAG_TIMER_STOP;
>  
>  		drv->state_count++;
>  	}
diff mbox series

Patch

diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 190410fc9ce5..73ddb1d8cfcf 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -1871,6 +1871,7 @@  static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
 	}
 
 	for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
+		struct cpuidle_state *state;
 		unsigned int mwait_hint;
 
 		if (intel_idle_max_cstate_reached(cstate))
@@ -1893,29 +1894,30 @@  static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
 
 		/* Structure copy. */
 		drv->states[drv->state_count] = cpuidle_state_table[cstate];
+		state = &drv->states[drv->state_count];
 
-		if ((drv->states[drv->state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) {
+		if ((state->flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) {
 			pr_info("forced intel_idle_irq for state %d\n", cstate);
-			drv->states[drv->state_count].enter = intel_idle_irq;
+			state->enter = intel_idle_irq;
 		}
 
 		if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) &&
-		    drv->states[drv->state_count].flags & CPUIDLE_FLAG_IBRS) {
-			WARN_ON_ONCE(drv->states[drv->state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE);
-			drv->states[drv->state_count].enter = intel_idle_ibrs;
+		    state->flags & CPUIDLE_FLAG_IBRS) {
+			WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE);
+			state->enter = intel_idle_ibrs;
 		}
 
-		if (drv->states[drv->state_count].flags & CPUIDLE_FLAG_INIT_XSTATE)
-			drv->states[drv->state_count].enter = intel_idle_xstate;
+		if (state->flags & CPUIDLE_FLAG_INIT_XSTATE)
+			state->enter = intel_idle_xstate;
 
 		if ((disabled_states_mask & BIT(drv->state_count)) ||
 		    ((icpu->use_acpi || force_use_acpi) &&
 		     intel_idle_off_by_default(mwait_hint) &&
-		     !(drv->states[drv->state_count].flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
-			drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF;
+		     !(state->flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
+			state->flags |= CPUIDLE_FLAG_OFF;
 
-		if (intel_idle_state_needs_timer_stop(&drv->states[drv->state_count]))
-			drv->states[drv->state_count].flags |= CPUIDLE_FLAG_TIMER_STOP;
+		if (intel_idle_state_needs_timer_stop(state))
+			state->flags |= CPUIDLE_FLAG_TIMER_STOP;
 
 		drv->state_count++;
 	}