2013-05-22 09:32:14 +04:00
|
|
|
#ifndef _TIMEKEEPING_INTERNAL_H
|
|
|
|
#define _TIMEKEEPING_INTERNAL_H
|
|
|
|
/*
|
|
|
|
* timekeeping debug functions
|
|
|
|
*/
|
2014-07-17 01:05:10 +04:00
|
|
|
#include <linux/clocksource.h>
|
2013-05-22 09:32:14 +04:00
|
|
|
#include <linux/time.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
2014-07-17 01:04:01 +04:00
|
|
|
extern void tk_debug_account_sleep_time(struct timespec64 *t);
|
2013-05-22 09:32:14 +04:00
|
|
|
#else
|
|
|
|
#define tk_debug_account_sleep_time(x)
|
|
|
|
#endif
|
|
|
|
|
2014-07-17 01:05:12 +04:00
|
|
|
#ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
|
2016-12-21 22:32:01 +03:00
|
|
|
static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
|
2014-07-17 01:05:12 +04:00
|
|
|
{
|
2016-12-21 22:32:01 +03:00
|
|
|
u64 ret = (now - last) & mask;
|
2014-07-17 01:05:12 +04:00
|
|
|
|
2015-10-31 13:20:55 +03:00
|
|
|
/*
|
|
|
|
* Prevent time going backwards by checking the MSB of mask in
|
|
|
|
* the result. If set, return 0.
|
|
|
|
*/
|
|
|
|
return ret & ~(mask >> 1) ? 0 : ret;
|
2014-07-17 01:05:12 +04:00
|
|
|
}
|
|
|
|
#else
|
2016-12-21 22:32:01 +03:00
|
|
|
static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
|
2014-07-17 01:05:10 +04:00
|
|
|
{
|
|
|
|
return (now - last) & mask;
|
|
|
|
}
|
2014-07-17 01:05:12 +04:00
|
|
|
#endif
|
2014-07-17 01:05:10 +04:00
|
|
|
|
2015-12-13 07:24:18 +03:00
|
|
|
extern time64_t __ktime_get_real_seconds(void);
|
|
|
|
|
2013-05-22 09:32:14 +04:00
|
|
|
#endif /* _TIMEKEEPING_INTERNAL_H */
|