mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 05:30:54 +07:00
timekeeping: create arch_gettimeoffset infrastructure
Some arches don't supply their own clocksource. This is mainly the case in architectures that get their inter-tick times by reading the counter on their interval timer. Since these timers wrap every tick, they're not really useful as clocksources. Wrapping them to act like one is possible but not very efficient. So we provide a callout these arches can implement for use with the jiffies clocksource to provide finer then tick granular time. [ Impact: ease the migration to generic time keeping ] Signed-off-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
a25cbd045a
commit
7d27558c41
@ -113,6 +113,21 @@ struct timespec current_kernel_time(void);
|
|||||||
#define CURRENT_TIME (current_kernel_time())
|
#define CURRENT_TIME (current_kernel_time())
|
||||||
#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })
|
#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })
|
||||||
|
|
||||||
|
/* Some architectures do not supply their own clocksource.
|
||||||
|
* This is mainly the case in architectures that get their
|
||||||
|
* inter-tick times by reading the counter on their interval
|
||||||
|
* timer. Since these timers wrap every tick, they're not really
|
||||||
|
* useful as clocksources. Wrapping them to act like one is possible
|
||||||
|
* but not very efficient. So we provide a callout these arches
|
||||||
|
* can implement for use with the jiffies clocksource to provide
|
||||||
|
* finer then tick granular time.
|
||||||
|
*/
|
||||||
|
#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
|
||||||
|
extern u32 arch_gettimeoffset(void);
|
||||||
|
#else
|
||||||
|
static inline u32 arch_gettimeoffset(void) { return 0; }
|
||||||
|
#endif
|
||||||
|
|
||||||
extern void do_gettimeofday(struct timeval *tv);
|
extern void do_gettimeofday(struct timeval *tv);
|
||||||
extern int do_settimeofday(struct timespec *tv);
|
extern int do_settimeofday(struct timespec *tv);
|
||||||
extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz);
|
extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz);
|
||||||
|
@ -77,6 +77,10 @@ static void clocksource_forward_now(void)
|
|||||||
clock->cycle_last = cycle_now;
|
clock->cycle_last = cycle_now;
|
||||||
|
|
||||||
nsec = cyc2ns(clock, cycle_delta);
|
nsec = cyc2ns(clock, cycle_delta);
|
||||||
|
|
||||||
|
/* If arch requires, add in gettimeoffset() */
|
||||||
|
nsec += arch_gettimeoffset();
|
||||||
|
|
||||||
timespec_add_ns(&xtime, nsec);
|
timespec_add_ns(&xtime, nsec);
|
||||||
|
|
||||||
nsec = ((s64)cycle_delta * clock->mult_orig) >> clock->shift;
|
nsec = ((s64)cycle_delta * clock->mult_orig) >> clock->shift;
|
||||||
@ -111,6 +115,9 @@ void getnstimeofday(struct timespec *ts)
|
|||||||
/* convert to nanoseconds: */
|
/* convert to nanoseconds: */
|
||||||
nsecs = cyc2ns(clock, cycle_delta);
|
nsecs = cyc2ns(clock, cycle_delta);
|
||||||
|
|
||||||
|
/* If arch requires, add in gettimeoffset() */
|
||||||
|
nsecs += arch_gettimeoffset();
|
||||||
|
|
||||||
} while (read_seqretry(&xtime_lock, seq));
|
} while (read_seqretry(&xtime_lock, seq));
|
||||||
|
|
||||||
timespec_add_ns(ts, nsecs);
|
timespec_add_ns(ts, nsecs);
|
||||||
|
Loading…
Reference in New Issue
Block a user