ar71xx: fix regression in building TL-WDR6500-v2 images
[openwrt/staging/chunkeey.git] / target / linux / x86 / patches-3.18 / 001-x86-platform-Fix-Geode-LX-timekeeping-in-the-generic.patch
1 From: David Woodhouse <dwmw2@infradead.org>
2 Date: Thu, 17 Sep 2015 10:16:54 +0100
3 Subject: [PATCH] x86/platform: Fix Geode LX timekeeping in the generic x86
4 build
5
6 In 2007, commit 07190a08eef36 ("Mark TSC on GeodeLX reliable")
7 bypassed verification of the TSC on Geode LX. However, this code
8 (now in the check_system_tsc_reliable() function in
9 arch/x86/kernel/tsc.c) was only present if CONFIG_MGEODE_LX was
10 set.
11
12 OpenWRT has recently started building its generic Geode target
13 for Geode GX, not LX, to include support for additional
14 platforms. This broke the timekeeping on LX-based devices,
15 because the TSC wasn't marked as reliable:
16 https://dev.openwrt.org/ticket/20531
17
18 By adding a runtime check on is_geode_lx(), we can also include
19 the fix if CONFIG_MGEODEGX1 or CONFIG_X86_GENERIC are set, thus
20 fixing the problem.
21
22 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
23 Signed-off-by: Ingo Molnar <mingo@kernel.org>
24 Closes #20531
25 ---
26
27 --- a/arch/x86/kernel/tsc.c
28 +++ b/arch/x86/kernel/tsc.c
29 @@ -21,6 +21,7 @@
30 #include <asm/hypervisor.h>
31 #include <asm/nmi.h>
32 #include <asm/x86_init.h>
33 +#include <asm/geode.h>
34
35 unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */
36 EXPORT_SYMBOL(cpu_khz);
37 @@ -1004,15 +1005,17 @@ EXPORT_SYMBOL_GPL(mark_tsc_unstable);
38
39 static void __init check_system_tsc_reliable(void)
40 {
41 -#ifdef CONFIG_MGEODE_LX
42 - /* RTSC counts during suspend */
43 +#if defined(CONFIG_MGEODEGX1) || defined(CONFIG_MGEODE_LX) || defined(CONFIG_X86_GENERIC)
44 + if (is_geode_lx()) {
45 + /* RTSC counts during suspend */
46 #define RTSC_SUSP 0x100
47 - unsigned long res_low, res_high;
48 + unsigned long res_low, res_high;
49
50 - rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
51 - /* Geode_LX - the OLPC CPU has a very reliable TSC */
52 - if (res_low & RTSC_SUSP)
53 - tsc_clocksource_reliable = 1;
54 + rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
55 + /* Geode_LX - the OLPC CPU has a very reliable TSC */
56 + if (res_low & RTSC_SUSP)
57 + tsc_clocksource_reliable = 1;
58 + }
59 #endif
60 if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
61 tsc_clocksource_reliable = 1;