From c73335a8dc5bd3c114604803b3d6c2d58e45cef3 Mon Sep 17 00:00:00 2001 From: Chen Yu Date: Fri, 3 Jul 2020 17:02:42 +0800 Subject: [PATCH 1886/2944] intel_idle: Customize IceLake server support task #29239886 commit 7f7b2e358b1baa106afe6dec6dacb539d520dc6b linux-pm On ICX platform, the CPU frequency will slowly ramp up when woken up from C-states deeper than/equals to C1E, and since C1E auto-promotion is enabled by default, this might cause unexpected result. Thus this patch disables C1E auto-promotion and expose C1E as a separate idle state, so that the C1E and C6 can be disabled via sysfs when necessary. Besides C1 and C1E, the exit latency of C6 was measured by a dedicated tool. However the exit latency(41us) exposed by _CST is much smaller than the one measured(128us). This is probably due to the _CST uses the exit latency when woken up from PC0+C6, rather than PC6+C6 when C6 was measured. erwei: This patch is coming from linux-pm, which provides the static C-state table for ICX. If not use this patch, the C-state information whould come from the ACPI which result in the cpu cannot enter the C1E and C6 state. And there are some differences between this patch and our kernel. The macro X86_MATCH_INTEL_FAM6_MODEL is used in this patch, but ICPU in source code. So I change them here. Tested-by: Artem Bityutskiy Acked-by: Artem Bityutskiy Signed-off-by: Zhang Rui Signed-off-by: Chen Yu Signed-off-by: Erwei Deng Reviewed-by: Artie Ding --- drivers/idle/intel_idle.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 7bd2aee..24c6995 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -694,6 +694,35 @@ static void intel_idle_s2idle(struct cpuidle_device *dev, .enter = NULL } }; +static struct cpuidle_state icx_cstates[] = { + { + .name = "C1", + .desc = "MWAIT 0x00", + .flags = MWAIT2flg(0x00), + .exit_latency = 1, + .target_residency = 1, + .enter = &intel_idle, + .enter_s2idle = intel_idle_s2idle, }, + { + .name = "C1E", + .desc = "MWAIT 0x01", + .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE, + .exit_latency = 4, + .target_residency = 4, + .enter = &intel_idle, + .enter_s2idle = intel_idle_s2idle, }, + { + .name = "C6", + .desc = "MWAIT 0x20", + .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, + .exit_latency = 128, + .target_residency = 384, + .enter = &intel_idle, + .enter_s2idle = intel_idle_s2idle, }, + { + .enter = NULL } +}; + static struct cpuidle_state atom_cstates[] = { { .name = "C1E", @@ -1097,6 +1126,12 @@ static void c1e_promotion_disable(void) .use_acpi = true, }; +static const struct idle_cpu idle_cpu_icx = { + .state_table = icx_cstates, + .disable_promotion_to_c1e = true, + .use_acpi = true, +}; + static const struct idle_cpu idle_cpu_avn = { .state_table = avn_cstates, .disable_promotion_to_c1e = true, @@ -1154,6 +1189,7 @@ static void c1e_promotion_disable(void) ICPU(INTEL_FAM6_KABYLAKE_MOBILE, idle_cpu_skl), ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, idle_cpu_skl), ICPU(INTEL_FAM6_SKYLAKE_X, idle_cpu_skx), + ICPU(INTEL_FAM6_ICELAKE_X, idle_cpu_icx), ICPU(INTEL_FAM6_XEON_PHI_KNL, idle_cpu_knl), ICPU(INTEL_FAM6_XEON_PHI_KNM, idle_cpu_knl), ICPU(INTEL_FAM6_ATOM_GOLDMONT, idle_cpu_bxt), -- 1.8.3.1