Skip to content

Commit 314ac37

Browse files
time: Extend get_xtime_and_monotonic_offset() to also return sleep
Extend get_xtime_and_monotonic_offset to get_xtime_and_monotonic_and_sleep_offset(). CC: Jamie Lokier <jamie@shareable.org> CC: Thomas Gleixner <tglx@linutronix.de> CC: Alexander Shishkin <virtuoso@slind.org> CC: Arve Hjønnevåg <arve@android.com> Signed-off-by: John Stultz <john.stultz@linaro.org>
1 parent abb3a4e commit 314ac37

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎include/linux/time.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ unsigned long get_seconds(void);
124124
struct timespec current_kernel_time(void);
125125
struct timespec __current_kernel_time(void); /* does not take xtime_lock */
126126
struct timespec get_monotonic_coarse(void);
127-
void get_xtime_and_monotonic_offset(struct timespec *xtim, struct timespec *wtom);
127+
void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
128+
struct timespec *wtom, struct timespec *sleep);
128129

129130
#define CURRENT_TIME (current_kernel_time())
130131
#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })

‎kernel/hrtimer.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
9191
static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
9292
{
9393
ktime_t xtim, tomono;
94-
struct timespec xts, tom;
94+
struct timespec xts, tom, slp;
9595

96-
get_xtime_and_monotonic_offset(&xts, &tom);
96+
get_xtime_and_monotonic_and_sleep_offset(&xts, &tom, &slp);
9797

9898
xtim = timespec_to_ktime(xts);
9999
tomono = timespec_to_ktime(tom);
@@ -614,12 +614,13 @@ static int hrtimer_reprogram(struct hrtimer *timer,
614614
static void retrigger_next_event(void *arg)
615615
{
616616
struct hrtimer_cpu_base *base;
617-
struct timespec realtime_offset, wtm;
617+
struct timespec realtime_offset, wtm, sleep;
618618

619619
if (!hrtimer_hres_active())
620620
return;
621621

622-
get_xtime_and_monotonic_offset(&realtime_offset, &wtm);
622+
get_xtime_and_monotonic_and_sleep_offset(&realtime_offset, &wtm,
623+
&sleep);
623624
set_normalized_timespec(&realtime_offset, -wtm.tv_sec, -wtm.tv_nsec);
624625

625626
base = &__get_cpu_var(hrtimer_bases);

‎kernel/time/timekeeping.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,18 +1040,22 @@ void do_timer(unsigned long ticks)
10401040
}
10411041

10421042
/**
1043-
* get_xtime_and_monotonic_offset() - get xtime and wall_to_monotonic
1043+
* get_xtime_and_monotonic_and_sleep_offset() - get xtime, wall_to_monotonic,
1044+
* and sleep offsets.
10441045
* @xtim: pointer to timespec to be set with xtime
10451046
* @wtom: pointer to timespec to be set with wall_to_monotonic
1047+
* @sleep: pointer to timespec to be set with time in suspend
10461048
*/
1047-
void get_xtime_and_monotonic_offset(struct timespec *xtim, struct timespec *wtom)
1049+
void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
1050+
struct timespec *wtom, struct timespec *sleep)
10481051
{
10491052
unsigned long seq;
10501053

10511054
do {
10521055
seq = read_seqbegin(&xtime_lock);
10531056
*xtim = xtime;
10541057
*wtom = wall_to_monotonic;
1058+
*sleep = total_sleep_time;
10551059
} while (read_seqretry(&xtime_lock, seq));
10561060
}
10571061

0 commit comments

Comments
 (0)