Commit d1896049 authored by Thomas Renninger's avatar Thomas Renninger Committed by Len Brown

ACPI, intel_idle: Cleanup idle= internal variables

Having four variables for the same thing:
  idle_halt, idle_nomwait, force_mwait and boot_option_idle_overrides
is rather confusing and unnecessary complex.

if idle= boot param is passed, only set up one variable:
boot_option_idle_overrides

Introduces following functional changes/fixes:
  - intel_idle driver does not register if any idle=xy
    boot param is passed.
  - processor_idle.c will also not register a cpuidle driver
    and get active if idle=halt is passed.
    Before a cpuidle driver with one (C1, halt) state got registered
    Now the default_idle function will be used which finally uses
    the same idle call to enter sleep state (safe_halt()), but
    without registering a whole cpuidle driver.

That means idle= param will always avoid cpuidle drivers to register
with one exception (same behavior as before):
idle=nomwait
may still register acpi_idle cpuidle driver, but C1 will not use
mwait, but hlt. This can be a workaround for IO based deeper sleep
states where C1 mwait causes problems.
Signed-off-by: default avatarThomas Renninger <trenn@suse.de>
cc: x86@kernel.org
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent d8c216cf
...@@ -717,8 +717,9 @@ prefetchw (const void *x) ...@@ -717,8 +717,9 @@ prefetchw (const void *x)
#define spin_lock_prefetch(x) prefetchw(x) #define spin_lock_prefetch(x) prefetchw(x)
extern unsigned long boot_option_idle_override; extern unsigned long boot_option_idle_override;
extern unsigned long idle_halt;
extern unsigned long idle_nomwait; enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,
IDLE_NOMWAIT, IDLE_POLL};
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
......
...@@ -53,12 +53,8 @@ ...@@ -53,12 +53,8 @@
void (*ia64_mark_idle)(int); void (*ia64_mark_idle)(int);
unsigned long boot_option_idle_override = 0; unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
EXPORT_SYMBOL(boot_option_idle_override); EXPORT_SYMBOL(boot_option_idle_override);
unsigned long idle_halt;
EXPORT_SYMBOL(idle_halt);
unsigned long idle_nomwait;
EXPORT_SYMBOL(idle_nomwait);
void (*pm_idle) (void); void (*pm_idle) (void);
EXPORT_SYMBOL(pm_idle); EXPORT_SYMBOL(pm_idle);
void (*pm_power_off) (void); void (*pm_power_off) (void);
......
...@@ -762,10 +762,11 @@ extern void select_idle_routine(const struct cpuinfo_x86 *c); ...@@ -762,10 +762,11 @@ extern void select_idle_routine(const struct cpuinfo_x86 *c);
extern void init_c1e_mask(void); extern void init_c1e_mask(void);
extern unsigned long boot_option_idle_override; extern unsigned long boot_option_idle_override;
extern unsigned long idle_halt;
extern unsigned long idle_nomwait;
extern bool c1e_detected; extern bool c1e_detected;
enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_NOMWAIT,
IDLE_POLL, IDLE_FORCE_MWAIT};
extern void enable_sep_cpu(void); extern void enable_sep_cpu(void);
extern int sysenter_setup(void); extern int sysenter_setup(void);
......
...@@ -22,11 +22,6 @@ ...@@ -22,11 +22,6 @@
#include <asm/i387.h> #include <asm/i387.h>
#include <asm/debugreg.h> #include <asm/debugreg.h>
unsigned long idle_halt;
EXPORT_SYMBOL(idle_halt);
unsigned long idle_nomwait;
EXPORT_SYMBOL(idle_nomwait);
struct kmem_cache *task_xstate_cachep; struct kmem_cache *task_xstate_cachep;
EXPORT_SYMBOL_GPL(task_xstate_cachep); EXPORT_SYMBOL_GPL(task_xstate_cachep);
...@@ -328,7 +323,7 @@ long sys_execve(const char __user *name, ...@@ -328,7 +323,7 @@ long sys_execve(const char __user *name,
/* /*
* Idle related variables and functions * Idle related variables and functions
*/ */
unsigned long boot_option_idle_override = 0; unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
EXPORT_SYMBOL(boot_option_idle_override); EXPORT_SYMBOL(boot_option_idle_override);
/* /*
...@@ -499,7 +494,6 @@ static void poll_idle(void) ...@@ -499,7 +494,6 @@ static void poll_idle(void)
* *
* idle=mwait overrides this decision and forces the usage of mwait. * idle=mwait overrides this decision and forces the usage of mwait.
*/ */
static int __cpuinitdata force_mwait;
#define MWAIT_INFO 0x05 #define MWAIT_INFO 0x05
#define MWAIT_ECX_EXTENDED_INFO 0x01 #define MWAIT_ECX_EXTENDED_INFO 0x01
...@@ -509,7 +503,7 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c) ...@@ -509,7 +503,7 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
{ {
u32 eax, ebx, ecx, edx; u32 eax, ebx, ecx, edx;
if (force_mwait) if (boot_option_idle_override == IDLE_FORCE_MWAIT)
return 1; return 1;
if (c->cpuid_level < MWAIT_INFO) if (c->cpuid_level < MWAIT_INFO)
...@@ -629,9 +623,10 @@ static int __init idle_setup(char *str) ...@@ -629,9 +623,10 @@ static int __init idle_setup(char *str)
if (!strcmp(str, "poll")) { if (!strcmp(str, "poll")) {
printk("using polling idle threads.\n"); printk("using polling idle threads.\n");
pm_idle = poll_idle; pm_idle = poll_idle;
} else if (!strcmp(str, "mwait")) boot_option_idle_override = IDLE_POLL;
force_mwait = 1; } else if (!strcmp(str, "mwait")) {
else if (!strcmp(str, "halt")) { boot_option_idle_override = IDLE_FORCE_MWAIT;
} else if (!strcmp(str, "halt")) {
/* /*
* When the boot option of idle=halt is added, halt is * When the boot option of idle=halt is added, halt is
* forced to be used for CPU idle. In such case CPU C2/C3 * forced to be used for CPU idle. In such case CPU C2/C3
...@@ -640,8 +635,7 @@ static int __init idle_setup(char *str) ...@@ -640,8 +635,7 @@ static int __init idle_setup(char *str)
* the boot_option_idle_override. * the boot_option_idle_override.
*/ */
pm_idle = default_idle; pm_idle = default_idle;
idle_halt = 1; boot_option_idle_override = IDLE_HALT;
return 0;
} else if (!strcmp(str, "nomwait")) { } else if (!strcmp(str, "nomwait")) {
/* /*
* If the boot option of "idle=nomwait" is added, * If the boot option of "idle=nomwait" is added,
...@@ -649,12 +643,10 @@ static int __init idle_setup(char *str) ...@@ -649,12 +643,10 @@ static int __init idle_setup(char *str)
* states. In such case it won't touch the variable * states. In such case it won't touch the variable
* of boot_option_idle_override. * of boot_option_idle_override.
*/ */
idle_nomwait = 1; boot_option_idle_override = IDLE_NOMWAIT;
return 0;
} else } else
return -1; return -1;
boot_option_idle_override = 1;
return 0; return 0;
} }
early_param("idle", idle_setup); early_param("idle", idle_setup);
......
...@@ -23,7 +23,7 @@ static int set_no_mwait(const struct dmi_system_id *id) ...@@ -23,7 +23,7 @@ static int set_no_mwait(const struct dmi_system_id *id)
{ {
printk(KERN_NOTICE PREFIX "%s detected - " printk(KERN_NOTICE PREFIX "%s detected - "
"disabling mwait for CPU C-states\n", id->ident); "disabling mwait for CPU C-states\n", id->ident);
idle_nomwait = 1; boot_option_idle_override = IDLE_NOMWAIT;
return 0; return 0;
} }
...@@ -283,7 +283,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) ...@@ -283,7 +283,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
{ {
acpi_status status = AE_OK; acpi_status status = AE_OK;
if (idle_nomwait) { if (boot_option_idle_override == IDLE_NOMWAIT) {
/* /*
* If mwait is disabled for CPU C-states, the C2C3_FFH access * If mwait is disabled for CPU C-states, the C2C3_FFH access
* mode will be disabled in the parameter of _PDC object. * mode will be disabled in the parameter of _PDC object.
......
...@@ -79,6 +79,13 @@ module_param(bm_check_disable, uint, 0000); ...@@ -79,6 +79,13 @@ module_param(bm_check_disable, uint, 0000);
static unsigned int latency_factor __read_mostly = 2; static unsigned int latency_factor __read_mostly = 2;
module_param(latency_factor, uint, 0644); module_param(latency_factor, uint, 0644);
static int disabled_by_idle_boot_param(void)
{
return boot_option_idle_override == IDLE_POLL ||
boot_option_idle_override == IDLE_FORCE_MWAIT ||
boot_option_idle_override == IDLE_HALT;
}
/* /*
* IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3.
* For now disable this. Probably a bug somewhere else. * For now disable this. Probably a bug somewhere else.
...@@ -455,7 +462,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) ...@@ -455,7 +462,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
continue; continue;
} }
if (cx.type == ACPI_STATE_C1 && if (cx.type == ACPI_STATE_C1 &&
(idle_halt || idle_nomwait)) { (boot_option_idle_override == IDLE_NOMWAIT)) {
/* /*
* In most cases the C1 space_id obtained from * In most cases the C1 space_id obtained from
* _CST object is FIXED_HARDWARE access mode. * _CST object is FIXED_HARDWARE access mode.
...@@ -1058,7 +1065,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) ...@@ -1058,7 +1065,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
{ {
int ret = 0; int ret = 0;
if (boot_option_idle_override) if (disabled_by_idle_boot_param())
return 0; return 0;
if (!pr) if (!pr)
...@@ -1089,19 +1096,10 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, ...@@ -1089,19 +1096,10 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
acpi_status status = 0; acpi_status status = 0;
static int first_run; static int first_run;
if (boot_option_idle_override) if (disabled_by_idle_boot_param())
return 0; return 0;
if (!first_run) { if (!first_run) {
if (idle_halt) {
/*
* When the boot option of "idle=halt" is added, halt
* is used for CPU IDLE.
* In such case C2/C3 is meaningless. So the max_cstate
* is set to one.
*/
max_cstate = 1;
}
dmi_check_system(processor_power_dmi_table); dmi_check_system(processor_power_dmi_table);
max_cstate = acpi_processor_cstate_check(max_cstate); max_cstate = acpi_processor_cstate_check(max_cstate);
if (max_cstate < ACPI_C_STATES_MAX) if (max_cstate < ACPI_C_STATES_MAX)
...@@ -1142,7 +1140,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, ...@@ -1142,7 +1140,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
int acpi_processor_power_exit(struct acpi_processor *pr, int acpi_processor_power_exit(struct acpi_processor *pr,
struct acpi_device *device) struct acpi_device *device)
{ {
if (boot_option_idle_override) if (disabled_by_idle_boot_param())
return 0; return 0;
cpuidle_unregister_device(&pr->power.dev); cpuidle_unregister_device(&pr->power.dev);
......
...@@ -404,6 +404,10 @@ static int __init intel_idle_init(void) ...@@ -404,6 +404,10 @@ static int __init intel_idle_init(void)
{ {
int retval; int retval;
/* Do not load intel_idle at all for now if idle= is passed */
if (boot_option_idle_override != IDLE_NO_OVERRIDE)
return -ENODEV;
retval = intel_idle_probe(); retval = intel_idle_probe();
if (retval) if (retval)
return retval; return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment