x86: move tsc definitions to were they belong
[sfrench/cifs-2.6.git] / include / asm-x86 / tsc.h
index 6baab30dc2c8be051e81286bcb9e0ce97d37d724..401303724130b047b861ae2b7f3b1eff3e17108b 100644 (file)
@@ -16,6 +16,10 @@ typedef unsigned long long cycles_t;
 
 extern unsigned int cpu_khz;
 extern unsigned int tsc_khz;
+/* flag for disabling the tsc */
+extern int tsc_disable;
+
+extern void disable_TSC(void);
 
 static inline cycles_t get_cycles(void)
 {
@@ -33,14 +37,14 @@ static inline cycles_t get_cycles(void)
 }
 
 /* Like get_cycles, but make sure the CPU is synchronized. */
-static __always_inline cycles_t get_cycles_sync(void)
+static __always_inline cycles_t __get_cycles_sync(void)
 {
        unsigned long long ret;
        unsigned eax, edx;
 
        /*
-        * Use RDTSCP if possible; it is guaranteed to be synchronous
-        * and doesn't cause a VMEXIT on Hypervisors
+        * Use RDTSCP if possible; it is guaranteed to be synchronous
+        * and doesn't cause a VMEXIT on Hypervisors
         */
        alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP,
                       ASM_OUTPUT2("=a" (eax), "=d" (edx)),
@@ -55,11 +59,40 @@ static __always_inline cycles_t get_cycles_sync(void)
         */
        alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC,
                          "=a" (eax), "0" (1) : "ebx","ecx","edx","memory");
-       rdtscll(ret);
 
+       return 0;
+}
+
+static __always_inline cycles_t get_cycles_sync(void)
+{
+       unsigned long long ret;
+       ret = __get_cycles_sync();
+       if (!ret)
+               rdtscll(ret);
        return ret;
 }
 
+#ifdef CONFIG_PARAVIRT
+/*
+ * For paravirt guests, some functionalities are executed through function
+ * pointers in the various pvops structures.
+ * These function pointers exist inside the kernel and can not
+ * be accessed by user space. To avoid this, we make a copy of the
+ * get_cycles_sync (called in kernel) but force the use of native_read_tsc.
+ * Ideally, the guest should set up it's own clock and vread
+ */
+static __always_inline long long vget_cycles_sync(void)
+{
+       unsigned long long ret;
+       ret = __get_cycles_sync();
+       if (!ret)
+               ret = native_read_tsc();
+       return ret;
+}
+#else
+# define vget_cycles_sync() get_cycles_sync()
+#endif
+
 extern void tsc_init(void);
 extern void mark_tsc_unstable(char *reason);
 extern int unsynchronized_tsc(void);
@@ -73,8 +106,7 @@ int check_tsc_unstable(void);
 extern void check_tsc_sync_source(int cpu);
 extern void check_tsc_sync_target(void);
 
-#ifdef CONFIG_X86_64
 extern void tsc_calibrate(void);
-#endif
+extern int notsc_setup(char *);
 
 #endif