Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Andrew Morton --- arch/x86_64/kernel/tsc.c | 43 +++++++++++-------------------------- 1 files changed, 13 insertions(+), 30 deletions(-) diff -puN arch/x86_64/kernel/tsc.c~time-x86_64-tsc-fixup-clocksource-changes arch/x86_64/kernel/tsc.c --- a/arch/x86_64/kernel/tsc.c~time-x86_64-tsc-fixup-clocksource-changes +++ a/arch/x86_64/kernel/tsc.c @@ -46,13 +46,6 @@ static inline int check_tsc_unstable(voi { return tsc_unstable; } - -void mark_tsc_unstable(void) -{ - tsc_unstable = 1; -} -EXPORT_SYMBOL_GPL(mark_tsc_unstable); - #ifdef CONFIG_CPU_FREQ /* Frequency scaling support. Adjust the TSC based timer when the cpu frequency @@ -143,12 +136,6 @@ core_initcall(cpufreq_tsc); static int tsc_unstable = 0; -void mark_tsc_unstable(void) -{ - tsc_unstable = 1; -} -EXPORT_SYMBOL_GPL(mark_tsc_unstable); - /* * Make an educated guess if the TSC is trustworthy and synchronized * over all CPUs. @@ -187,9 +174,6 @@ __setup("notsc", notsc_setup); /* clock source code: */ - -static int tsc_update_callback(void); - static cycle_t read_tsc(void) { cycle_t ret = (cycle_t)get_cycles_sync(); @@ -200,25 +184,24 @@ static struct clocksource clocksource_ts .name = "tsc", .rating = 300, .read = read_tsc, - .mask = (cycle_t)-1, - .mult = 0, /* to be set */ + .mask = CLOCKSOURCE_MASK(64), .shift = 22, - .update_callback = tsc_update_callback, - .is_continuous = 1, + .flags = CLOCK_SOURCE_IS_CONTINUOUS | + CLOCK_SOURCE_MUST_VERIFY, }; -static int tsc_update_callback(void) +void mark_tsc_unstable(void) { - int change = 0; - - /* check to see if we should switch to the safe clocksource: */ - if (clocksource_tsc.rating != 50 && check_tsc_unstable()) { - clocksource_tsc.rating = 50; - clocksource_reselect(); - change = 1; + if (!tsc_unstable) { + tsc_unstable = 1; + /* Change only the rating, when not registered */ + if (clocksource_tsc.mult) + clocksource_change_rating(&clocksource_tsc, 0); + else + clocksource_tsc.rating = 0; } - return change; } +EXPORT_SYMBOL_GPL(mark_tsc_unstable); static int __init init_tsc_clocksource(void) { @@ -226,7 +209,7 @@ static int __init init_tsc_clocksource(v clocksource_tsc.mult = clocksource_khz2mult(cpu_khz, clocksource_tsc.shift); if (check_tsc_unstable()) - clocksource_tsc.rating = 50; + clocksource_tsc.rating = 0; return clocksource_register(&clocksource_tsc); } _