diff options
| -rw-r--r-- | arch/x86/include/asm/tsc.h | 1 | ||||
| -rw-r--r-- | arch/x86/kernel/tsc.c | 25 | ||||
| -rw-r--r-- | arch/x86/kernel/x86_init.c | 2 |
3 files changed, 20 insertions, 8 deletions
diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h index 88140e4f2292..eb5bbfeccb66 100644 --- a/arch/x86/include/asm/tsc.h +++ b/arch/x86/include/asm/tsc.h | |||
| @@ -39,7 +39,6 @@ extern void mark_tsc_unstable(char *reason); | |||
| 39 | extern int unsynchronized_tsc(void); | 39 | extern int unsynchronized_tsc(void); |
| 40 | extern int check_tsc_unstable(void); | 40 | extern int check_tsc_unstable(void); |
| 41 | extern void mark_tsc_async_resets(char *reason); | 41 | extern void mark_tsc_async_resets(char *reason); |
| 42 | extern unsigned long native_calibrate_cpu(void); | ||
| 43 | extern unsigned long native_calibrate_cpu_early(void); | 42 | extern unsigned long native_calibrate_cpu_early(void); |
| 44 | extern unsigned long native_calibrate_tsc(void); | 43 | extern unsigned long native_calibrate_tsc(void); |
| 45 | extern unsigned long long native_sched_clock_from_tsc(u64 tsc); | 44 | extern unsigned long long native_sched_clock_from_tsc(u64 tsc); |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 60586779b02c..02e416b87ac1 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
| @@ -854,7 +854,7 @@ unsigned long native_calibrate_cpu_early(void) | |||
| 854 | /** | 854 | /** |
| 855 | * native_calibrate_cpu - calibrate the cpu | 855 | * native_calibrate_cpu - calibrate the cpu |
| 856 | */ | 856 | */ |
| 857 | unsigned long native_calibrate_cpu(void) | 857 | static unsigned long native_calibrate_cpu(void) |
| 858 | { | 858 | { |
| 859 | unsigned long tsc_freq = native_calibrate_cpu_early(); | 859 | unsigned long tsc_freq = native_calibrate_cpu_early(); |
| 860 | 860 | ||
| @@ -1374,13 +1374,19 @@ unreg: | |||
| 1374 | */ | 1374 | */ |
| 1375 | device_initcall(init_tsc_clocksource); | 1375 | device_initcall(init_tsc_clocksource); |
| 1376 | 1376 | ||
| 1377 | static bool __init determine_cpu_tsc_frequencies(void) | 1377 | static bool __init determine_cpu_tsc_frequencies(bool early) |
| 1378 | { | 1378 | { |
| 1379 | /* Make sure that cpu and tsc are not already calibrated */ | 1379 | /* Make sure that cpu and tsc are not already calibrated */ |
| 1380 | WARN_ON(cpu_khz || tsc_khz); | 1380 | WARN_ON(cpu_khz || tsc_khz); |
| 1381 | 1381 | ||
| 1382 | cpu_khz = x86_platform.calibrate_cpu(); | 1382 | if (early) { |
| 1383 | tsc_khz = x86_platform.calibrate_tsc(); | 1383 | cpu_khz = x86_platform.calibrate_cpu(); |
| 1384 | tsc_khz = x86_platform.calibrate_tsc(); | ||
| 1385 | } else { | ||
| 1386 | /* We should not be here with non-native cpu calibration */ | ||
| 1387 | WARN_ON(x86_platform.calibrate_cpu != native_calibrate_cpu); | ||
| 1388 | cpu_khz = pit_hpet_ptimer_calibrate_cpu(); | ||
| 1389 | } | ||
| 1384 | 1390 | ||
| 1385 | /* | 1391 | /* |
| 1386 | * Trust non-zero tsc_khz as authorative, | 1392 | * Trust non-zero tsc_khz as authorative, |
| @@ -1419,7 +1425,7 @@ void __init tsc_early_init(void) | |||
| 1419 | { | 1425 | { |
| 1420 | if (!boot_cpu_has(X86_FEATURE_TSC)) | 1426 | if (!boot_cpu_has(X86_FEATURE_TSC)) |
| 1421 | return; | 1427 | return; |
| 1422 | if (!determine_cpu_tsc_frequencies()) | 1428 | if (!determine_cpu_tsc_frequencies(true)) |
| 1423 | return; | 1429 | return; |
| 1424 | loops_per_jiffy = get_loops_per_jiffy(); | 1430 | loops_per_jiffy = get_loops_per_jiffy(); |
| 1425 | 1431 | ||
| @@ -1431,6 +1437,13 @@ void __init tsc_early_init(void) | |||
| 1431 | 1437 | ||
| 1432 | void __init tsc_init(void) | 1438 | void __init tsc_init(void) |
| 1433 | { | 1439 | { |
| 1440 | /* | ||
| 1441 | * native_calibrate_cpu_early can only calibrate using methods that are | ||
| 1442 | * available early in boot. | ||
| 1443 | */ | ||
| 1444 | if (x86_platform.calibrate_cpu == native_calibrate_cpu_early) | ||
| 1445 | x86_platform.calibrate_cpu = native_calibrate_cpu; | ||
| 1446 | |||
| 1434 | if (!boot_cpu_has(X86_FEATURE_TSC)) { | 1447 | if (!boot_cpu_has(X86_FEATURE_TSC)) { |
| 1435 | setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); | 1448 | setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); |
| 1436 | return; | 1449 | return; |
| @@ -1438,7 +1451,7 @@ void __init tsc_init(void) | |||
| 1438 | 1451 | ||
| 1439 | if (!tsc_khz) { | 1452 | if (!tsc_khz) { |
| 1440 | /* We failed to determine frequencies earlier, try again */ | 1453 | /* We failed to determine frequencies earlier, try again */ |
| 1441 | if (!determine_cpu_tsc_frequencies()) { | 1454 | if (!determine_cpu_tsc_frequencies(false)) { |
| 1442 | mark_tsc_unstable("could not calculate TSC khz"); | 1455 | mark_tsc_unstable("could not calculate TSC khz"); |
| 1443 | setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); | 1456 | setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); |
| 1444 | return; | 1457 | return; |
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 3ab867603e81..2792b5573818 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c | |||
| @@ -109,7 +109,7 @@ struct x86_cpuinit_ops x86_cpuinit = { | |||
| 109 | static void default_nmi_init(void) { }; | 109 | static void default_nmi_init(void) { }; |
| 110 | 110 | ||
| 111 | struct x86_platform_ops x86_platform __ro_after_init = { | 111 | struct x86_platform_ops x86_platform __ro_after_init = { |
| 112 | .calibrate_cpu = native_calibrate_cpu, | 112 | .calibrate_cpu = native_calibrate_cpu_early, |
| 113 | .calibrate_tsc = native_calibrate_tsc, | 113 | .calibrate_tsc = native_calibrate_tsc, |
| 114 | .get_wallclock = mach_get_cmos_time, | 114 | .get_wallclock = mach_get_cmos_time, |
| 115 | .set_wallclock = mach_set_rtc_mmss, | 115 | .set_wallclock = mach_set_rtc_mmss, |
