This source file includes following definitions.
- hv_read_tsc_page_tsc
- hv_read_tsc_page
- hv_get_tsc_page
- hv_read_tsc_page_tsc
1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef __CLKSOURCE_HYPERV_TIMER_H
14 #define __CLKSOURCE_HYPERV_TIMER_H
15
16 #include <linux/clocksource.h>
17 #include <linux/math64.h>
18 #include <asm/mshyperv.h>
19
20 #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
21 #define HV_MIN_DELTA_TICKS 1
22
23
24 extern int hv_stimer_alloc(int sint);
25 extern void hv_stimer_free(void);
26 extern void hv_stimer_init(unsigned int cpu);
27 extern void hv_stimer_cleanup(unsigned int cpu);
28 extern void hv_stimer_global_cleanup(void);
29 extern void hv_stimer0_isr(void);
30
31 #ifdef CONFIG_HYPERV_TIMER
32 extern struct clocksource *hyperv_cs;
33 extern void hv_init_clocksource(void);
34
35 extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void);
36
37 static inline notrace u64
38 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg, u64 *cur_tsc)
39 {
40 u64 scale, offset;
41 u32 sequence;
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 do {
60 sequence = READ_ONCE(tsc_pg->tsc_sequence);
61 if (!sequence)
62 return U64_MAX;
63
64
65
66
67 smp_rmb();
68
69 scale = READ_ONCE(tsc_pg->tsc_scale);
70 offset = READ_ONCE(tsc_pg->tsc_offset);
71 *cur_tsc = hv_get_raw_timer();
72
73
74
75
76
77 smp_rmb();
78
79 } while (READ_ONCE(tsc_pg->tsc_sequence) != sequence);
80
81 return mul_u64_u64_shr(*cur_tsc, scale, 64) + offset;
82 }
83
84 static inline notrace u64
85 hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg)
86 {
87 u64 cur_tsc;
88
89 return hv_read_tsc_page_tsc(tsc_pg, &cur_tsc);
90 }
91
92 #else
93 static inline struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
94 {
95 return NULL;
96 }
97
98 static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg,
99 u64 *cur_tsc)
100 {
101 return U64_MAX;
102 }
103 #endif
104
105 #endif