From: John Stultz Date: Fri, 22 Mar 2013 22:04:13 +0000 (-0700) Subject: timekeeping: Move ADJ_SETOFFSET to top level do_adjtimex() X-Git-Tag: firefly_0821_release~3680^2~653^2~20 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cef90377fab488bd1f959efda178fb83250cf61d;p=firefly-linux-kernel-4.4.55.git timekeeping: Move ADJ_SETOFFSET to top level do_adjtimex() Since ADJ_SETOFFSET adjusts the timekeeping state, process it as part of the top level do_adjtimex() function in timekeeping.c. This avoids deadlocks that could occur once we change the ntp locking rules. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index d17e13c0147d..a331ebc32e21 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -666,17 +666,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) { int result; - if (txc->modes & ADJ_SETOFFSET) { - struct timespec delta; - delta.tv_sec = txc->time.tv_sec; - delta.tv_nsec = txc->time.tv_usec; - if (!(txc->modes & ADJ_NANO)) - delta.tv_nsec *= 1000; - result = timekeeping_inject_offset(&delta); - if (result) - return result; - } - raw_spin_lock_irq(&ntp_lock); if (txc->modes & ADJ_ADJTIME) { diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 5f7a2330dc3c..e44915c7b16c 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1627,6 +1627,17 @@ int do_adjtimex(struct timex *txc) if (ret) return ret; + if (txc->modes & ADJ_SETOFFSET) { + struct timespec delta; + delta.tv_sec = txc->time.tv_sec; + delta.tv_nsec = txc->time.tv_usec; + if (!(txc->modes & ADJ_NANO)) + delta.tv_nsec *= 1000; + ret = timekeeping_inject_offset(&delta); + if (ret) + return ret; + } + getnstimeofday(&ts); orig_tai = tai = timekeeping_get_tai_offset();