Skip to content

Commit a78032e

Browse files
dedekindrafaeljw
authored andcommitted
intel_idle: clean up intel_idle_init_cstates_icpu()
The intel_idle_init_cstates_icpu() function includes a loop that iterates over every C-state. Inside the loop, the same C-state data is referenced 2 ways: 1. as cpuidle_state_table[cstate] 2. as drv->states[drv->state_count] (but it is a copy of #1, not the same object). Make the code be more consistent and easier to read by using only the 2nd way. So the code structure would be as follows: 1. Use cpuidle_state_table[cstate] 2. Copy cpuidle_state_table[cstate] to drv->states[drv->state_count] 3. Use only drv->states[drv->state_count] from this point. Note, this change introduces a checkpatch.pl warning (too long line), but it will be addressed in the next patch. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Reviewed-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 91048ce commit a78032e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

drivers/idle/intel_idle.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,24 +1894,24 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
18941894
/* Structure copy. */
18951895
drv->states[drv->state_count] = cpuidle_state_table[cstate];
18961896

1897-
if ((cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) {
1897+
if ((drv->states[drv->state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) {
18981898
pr_info("forced intel_idle_irq for state %d\n", cstate);
18991899
drv->states[drv->state_count].enter = intel_idle_irq;
19001900
}
19011901

19021902
if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) &&
1903-
cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IBRS) {
1904-
WARN_ON_ONCE(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IRQ_ENABLE);
1903+
drv->states[drv->state_count].flags & CPUIDLE_FLAG_IBRS) {
1904+
WARN_ON_ONCE(drv->states[drv->state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE);
19051905
drv->states[drv->state_count].enter = intel_idle_ibrs;
19061906
}
19071907

1908-
if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_INIT_XSTATE)
1908+
if (drv->states[drv->state_count].flags & CPUIDLE_FLAG_INIT_XSTATE)
19091909
drv->states[drv->state_count].enter = intel_idle_xstate;
19101910

19111911
if ((disabled_states_mask & BIT(drv->state_count)) ||
19121912
((icpu->use_acpi || force_use_acpi) &&
19131913
intel_idle_off_by_default(mwait_hint) &&
1914-
!(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
1914+
!(drv->states[drv->state_count].flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
19151915
drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF;
19161916

19171917
if (intel_idle_state_needs_timer_stop(&drv->states[drv->state_count]))

0 commit comments

Comments
 (0)