]>
Commit | Line | Data |
---|---|---|
d11f37ce GKH |
1 | From e9088adda13cd23249d4b0abb97ff8a81bf5573a Mon Sep 17 00:00:00 2001 |
2 | From: Peter Zijlstra <peterz@infradead.org> | |
3 | Date: Mon, 30 Apr 2018 12:00:09 +0200 | |
4 | Subject: x86/tsc: Always unregister clocksource_tsc_early | |
5 | ||
6 | From: Peter Zijlstra <peterz@infradead.org> | |
7 | ||
8 | commit e9088adda13cd23249d4b0abb97ff8a81bf5573a upstream. | |
9 | ||
10 | Don't leave the tsc-early clocksource registered if it errors out | |
11 | early. | |
12 | ||
13 | This was reported by Diego, who on his Core2 era machine got TSC | |
14 | invalidated while it was running with tsc-early (due to C-states). | |
15 | This results in keeping tsc-early with very bad effects. | |
16 | ||
17 | Reported-and-Tested-by: Diego Viola <diego.viola@gmail.com> | |
18 | Fixes: aa83c45762a2 ("x86/tsc: Introduce early tsc clocksource") | |
19 | Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> | |
20 | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> | |
21 | Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
22 | Cc: len.brown@intel.com | |
23 | Cc: rjw@rjwysocki.net | |
24 | Cc: diego.viola@gmail.com | |
25 | Cc: rui.zhang@intel.com | |
26 | Cc: stable@vger.kernel.org | |
27 | Link: https://lkml.kernel.org/r/20180430100344.350507853@infradead.org | |
28 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
29 | ||
30 | --- | |
31 | arch/x86/kernel/tsc.c | 10 ++++++---- | |
32 | 1 file changed, 6 insertions(+), 4 deletions(-) | |
33 | ||
34 | --- a/arch/x86/kernel/tsc.c | |
35 | +++ b/arch/x86/kernel/tsc.c | |
36 | @@ -1205,7 +1205,7 @@ static void tsc_refine_calibration_work( | |
37 | ||
38 | /* Don't bother refining TSC on unstable systems */ | |
39 | if (tsc_unstable) | |
40 | - return; | |
41 | + goto unreg; | |
42 | ||
43 | /* | |
44 | * Since the work is started early in boot, we may be | |
45 | @@ -1258,11 +1258,12 @@ static void tsc_refine_calibration_work( | |
46 | ||
47 | out: | |
48 | if (tsc_unstable) | |
49 | - return; | |
50 | + goto unreg; | |
51 | ||
52 | if (boot_cpu_has(X86_FEATURE_ART)) | |
53 | art_related_clocksource = &clocksource_tsc; | |
54 | clocksource_register_khz(&clocksource_tsc, tsc_khz); | |
55 | +unreg: | |
56 | clocksource_unregister(&clocksource_tsc_early); | |
57 | } | |
58 | ||
59 | @@ -1272,8 +1273,8 @@ static int __init init_tsc_clocksource(v | |
60 | if (!boot_cpu_has(X86_FEATURE_TSC) || tsc_disabled > 0 || !tsc_khz) | |
61 | return 0; | |
62 | ||
63 | - if (check_tsc_unstable()) | |
64 | - return 0; | |
65 | + if (tsc_unstable) | |
66 | + goto unreg; | |
67 | ||
68 | if (tsc_clocksource_reliable) | |
69 | clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY; | |
70 | @@ -1289,6 +1290,7 @@ static int __init init_tsc_clocksource(v | |
71 | if (boot_cpu_has(X86_FEATURE_ART)) | |
72 | art_related_clocksource = &clocksource_tsc; | |
73 | clocksource_register_khz(&clocksource_tsc, tsc_khz); | |
74 | +unreg: | |
75 | clocksource_unregister(&clocksource_tsc_early); | |
76 | return 0; | |
77 | } |