* [PATCH] intel_idle: Fix max_cstate for processor models without C-state tables
@ 2020-10-24 16:29 Chen Yu
2020-10-27 18:05 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Chen Yu @ 2020-10-24 16:29 UTC (permalink / raw)
To: Len Brown, Rafael J. Wysocki; +Cc: linux-pm, linux-kernel, Chen Yu, 5 . 6+
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")
Reported-by: Pengfei Xu <pengfei.xu@intel.com>
Cc: 5.6+ <stable@vger.kernel.org> # 5.6+
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
drivers/idle/intel_idle.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 9a810e4a7946..dbd4be1c271b 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -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];
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] intel_idle: Fix max_cstate for processor models without C-state tables
2020-10-24 16:29 [PATCH] intel_idle: Fix max_cstate for processor models without C-state tables Chen Yu
@ 2020-10-27 18:05 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-10-27 18:05 UTC (permalink / raw)
To: Chen Yu
Cc: Len Brown, Rafael J. Wysocki, Linux PM,
Linux Kernel Mailing List, 5 . 6+
On Sat, Oct 24, 2020 at 6:27 PM Chen Yu <yu.c.chen@intel.com> wrote:
>
> 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")
> Reported-by: Pengfei Xu <pengfei.xu@intel.com>
> Cc: 5.6+ <stable@vger.kernel.org> # 5.6+
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
> drivers/idle/intel_idle.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
> index 9a810e4a7946..dbd4be1c271b 100644
> --- a/drivers/idle/intel_idle.c
> +++ b/drivers/idle/intel_idle.c
> @@ -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!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-27 18:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-24 16:29 [PATCH] intel_idle: Fix max_cstate for processor models without C-state tables Chen Yu
2020-10-27 18:05 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome