Skip to contentSkip to conversation

intel_idle: Fix max_cstate for processor models without C-state tables

PATCH Applied Chen Yu 2 participants 2 messages Oct 24, 2020 – Oct 27, 2020

Subsystems (2)
lore
Share & tools
lore

Chen Yu

author
#0 lore raw

PATCH 1/1 intel_idle: Fix max_cstate for processor models without C-state tables

Currently intel_idle driver gets the c-state information from ACPI _CST if the processor model is not recognized by it. However the c-state in _CST starts with index 1 which is different from the index in intel_idle driver's internal c-state table. While intel_idle_max_cstate_reached() was previously introduced to deal with intel_idle driver's internal c-state table, re-using this function directly on _CST might get wrong. Fix this by subtracting the index by 1 when checking max cstate via _CST. For example, append intel_idle.max_cstate=1 in boot command line, Before the patch:
grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name POLL
After the patch:
grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name /sys/devices/system/cpu/cpu0/cpuidle/state0/name:POLL /sys/devices/system/cpu/cpu0/cpuidle/state1/name:C1_ACPI

Fixes 18734958e9bf ("intel_idle: Use ACPI _CST for processor models without C-state tables")
Cc 5.6+ <[email protected]> # 5.6+
---
 drivers/idle/intel_idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/idle/intel_idle.c +1 -1
index 9a810e4a7946..dbd4be1c271b 100644
@@ -1236,7 +1236,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
 		struct acpi_processor_cx *cx;
 		struct cpuidle_state *state;
 
-		if (intel_idle_max_cstate_reached(cstate))
+		if (intel_idle_max_cstate_reached(cstate - 1))
 			break;
 
 		cx = &acpi_state_table.states[cstate];
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 31 lines · Chen Yu

Currently intel_idle driver gets the c-state information from ACPI _CST if the processor model is not recognized by it. However the c-state in _CST starts with index 1 which is different from the index in intel_idle driver's internal c-state table. While intel_idle_max_cstate_reached() was previously introduced to deal with intel_idle driver's internal c-state table, re-using this function directly on _CST might get wrong. Fix this by subtracting the index by 1 when checking max cstate via _CST. For example, append intel_idle.max_cstate=1 in boot command line, Before the patch:
grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name POLL
After the patch:
grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name /sys/devices/system/cpu/cpu0/cpuidle/state0/name:POLL /sys/devices/system/cpu/cpu0/cpuidle/state1/name:C1_ACPI

Fixes 18734958e9bf ("intel_idle: Use ACPI _CST for processor models without C-state tables")
Cc 5.6+ <[email protected]> # 5.6+
---
 drivers/idle/intel_idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/idle/intel_idle.c +0 -0
index 9a810e4a7946..dbd4be1c271b 100644

drivers/idle/intel_idle.c static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)

Quoted 9 lines
drivers/idle/intel_idle.c +1 -2
@@ -1236,7 +1236,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
                struct acpi_processor_cx *cx;
                struct cpuidle_state *state;
 
-               if (intel_idle_max_cstate_reached(cstate))
+               if (intel_idle_max_cstate_reached(cstate - 1))
                        break;
 
                cx = &acpi_state_table.states[cstate];
--

Applied as 5.10-rc material with some changelog edits, thanks!