Commit 3c2047cd authored by Rusty Russell's avatar Rusty Russell Committed by Ingo Molnar

x86: if we cannot calibrate the TSC, we panic.

The current tsc_init() clears the TSC feature bit if the TSC khz
cannot be calculated, causing us to panic in
arch/x86/kernel/cpu/bugs.c check_config().  We should simply mark it
unstable.

Frankly, someone should take an axe to this code.  mark_tsc_unstable()
not only marks it unstable, but sets tsc_enabled to 0, which seems
redundant but is actually important here because means it won't be
used by sched_clock() either.  Perhaps a tristate enum "UNUSABLE,
UNSTABLE, OK" would be clearer, and separate mark_tsc_unstable() and
mark_tsc_broken() functions?
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 9fc34113
...@@ -392,13 +392,15 @@ void __init tsc_init(void) ...@@ -392,13 +392,15 @@ void __init tsc_init(void)
int cpu; int cpu;
if (!cpu_has_tsc) if (!cpu_has_tsc)
goto out_no_tsc; return;
cpu_khz = calculate_cpu_khz(); cpu_khz = calculate_cpu_khz();
tsc_khz = cpu_khz; tsc_khz = cpu_khz;
if (!cpu_khz) if (!cpu_khz) {
goto out_no_tsc; mark_tsc_unstable("could not calculate TSC khz");
return;
}
printk("Detected %lu.%03lu MHz processor.\n", printk("Detected %lu.%03lu MHz processor.\n",
(unsigned long)cpu_khz / 1000, (unsigned long)cpu_khz / 1000,
...@@ -431,9 +433,4 @@ void __init tsc_init(void) ...@@ -431,9 +433,4 @@ void __init tsc_init(void)
tsc_enabled = 1; tsc_enabled = 1;
clocksource_register(&clocksource_tsc); clocksource_register(&clocksource_tsc);
return;
out_no_tsc:
setup_clear_cpu_cap(X86_FEATURE_TSC);
} }
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