Skip to content

Commit f3d7eab

Browse files
KAGA-KOKObp3tk0v
authored andcommitted
x86/idle: Cleanup idle_setup()
Updating the static call for x86_idle() from idle_setup() is counter-intuitive. Let select_idle_routine() handle it like the other idle choices, which allows to simplify the idle selection later on. While at it rewrite comments and return a proper error code and not -1. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20240229142248.455616019@linutronix.de
1 parent 0ab5628 commit f3d7eab

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

arch/x86/kernel/process.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,8 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
857857
{
858858
u32 eax, ebx, ecx, edx;
859859

860-
/* User has disallowed the use of MWAIT. Fallback to HALT */
861-
if (boot_option_idle_override == IDLE_NOMWAIT)
860+
/* If override is enforced on the command line, fall back to HALT. */
861+
if (boot_option_idle_override != IDLE_NO_OVERRIDE)
862862
return 0;
863863

864864
/* MWAIT is not supported on this platform. Fallback to HALT */
@@ -976,24 +976,14 @@ static int __init idle_setup(char *str)
976976
boot_option_idle_override = IDLE_POLL;
977977
cpu_idle_poll_ctrl(true);
978978
} else if (!strcmp(str, "halt")) {
979-
/*
980-
* When the boot option of idle=halt is added, halt is
981-
* forced to be used for CPU idle. In such case CPU C2/C3
982-
* won't be used again.
983-
* To continue to load the CPU idle driver, don't touch
984-
* the boot_option_idle_override.
985-
*/
986-
static_call_update(x86_idle, default_idle);
979+
/* 'idle=halt' HALT for idle. C-states are disabled. */
987980
boot_option_idle_override = IDLE_HALT;
988981
} else if (!strcmp(str, "nomwait")) {
989-
/*
990-
* If the boot option of "idle=nomwait" is added,
991-
* it means that mwait will be disabled for CPU C1/C2/C3
992-
* states.
993-
*/
982+
/* 'idle=nomwait' disables MWAIT for idle */
994983
boot_option_idle_override = IDLE_NOMWAIT;
995-
} else
996-
return -1;
984+
} else {
985+
return -EINVAL;
986+
}
997987

998988
return 0;
999989
}

0 commit comments

Comments
 (0)