iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support
[linux/fpc-iii.git] / arch / x86 / include / asm / vgtod.h
blob53748541c487ab00d8bd1ee9b4d05305aa33171d
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_VGTOD_H
3 #define _ASM_X86_VGTOD_H
5 #include <linux/compiler.h>
6 #include <linux/clocksource.h>
8 #ifdef BUILD_VDSO32_64
9 typedef u64 gtod_long_t;
10 #else
11 typedef unsigned long gtod_long_t;
12 #endif
14 * vsyscall_gtod_data will be accessed by 32 and 64 bit code at the same time
15 * so be carefull by modifying this structure.
17 struct vsyscall_gtod_data {
18 unsigned seq;
20 int vclock_mode;
21 u64 cycle_last;
22 u64 mask;
23 u32 mult;
24 u32 shift;
26 /* open coded 'struct timespec' */
27 u64 wall_time_snsec;
28 gtod_long_t wall_time_sec;
29 gtod_long_t monotonic_time_sec;
30 u64 monotonic_time_snsec;
31 gtod_long_t wall_time_coarse_sec;
32 gtod_long_t wall_time_coarse_nsec;
33 gtod_long_t monotonic_time_coarse_sec;
34 gtod_long_t monotonic_time_coarse_nsec;
36 int tz_minuteswest;
37 int tz_dsttime;
39 extern struct vsyscall_gtod_data vsyscall_gtod_data;
41 extern int vclocks_used;
42 static inline bool vclock_was_used(int vclock)
44 return READ_ONCE(vclocks_used) & (1 << vclock);
47 static inline unsigned gtod_read_begin(const struct vsyscall_gtod_data *s)
49 unsigned ret;
51 repeat:
52 ret = READ_ONCE(s->seq);
53 if (unlikely(ret & 1)) {
54 cpu_relax();
55 goto repeat;
57 smp_rmb();
58 return ret;
61 static inline int gtod_read_retry(const struct vsyscall_gtod_data *s,
62 unsigned start)
64 smp_rmb();
65 return unlikely(s->seq != start);
68 static inline void gtod_write_begin(struct vsyscall_gtod_data *s)
70 ++s->seq;
71 smp_wmb();
74 static inline void gtod_write_end(struct vsyscall_gtod_data *s)
76 smp_wmb();
77 ++s->seq;
80 #ifdef CONFIG_X86_64
82 #define VGETCPU_CPU_MASK 0xfff
84 static inline unsigned int __getcpu(void)
86 unsigned int p;
89 * Load per CPU data from GDT. LSL is faster than RDTSCP and
90 * works on all CPUs. This is volatile so that it orders
91 * correctly wrt barrier() and to keep gcc from cleverly
92 * hoisting it out of the calling function.
94 * If RDPID is available, use it.
96 alternative_io ("lsl %[seg],%[p]",
97 ".byte 0xf3,0x0f,0xc7,0xf8", /* RDPID %eax/rax */
98 X86_FEATURE_RDPID,
99 [p] "=a" (p), [seg] "r" (__PER_CPU_SEG));
101 return p;
104 #endif /* CONFIG_X86_64 */
106 #endif /* _ASM_X86_VGTOD_H */