]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
5c83545f CC |
2 | #ifndef _TIMEKEEPING_INTERNAL_H |
3 | #define _TIMEKEEPING_INTERNAL_H | |
19d0070a | 4 | |
3a978377 | 5 | #include <linux/clocksource.h> |
19d0070a | 6 | #include <linux/spinlock.h> |
5c83545f CC |
7 | #include <linux/time.h> |
8 | ||
19d0070a TG |
9 | /* |
10 | * timekeeping debug functions | |
11 | */ | |
5c83545f | 12 | #ifdef CONFIG_DEBUG_FS |
985e6950 | 13 | extern void tk_debug_account_sleep_time(const struct timespec64 *t); |
5c83545f CC |
14 | #else |
15 | #define tk_debug_account_sleep_time(x) | |
16 | #endif | |
17 | ||
09ec5442 | 18 | #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE |
a5a1d1c2 | 19 | static inline u64 clocksource_delta(u64 now, u64 last, u64 mask) |
09ec5442 | 20 | { |
a5a1d1c2 | 21 | u64 ret = (now - last) & mask; |
09ec5442 | 22 | |
1f45f1f3 YY |
23 | /* |
24 | * Prevent time going backwards by checking the MSB of mask in | |
25 | * the result. If set, return 0. | |
26 | */ | |
27 | return ret & ~(mask >> 1) ? 0 : ret; | |
09ec5442 TG |
28 | } |
29 | #else | |
a5a1d1c2 | 30 | static inline u64 clocksource_delta(u64 now, u64 last, u64 mask) |
3a978377 TG |
31 | { |
32 | return (now - last) & mask; | |
33 | } | |
09ec5442 | 34 | #endif |
3a978377 | 35 | |
19d0070a TG |
36 | /* Semi public for serialization of non timekeeper VDSO updates. */ |
37 | extern raw_spinlock_t timekeeper_lock; | |
38 | ||
5c83545f | 39 | #endif /* _TIMEKEEPING_INTERNAL_H */ |