Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

intel_idle: Fix SPR C6 optimization

The Sapphire Rapids (SPR) C6 optimization was added to the end of the
'spr_idle_state_table_update()' function. However, the function has a
'return' which may happen before the optimization has a chance to run.
And this may prevent the optimization from happening.

This is an unlikely scenario, but possible if user boots with, say,
the 'intel_idle.preferred_cstates=6' kernel boot option.

This patch fixes the issue by eliminating the problematic 'return'
statement.

Fixes: 3a9cf77b60dc ("intel_idle: add core C6 optimization for SPR")
Suggested-by: Jan Beulich <jbeulich@suse.com>
Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
[ rjw: Minor changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Artem Bityutskiy and committed by
Rafael J. Wysocki
7eac3bd3 39c184a6

+3 -5
+3 -5
drivers/idle/intel_idle.c
··· 1581 1581 unsigned long long msr; 1582 1582 1583 1583 /* Check if user prefers C1E over C1. */ 1584 - if (preferred_states_mask & BIT(2)) { 1585 - if (preferred_states_mask & BIT(1)) 1586 - /* Both can't be enabled, stick to the defaults. */ 1587 - return; 1588 - 1584 + if ((preferred_states_mask & BIT(2)) && 1585 + !(preferred_states_mask & BIT(1))) { 1586 + /* Disable C1 and enable C1E. */ 1589 1587 spr_cstates[0].flags |= CPUIDLE_FLAG_UNUSABLE; 1590 1588 spr_cstates[1].flags &= ~CPUIDLE_FLAG_UNUSABLE; 1591 1589