0001
0002
0003
0004
0005 #ifndef _ASM_X86_TSC_H
0006 #define _ASM_X86_TSC_H
0007
0008 #include <asm/processor.h>
0009 #include <asm/cpufeature.h>
0010
0011
0012
0013
0014 typedef unsigned long long cycles_t;
0015
0016 extern unsigned int cpu_khz;
0017 extern unsigned int tsc_khz;
0018
0019 extern void disable_TSC(void);
0020
0021 static inline cycles_t get_cycles(void)
0022 {
0023 if (!IS_ENABLED(CONFIG_X86_TSC) &&
0024 !cpu_feature_enabled(X86_FEATURE_TSC))
0025 return 0;
0026 return rdtsc();
0027 }
0028 #define get_cycles get_cycles
0029
0030 extern struct system_counterval_t convert_art_to_tsc(u64 art);
0031 extern struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns);
0032
0033 extern void tsc_early_init(void);
0034 extern void tsc_init(void);
0035 extern unsigned long calibrate_delay_is_known(void);
0036 extern void mark_tsc_unstable(char *reason);
0037 extern int unsynchronized_tsc(void);
0038 extern int check_tsc_unstable(void);
0039 extern void mark_tsc_async_resets(char *reason);
0040 extern unsigned long native_calibrate_cpu_early(void);
0041 extern unsigned long native_calibrate_tsc(void);
0042 extern unsigned long long native_sched_clock_from_tsc(u64 tsc);
0043
0044 extern int tsc_clocksource_reliable;
0045 #ifdef CONFIG_X86_TSC
0046 extern bool tsc_async_resets;
0047 #else
0048 # define tsc_async_resets false
0049 #endif
0050
0051
0052
0053
0054
0055 #ifdef CONFIG_X86_TSC
0056 extern bool tsc_store_and_check_tsc_adjust(bool bootcpu);
0057 extern void tsc_verify_tsc_adjust(bool resume);
0058 extern void check_tsc_sync_source(int cpu);
0059 extern void check_tsc_sync_target(void);
0060 #else
0061 static inline bool tsc_store_and_check_tsc_adjust(bool bootcpu) { return false; }
0062 static inline void tsc_verify_tsc_adjust(bool resume) { }
0063 static inline void check_tsc_sync_source(int cpu) { }
0064 static inline void check_tsc_sync_target(void) { }
0065 #endif
0066
0067 extern int notsc_setup(char *);
0068 extern void tsc_save_sched_clock_state(void);
0069 extern void tsc_restore_sched_clock_state(void);
0070
0071 unsigned long cpu_khz_from_msr(void);
0072
0073 #endif