Skip to content

Commit d189604

Browse files
watologo1lenb
authored andcommitted
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: Thomas Renninger <trenn@suse.de> cc: x86@kernel.org Signed-off-by: Len Brown <len.brown@intel.com>
1 parent d8c216c commit d189604

7 files changed

Lines changed: 32 additions & 40 deletions

File tree

‎arch/ia64/include/asm/processor.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,9 @@ prefetchw (const void *x)
717717
#define spin_lock_prefetch(x) prefetchw(x)
718718

719719
extern unsigned long boot_option_idle_override;
720-
extern unsigned long idle_halt;
721-
extern unsigned long idle_nomwait;
720+
721+
enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,
722+
IDLE_NOMWAIT, IDLE_POLL};
722723

723724
#endif /* !__ASSEMBLY__ */
724725

‎arch/ia64/kernel/process.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@
5353

5454
void (*ia64_mark_idle)(int);
5555

56-
unsigned long boot_option_idle_override = 0;
56+
unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
5757
EXPORT_SYMBOL(boot_option_idle_override);
58-
unsigned long idle_halt;
59-
EXPORT_SYMBOL(idle_halt);
60-
unsigned long idle_nomwait;
61-
EXPORT_SYMBOL(idle_nomwait);
6258
void (*pm_idle) (void);
6359
EXPORT_SYMBOL(pm_idle);
6460
void (*pm_power_off) (void);

‎arch/x86/include/asm/processor.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,11 @@ extern void select_idle_routine(const struct cpuinfo_x86 *c);
762762
extern void init_c1e_mask(void);
763763

764764
extern unsigned long boot_option_idle_override;
765-
extern unsigned long idle_halt;
766-
extern unsigned long idle_nomwait;
767765
extern bool c1e_detected;
768766

767+
enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_NOMWAIT,
768+
IDLE_POLL, IDLE_FORCE_MWAIT};
769+
769770
extern void enable_sep_cpu(void);
770771
extern int sysenter_setup(void);
771772

‎arch/x86/kernel/process.c‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
#include <asm/i387.h>
2323
#include <asm/debugreg.h>
2424

25-
unsigned long idle_halt;
26-
EXPORT_SYMBOL(idle_halt);
27-
unsigned long idle_nomwait;
28-
EXPORT_SYMBOL(idle_nomwait);
29-
3025
struct kmem_cache *task_xstate_cachep;
3126
EXPORT_SYMBOL_GPL(task_xstate_cachep);
3227

