Commit 06c017fd authored by John Stultz's avatar John Stultz

timekeeping: Hold timekeepering locks in do_adjtimex and hardpps

In moving the NTP state to be protected by the timekeeping locks,
be sure to acquire the timekeeping locks prior to calling
ntp functions.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent cef90377
...@@ -787,10 +787,10 @@ void __init timekeeping_init(void) ...@@ -787,10 +787,10 @@ void __init timekeeping_init(void)
boot.tv_nsec = 0; boot.tv_nsec = 0;
} }
ntp_init();
raw_spin_lock_irqsave(&timekeeper_lock, flags); raw_spin_lock_irqsave(&timekeeper_lock, flags);
write_seqcount_begin(&timekeeper_seq); write_seqcount_begin(&timekeeper_seq);
ntp_init();
clock = clocksource_default_clock(); clock = clocksource_default_clock();
if (clock->enable) if (clock->enable)
clock->enable(clock); clock->enable(clock);
...@@ -1618,6 +1618,7 @@ EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); ...@@ -1618,6 +1618,7 @@ EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset);
*/ */
int do_adjtimex(struct timex *txc) int do_adjtimex(struct timex *txc)
{ {
unsigned long flags;
struct timespec ts; struct timespec ts;
s32 tai, orig_tai; s32 tai, orig_tai;
int ret; int ret;
...@@ -1641,8 +1642,14 @@ int do_adjtimex(struct timex *txc) ...@@ -1641,8 +1642,14 @@ int do_adjtimex(struct timex *txc)
getnstimeofday(&ts); getnstimeofday(&ts);
orig_tai = tai = timekeeping_get_tai_offset(); orig_tai = tai = timekeeping_get_tai_offset();
raw_spin_lock_irqsave(&timekeeper_lock, flags);
write_seqcount_begin(&timekeeper_seq);
ret = __do_adjtimex(txc, &ts, &tai); ret = __do_adjtimex(txc, &ts, &tai);
write_seqcount_end(&timekeeper_seq);
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
if (tai != orig_tai) if (tai != orig_tai)
timekeeping_set_tai_offset(tai); timekeeping_set_tai_offset(tai);
...@@ -1655,7 +1662,15 @@ int do_adjtimex(struct timex *txc) ...@@ -1655,7 +1662,15 @@ int do_adjtimex(struct timex *txc)
*/ */
void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
{ {
unsigned long flags;
raw_spin_lock_irqsave(&timekeeper_lock, flags);
write_seqcount_begin(&timekeeper_seq);
__hardpps(phase_ts, raw_ts); __hardpps(phase_ts, raw_ts);
write_seqcount_end(&timekeeper_seq);
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
} }
EXPORT_SYMBOL(hardpps); EXPORT_SYMBOL(hardpps);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment