diff options
Diffstat (limited to 'include/asm-x86/tsc.h')
-rw-r--r-- | include/asm-x86/tsc.h | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/include/asm-x86/tsc.h b/include/asm-x86/tsc.h index 6baab30dc2c8..7d3e27f7d484 100644 --- a/include/asm-x86/tsc.h +++ b/include/asm-x86/tsc.h | |||
@@ -17,6 +17,8 @@ typedef unsigned long long cycles_t; | |||
17 | extern unsigned int cpu_khz; | 17 | extern unsigned int cpu_khz; |
18 | extern unsigned int tsc_khz; | 18 | extern unsigned int tsc_khz; |
19 | 19 | ||
20 | extern void disable_TSC(void); | ||
21 | |||
20 | static inline cycles_t get_cycles(void) | 22 | static inline cycles_t get_cycles(void) |
21 | { | 23 | { |
22 | unsigned long long ret = 0; | 24 | unsigned long long ret = 0; |
@@ -25,39 +27,22 @@ static inline cycles_t get_cycles(void) | |||
25 | if (!cpu_has_tsc) | 27 | if (!cpu_has_tsc) |
26 | return 0; | 28 | return 0; |
27 | #endif | 29 | #endif |
28 | |||
29 | #if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC) | ||
30 | rdtscll(ret); | 30 | rdtscll(ret); |
31 | #endif | 31 | |
32 | return ret; | 32 | return ret; |
33 | } | 33 | } |
34 | 34 | ||
35 | /* Like get_cycles, but make sure the CPU is synchronized. */ | 35 | static inline cycles_t vget_cycles(void) |
36 | static __always_inline cycles_t get_cycles_sync(void) | ||
37 | { | 36 | { |
38 | unsigned long long ret; | ||
39 | unsigned eax, edx; | ||
40 | |||
41 | /* | ||
42 | * Use RDTSCP if possible; it is guaranteed to be synchronous | ||
43 | * and doesn't cause a VMEXIT on Hypervisors | ||
44 | */ | ||
45 | alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP, | ||
46 | ASM_OUTPUT2("=a" (eax), "=d" (edx)), | ||
47 | "a" (0U), "d" (0U) : "ecx", "memory"); | ||
48 | ret = (((unsigned long long)edx) << 32) | ((unsigned long long)eax); | ||
49 | if (ret) | ||
50 | return ret; | ||
51 | |||
52 | /* | 37 | /* |
53 | * Don't do an additional sync on CPUs where we know | 38 | * We only do VDSOs on TSC capable CPUs, so this shouldnt |
54 | * RDTSC is already synchronous: | 39 | * access boot_cpu_data (which is not VDSO-safe): |
55 | */ | 40 | */ |
56 | alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC, | 41 | #ifndef CONFIG_X86_TSC |
57 | "=a" (eax), "0" (1) : "ebx","ecx","edx","memory"); | 42 | if (!cpu_has_tsc) |
58 | rdtscll(ret); | 43 | return 0; |
59 | 44 | #endif | |
60 | return ret; | 45 | return (cycles_t) __native_read_tsc(); |
61 | } | 46 | } |
62 | 47 | ||
63 | extern void tsc_init(void); | 48 | extern void tsc_init(void); |
@@ -73,8 +58,7 @@ int check_tsc_unstable(void); | |||
73 | extern void check_tsc_sync_source(int cpu); | 58 | extern void check_tsc_sync_source(int cpu); |
74 | extern void check_tsc_sync_target(void); | 59 | extern void check_tsc_sync_target(void); |
75 | 60 | ||
76 | #ifdef CONFIG_X86_64 | ||
77 | extern void tsc_calibrate(void); | 61 | extern void tsc_calibrate(void); |
78 | #endif | 62 | extern int notsc_setup(char *); |
79 | 63 | ||
80 | #endif | 64 | #endif |