Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04005f60 authored by John Stultz's avatar John Stultz
Browse files

timekeeping: Fix CLOCK_TAI timer/nanosleep delays



A think-o in the calculation of the monotonic -> tai time offset
results in CLOCK_TAI timers and nanosleeps to expire late (the
latency is ~2x the tai offset).

Fix this by adding the tai offset from the realtime offset instead
of subtracting.

Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable <stable@vger.kernel.org> #3.10+
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent 47a1b796
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -77,7 +77,7 @@ static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec wtm)
	tk->wall_to_monotonic = wtm;
	tk->wall_to_monotonic = wtm;
	set_normalized_timespec(&tmp, -wtm.tv_sec, -wtm.tv_nsec);
	set_normalized_timespec(&tmp, -wtm.tv_sec, -wtm.tv_nsec);
	tk->offs_real = timespec_to_ktime(tmp);
	tk->offs_real = timespec_to_ktime(tmp);
	tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tk->tai_offset, 0));
	tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tk->tai_offset, 0));
}
}


static void tk_set_sleep_time(struct timekeeper *tk, struct timespec t)
static void tk_set_sleep_time(struct timekeeper *tk, struct timespec t)
@@ -595,7 +595,7 @@ s32 timekeeping_get_tai_offset(void)
static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset)
static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset)
{
{
	tk->tai_offset = tai_offset;
	tk->tai_offset = tai_offset;
	tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tai_offset, 0));
	tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tai_offset, 0));
}
}


/**
/**