@@ -328,7 +323,7 @@ long sys_execve(const char __user *name,
328323
/*
329324
* Idle related variables and functions
330325
*/
331-
unsigned long boot_option_idle_override = 0;
326+
unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
332327
EXPORT_SYMBOL(boot_option_idle_override);
333328

334329
/*
@@ -499,7 +494,6 @@ static void poll_idle(void)
499494
*
500495
* idle=mwait overrides this decision and forces the usage of mwait.
501496
*/
502-
static int __cpuinitdata force_mwait;
503497

504498
#define MWAIT_INFO 0x05
505499
#define MWAIT_ECX_EXTENDED_INFO 0x01
@@ -509,7 +503,7 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
509503
{
510504
u32 eax, ebx, ecx, edx;
511505

512-
if (force_mwait)
506+
if (boot_option_idle_override == IDLE_FORCE_MWAIT)
513507
return 1;
514508

515509
if (c->cpuid_level < MWAIT_INFO)
@@ -629,9 +623,10 @@ static int __init idle_setup(char *str)
629623
if (!strcmp(str, "poll")) {
630624
printk("using polling idle threads.\n");
631625
pm_idle = poll_idle;
632-
} else if (!strcmp(str, "mwait"))
633-
force_mwait = 1;
634-
else if (!strcmp(str, "halt")) {
626+
boot_option_idle_override = IDLE_POLL;
627+
} else if (!strcmp(str, "mwait")) {
628+
boot_option_idle_override = IDLE_FORCE_MWAIT;
629+
} else if (!strcmp(str, "halt")) {
635630
/*
636631
* When the boot option of idle=halt is added, halt is
637632
* forced to be used for CPU idle. In such case CPU C2/C3
@@ -640,21 +635,18 @@ static int __init idle_setup(char *str)
640635
* the boot_option_idle_override.
641636
*/
642637
pm_idle = default_idle;
643-
idle_halt = 1;
644-
return 0;
638+
boot_option_idle_override = IDLE_HALT;
645639
} else if (!strcmp(str, "nomwait")) {
646640
/*
647641
* If the boot option of "idle=nomwait" is added,
648642
* it means that mwait will be disabled for CPU C2/C3
649643
* states. In such case it won't touch the variable
650644
* of boot_option_idle_override.
651645
*/
652-
idle_nomwait = 1;
653-
return 0;
646+
boot_option_idle_override = IDLE_NOMWAIT;
654647
} else
655648
return -1;
656649

657-
boot_option_idle_override = 1;
658650
return 0;
659651
}
660652
early_param("idle", idle_setup);

‎drivers/acpi/processor_core.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static int set_no_mwait(const struct dmi_system_id *id)
2323
{
2424
printk(KERN_NOTICE PREFIX "%s detected - "
2525
"disabling mwait for CPU C-states\n", id->ident);
26-
idle_nomwait = 1;
26+
boot_option_idle_override = IDLE_NOMWAIT;
2727
return 0;
2828
}
2929

@@ -283,7 +283,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
283283
{
284284
acpi_status status = AE_OK;
285285

286-
if (idle_nomwait) {
286+
if (boot_option_idle_override == IDLE_NOMWAIT) {
287287
/*
288288
* If mwait is disabled for CPU C-states, the C2C3_FFH access
289289
* mode will be disabled in the parameter of _PDC object.

‎drivers/acpi/processor_idle.c‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ module_param(bm_check_disable, uint, 0000);
7979
static unsigned int latency_factor __read_mostly = 2;
8080
module_param(latency_factor, uint, 0644);
8181

82+
static int disabled_by_idle_boot_param(void)
83+
{
84+
return boot_option_idle_override == IDLE_POLL ||
85+
boot_option_idle_override == IDLE_FORCE_MWAIT ||
86+
boot_option_idle_override == IDLE_HALT;
87+
}
88+
8289
/*
8390
* IBM ThinkPad R40e crashes mysteriously when going into C2 or C3.
8491
* 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)
455462
continue;
456463
}
457464
if (cx.type == ACPI_STATE_C1 &&
458-
(idle_halt || idle_nomwait)) {
465+
(boot_option_idle_override == IDLE_NOMWAIT)) {
459466
/*
460467
* In most cases the C1 space_id obtained from
461468
* _CST object is FIXED_HARDWARE access mode.
@@ -1058,7 +1065,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
10581065
{
10591066
int ret = 0;
10601067

1061-
if (boot_option_idle_override)
1068+
if (disabled_by_idle_boot_param())
10621069
return 0;
10631070

10641071
if (!pr)
@@ -1089,19 +1096,10 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
10891096
acpi_status status = 0;
10901097
static int first_run;
10911098

1092-
if (boot_option_idle_override)
1099+
if (disabled_by_idle_boot_param())
10931100
return 0;
10941101

10951102
if (!first_run) {
1096-
if (idle_halt) {
1097-
/*
1098-
* When the boot option of "idle=halt" is added, halt
1099-
* is used for CPU IDLE.
1100-
* In such case C2/C3 is meaningless. So the max_cstate
1101-
* is set to one.
1102-
*/
1103-
max_cstate = 1;
1104-
}
11051103
dmi_check_system(processor_power_dmi_table);
11061104
max_cstate = acpi_processor_cstate_check(max_cstate);
11071105
if (max_cstate < ACPI_C_STATES_MAX)
@@ -1142,7 +1140,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
11421140
int acpi_processor_power_exit(struct acpi_processor *pr,
11431141
struct acpi_device *device)
11441142
{
1145-
if (boot_option_idle_override)
1143+
if (disabled_by_idle_boot_param())
11461144
return 0;
11471145

11481146
cpuidle_unregister_device(&pr->power.dev);

‎drivers/idle/intel_idle.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ static int __init intel_idle_init(void)
404404
{
405405
int retval;
406406

407+
/* Do not load intel_idle at all for now if idle= is passed */
408+
if (boot_option_idle_override != IDLE_NO_OVERRIDE)
409+
return -ENODEV;
410+
407411
retval = intel_idle_probe();
408412
if (retval)
409413
return retval;

0 commit comments

Comments
 (0)