summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2016-04-04 16:24:59 -0400
committerIngo Molnar <mingo@kernel.org>2016-04-13 05:37:41 -0400
commit59e21e3d00e6bc23186763c3e0bf11baf8924124 (patch)
tree8ab443f82b35233ef5edb2491925a20d61b72c7f
parenta402a8dffc9f838b413c5ee0317d2d3184968f5b (diff)
x86/cpufeature: Replace cpu_has_tsc with boot_cpu_has() usage
Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Thomas Sailer <t.sailer@alumni.ethz.ch> Link: http://lkml.kernel.org/r/1459801503-15600-7-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/cpufeature.h1
-rw-r--r--arch/x86/include/asm/tsc.h2
-rw-r--r--arch/x86/kernel/apic/apic.c10
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/tsc.c12
-rw-r--r--drivers/input/joystick/analog.c6
-rw-r--r--drivers/net/hamradio/baycom_epp.c8
7 files changed, 20 insertions, 21 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index b23d5570a5f4..8f58cd215f6d 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -118,7 +118,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
118 set_bit(bit, (unsigned long *)cpu_caps_set); \ 118 set_bit(bit, (unsigned long *)cpu_caps_set); \
119} while (0) 119} while (0)
120 120
121#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
122#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC) 121#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
123#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR) 122#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
124#define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE) 123#define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)
diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
index 174c4212780a..7428697c5b8d 100644
--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -22,7 +22,7 @@ extern void disable_TSC(void);
22static inline cycles_t get_cycles(void) 22static inline cycles_t get_cycles(void)
23{ 23{
24#ifndef CONFIG_X86_TSC 24#ifndef CONFIG_X86_TSC
25 if (!cpu_has_tsc) 25 if (!boot_cpu_has(X86_FEATURE_TSC))
26 return 0; 26 return 0;
27#endif 27#endif
28 28
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index d7867c885bf8..0b6509f1a4fe 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -607,7 +607,7 @@ static void __init lapic_cal_handler(struct clock_event_device *dev)
607 long tapic = apic_read(APIC_TMCCT); 607 long tapic = apic_read(APIC_TMCCT);
608 unsigned long pm = acpi_pm_read_early(); 608 unsigned long pm = acpi_pm_read_early();
609 609
610 if (cpu_has_tsc) 610 if (boot_cpu_has(X86_FEATURE_TSC))
611 tsc = rdtsc(); 611 tsc = rdtsc();
612 612
613 switch (lapic_cal_loops++) { 613 switch (lapic_cal_loops++) {
@@ -668,7 +668,7 @@ calibrate_by_pmtimer(long deltapm, long *delta, long *deltatsc)
668 *delta = (long)res; 668 *delta = (long)res;
669 669
670 /* Correct the tsc counter value */ 670 /* Correct the tsc counter value */
671 if (cpu_has_tsc) { 671 if (boot_cpu_has(X86_FEATURE_TSC)) {
672 res = (((u64)(*deltatsc)) * pm_100ms); 672 res = (((u64)(*deltatsc)) * pm_100ms);
673 do_div(res, deltapm); 673 do_div(res, deltapm);
674 apic_printk(APIC_VERBOSE, "TSC delta adjusted to " 674 apic_printk(APIC_VERBOSE, "TSC delta adjusted to "
@@ -760,7 +760,7 @@ static int __init calibrate_APIC_clock(void)
760 apic_printk(APIC_VERBOSE, "..... calibration result: %u\n", 760 apic_printk(APIC_VERBOSE, "..... calibration result: %u\n",
761 lapic_timer_frequency); 761 lapic_timer_frequency);
762 762
763 if (cpu_has_tsc) { 763 if (boot_cpu_has(X86_FEATURE_TSC)) {
764 apic_printk(APIC_VERBOSE, "..... CPU clock speed is " 764 apic_printk(APIC_VERBOSE, "..... CPU clock speed is "
765 "%ld.%04ld MHz.\n", 765 "%ld.%04ld MHz.\n",
766 (deltatsc / LAPIC_CAL_LOOPS) / (1000000 / HZ), 766 (deltatsc / LAPIC_CAL_LOOPS) / (1000000 / HZ),
@@ -1227,7 +1227,7 @@ void setup_local_APIC(void)
1227 unsigned long long tsc = 0, ntsc; 1227 unsigned long long tsc = 0, ntsc;
1228 long long max_loops = cpu_khz ? cpu_khz : 1000000; 1228 long long max_loops = cpu_khz ? cpu_khz : 1000000;
1229 1229
1230 if (cpu_has_tsc) 1230 if (boot_cpu_has(X86_FEATURE_TSC))
1231 tsc = rdtsc(); 1231 tsc = rdtsc();
1232 1232
1233 if (disable_apic) { 1233 if (disable_apic) {
@@ -1311,7 +1311,7 @@ void setup_local_APIC(void)
1311 break; 1311 break;
1312 } 1312 }
1313 if (queued) { 1313 if (queued) {
1314 if (cpu_has_tsc && cpu_khz) { 1314 if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
1315 ntsc = rdtsc(); 1315 ntsc = rdtsc();
1316 max_loops = (cpu_khz << 10) - (ntsc - tsc); 1316 max_loops = (cpu_khz << 10) - (ntsc - tsc);
1317 } else 1317 } else
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 28d3255edf00..6bfa36de6d9f 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1558,7 +1558,7 @@ void cpu_init(void)
1558 pr_info("Initializing CPU#%d\n", cpu); 1558 pr_info("Initializing CPU#%d\n", cpu);
1559 1559
1560 if (cpu_feature_enabled(X86_FEATURE_VME) || 1560 if (cpu_feature_enabled(X86_FEATURE_VME) ||
1561 cpu_has_tsc || 1561 boot_cpu_has(X86_FEATURE_TSC) ||
1562 boot_cpu_has(X86_FEATURE_DE)) 1562 boot_cpu_has(X86_FEATURE_DE))
1563 cr4_clear_bits(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); 1563 cr4_clear_bits(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
1564 1564
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index c9c4c7ce3eb2..a0346bc51833 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -36,7 +36,7 @@ static int __read_mostly tsc_unstable;
36 36
37/* native_sched_clock() is called before tsc_init(), so 37/* native_sched_clock() is called before tsc_init(), so
38 we must start with the TSC soft disabled to prevent 38 we must start with the TSC soft disabled to prevent
39 erroneous rdtsc usage on !cpu_has_tsc processors */ 39 erroneous rdtsc usage on !boot_cpu_has(X86_FEATURE_TSC) processors */
40static int __read_mostly tsc_disabled = -1; 40static int __read_mostly tsc_disabled = -1;
41 41
42static DEFINE_STATIC_KEY_FALSE(__use_tsc); 42static DEFINE_STATIC_KEY_FALSE(__use_tsc);
@@ -834,7 +834,7 @@ int recalibrate_cpu_khz(void)
834#ifndef CONFIG_SMP 834#ifndef CONFIG_SMP
835 unsigned long cpu_khz_old = cpu_khz; 835 unsigned long cpu_khz_old = cpu_khz;
836 836
837 if (cpu_has_tsc) { 837 if (boot_cpu_has(X86_FEATURE_TSC)) {
838 tsc_khz = x86_platform.calibrate_tsc(); 838 tsc_khz = x86_platform.calibrate_tsc();
839 cpu_khz = tsc_khz; 839 cpu_khz = tsc_khz;
840 cpu_data(0).loops_per_jiffy = 840 cpu_data(0).loops_per_jiffy =
@@ -956,7 +956,7 @@ static struct notifier_block time_cpufreq_notifier_block = {
956 956
957static int __init cpufreq_tsc(void) 957static int __init cpufreq_tsc(void)
958{ 958{
959 if (!cpu_has_tsc) 959 if (!boot_cpu_has(X86_FEATURE_TSC))
960 return 0; 960 return 0;
961 if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) 961 if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
962 return 0; 962 return 0;
@@ -1081,7 +1081,7 @@ static void __init check_system_tsc_reliable(void)
1081 */ 1081 */
1082int unsynchronized_tsc(void) 1082int unsynchronized_tsc(void)
1083{ 1083{
1084 if (!cpu_has_tsc || tsc_unstable) 1084 if (!boot_cpu_has(X86_FEATURE_TSC) || tsc_unstable)
1085 return 1; 1085 return 1;
1086 1086
1087#ifdef CONFIG_SMP 1087#ifdef CONFIG_SMP
@@ -1205,7 +1205,7 @@ out:
1205 1205
1206static int __init init_tsc_clocksource(void) 1206static int __init init_tsc_clocksource(void)
1207{ 1207{
1208 if (!cpu_has_tsc || tsc_disabled > 0 || !tsc_khz) 1208 if (!boot_cpu_has(X86_FEATURE_TSC) || tsc_disabled > 0 || !tsc_khz)
1209 return 0; 1209 return 0;
1210 1210
1211 if (tsc_clocksource_reliable) 1211 if (tsc_clocksource_reliable)
@@ -1242,7 +1242,7 @@ void __init tsc_init(void)
1242 u64 lpj; 1242 u64 lpj;
1243 int cpu; 1243 int cpu;
1244 1244
1245 if (!cpu_has_tsc) { 1245 if (!boot_cpu_has(X86_FEATURE_TSC)) {
1246 setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); 1246 setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
1247 return; 1247 return;
1248 } 1248 }
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index 6f8b084e13d0..3d8ff09eba57 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -143,9 +143,9 @@ struct analog_port {
143 143
144#include <linux/i8253.h> 144#include <linux/i8253.h>
145 145
146#define GET_TIME(x) do { if (cpu_has_tsc) x = (unsigned int)rdtsc(); else x = get_time_pit(); } while (0) 146#define GET_TIME(x) do { if (boot_cpu_has(X86_FEATURE_TSC)) x = (unsigned int)rdtsc(); else x = get_time_pit(); } while (0)
147#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? PIT_TICK_RATE / HZ : 0))) 147#define DELTA(x,y) (boot_cpu_has(X86_FEATURE_TSC) ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? PIT_TICK_RATE / HZ : 0)))
148#define TIME_NAME (cpu_has_tsc?"TSC":"PIT") 148#define TIME_NAME (boot_cpu_has(X86_FEATURE_TSC)?"TSC":"PIT")
149static unsigned int get_time_pit(void) 149static unsigned int get_time_pit(void)
150{ 150{
151 unsigned long flags; 151 unsigned long flags;
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 72c9f1f352b4..7c7830722ea2 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -635,10 +635,10 @@ static int receive(struct net_device *dev, int cnt)
635 635
636#ifdef __i386__ 636#ifdef __i386__
637#include <asm/msr.h> 637#include <asm/msr.h>
638#define GETTICK(x) \ 638#define GETTICK(x) \
639({ \ 639({ \
640 if (cpu_has_tsc) \ 640 if (boot_cpu_has(X86_FEATURE_TSC)) \
641 x = (unsigned int)rdtsc(); \ 641 x = (unsigned int)rdtsc(); \
642}) 642})
643#else /* __i386__ */ 643#else /* __i386__ */
644#define GETTICK(x) 644#define GETTICK(x)