From ae858286a957c7ab8f12320a4c4173c35c911513 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Mon, 9 Jun 2008 18:04:27 +0200 Subject: [PATCH] --- yaml --- r: 99429 b: refs/heads/master c: 09fd4b4ef5bc7e5222c13acec1bee8cd252fb63f h: refs/heads/master i: 99427: 690b759a1dea2b30828da8a658efa3c8e3a19907 v: v3 --- [refs] | 2 +- trunk/arch/x86/kernel/process.c | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index f3a8f3806f2b..8b341c4c1572 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 732d7be17b98ebfd59e5864c3490f19856fa832c +refs/heads/master: 09fd4b4ef5bc7e5222c13acec1bee8cd252fb63f diff --git a/trunk/arch/x86/kernel/process.c b/trunk/arch/x86/kernel/process.c index b3078f4ce25b..fe415ba606e0 100644 --- a/trunk/arch/x86/kernel/process.c +++ b/trunk/arch/x86/kernel/process.c @@ -122,19 +122,31 @@ static void poll_idle(void) * * idle=mwait overrides this decision and forces the usage of mwait. */ + +#define MWAIT_INFO 0x05 +#define MWAIT_ECX_EXTENDED_INFO 0x01 +#define MWAIT_EDX_C1 0xf0 + static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c) { + u32 eax, ebx, ecx, edx; + if (force_mwait) return 1; - if (c->x86_vendor == X86_VENDOR_AMD) { - switch(c->x86) { - case 0x10: - case 0x11: - return 0; - } - } - return 1; + if (c->cpuid_level < MWAIT_INFO) + return 0; + + cpuid(MWAIT_INFO, &eax, &ebx, &ecx, &edx); + /* Check, whether EDX has extended info about MWAIT */ + if (!(ecx & MWAIT_ECX_EXTENDED_INFO)) + return 1; + + /* + * edx enumeratios MONITOR/MWAIT extensions. Check, whether + * C1 supports MWAIT + */ + return (edx & MWAIT_EDX_C1); } void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)