From: Ross Lagerwall Subject: [PATCH] x86/mwait_idle: Allow setting the max cstate to C1 Date: Mon, 2 Jun 2014 15:43:50 +0100 Message-ID: <1401720230-3147-1-git-send-email-ross.lagerwall@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WrTTb-0007z7-JC for xen-devel@lists.xenproject.org; Mon, 02 Jun 2014 14:44:39 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ross Lagerwall , Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org From: Ross Lagerwall Following 91413b519631 ("x86/mwait_idle: export both C1 and C1E"), when setting the max cstate to C1, the C1E cstate is used as well. This is because MWAIT_HINT2CSTATE returns the same value for C1 and C1E. Instead, when limiting the cstate, compare max_cstate with the position in the states array, as the acpi cpu_idle driver does. Without this patch, there's no way of setting the max cstate to C1 when using the mwait_idle driver. Signed-off-by: Ross Lagerwall --- xen/arch/x86/cpu/mwait-idle.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c index 72a7abf..e4cfc16 100644 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -328,11 +328,9 @@ static void mwait_idle(void) if (max_cstate > 0 && power && !sched_has_urgent_vcpu() && (next_state = cpuidle_current_governor->select(power)) > 0) { - do { - cx = &power->states[next_state]; - } while (cx->type > max_cstate && --next_state); - if (!next_state) - cx = NULL; + cx = &power->states[next_state]; + if (cx->idx > max_cstate) + cx = &power->states[max_cstate]; menu_get_trace_data(&exp, &pred); } if (!cx) { @@ -585,6 +583,7 @@ static int mwait_idle_cpu_init(struct notifier_block *nfb, setup_clear_cpu_cap(X86_FEATURE_TSC_RELIABLE); cx = dev->states + dev->count; + cx->idx = dev->count; cx->type = state; cx->address = hint; cx->entry_method = ACPI_CSTATE_EM_FFH; -- 1.9.3