aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2013-03-22 14:52:03 -0400
committerJohn Stultz <john.stultz@linaro.org>2013-04-04 16:18:17 -0400
commita076b2146fabb0894cae5e0189a8ba3f1502d737 (patch)
tree5cefb4526bf90d9ffb775596b38cc6c0b602f907 /kernel/time
parent0b5154fb9040cca94e7d9893384c0e78bfe2d296 (diff)
ntp: Remove ntp_lock, using the timekeeping locks to protect ntp state
In order to properly handle the NTP state in future changes to the timekeeping lock management, this patch moves the management of all of the ntp state under the timekeeping locks. This allows us to remove the ntp_lock. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/ntp.c41
1 files changed, 4 insertions, 37 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index a331ebc32e21..12ff13a838c6 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -22,10 +22,10 @@
22 22
23/* 23/*
24 * NTP timekeeping variables: 24 * NTP timekeeping variables:
25 *
26 * Note: All of the NTP state is protected by the timekeeping locks.
25 */ 27 */
26 28
27DEFINE_RAW_SPINLOCK(ntp_lock);
28
29 29
30/* USER_HZ period (usecs): */ 30/* USER_HZ period (usecs): */
31unsigned long tick_usec = TICK_USEC; 31unsigned long tick_usec = TICK_USEC;
@@ -132,8 +132,6 @@ static inline void pps_reset_freq_interval(void)
132 132
133/** 133/**
134 * pps_clear - Clears the PPS state variables 134 * pps_clear - Clears the PPS state variables
135 *
136 * Must be called while holding a write on the ntp_lock
137 */ 135 */
138static inline void pps_clear(void) 136static inline void pps_clear(void)
139{ 137{
@@ -148,8 +146,6 @@ static inline void pps_clear(void)
148/* Decrease pps_valid to indicate that another second has passed since 146/* Decrease pps_valid to indicate that another second has passed since
149 * the last PPS signal. When it reaches 0, indicate that PPS signal is 147 * the last PPS signal. When it reaches 0, indicate that PPS signal is
150 * missing. 148 * missing.
151 *
152 * Must be called while holding a write on the ntp_lock
153 */ 149 */
154static inline void pps_dec_valid(void) 150static inline void pps_dec_valid(void)
155{ 151{
@@ -344,10 +340,6 @@ static void ntp_update_offset(long offset)
344 */ 340 */
345void ntp_clear(void) 341void ntp_clear(void)
346{ 342{
347 unsigned long flags;
348
349 raw_spin_lock_irqsave(&ntp_lock, flags);
350
351 time_adjust = 0; /* stop active adjtime() */ 343 time_adjust = 0; /* stop active adjtime() */
352 time_status |= STA_UNSYNC; 344 time_status |= STA_UNSYNC;
353 time_maxerror = NTP_PHASE_LIMIT; 345 time_maxerror = NTP_PHASE_LIMIT;
@@ -360,20 +352,12 @@ void ntp_clear(void)
360 352
361 /* Clear PPS state variables */ 353 /* Clear PPS state variables */
362 pps_clear(); 354 pps_clear();
363 raw_spin_unlock_irqrestore(&ntp_lock, flags);
364
365} 355}
366 356
367 357
368u64 ntp_tick_length(void) 358u64 ntp_tick_length(void)
369{ 359{
370 unsigned long flags; 360 return tick_length;
371 s64 ret;
372
373 raw_spin_lock_irqsave(&ntp_lock, flags);
374 ret = tick_length;
375 raw_spin_unlock_irqrestore(&ntp_lock, flags);
376 return ret;
377} 361}
378 362
379 363
@@ -391,9 +375,6 @@ int second_overflow(unsigned long secs)
391{ 375{
392 s64 delta; 376 s64 delta;
393 int leap = 0; 377 int leap = 0;
394 unsigned long flags;
395
396 raw_spin_lock_irqsave(&ntp_lock, flags);
397 378
398 /* 379 /*
399 * Leap second processing. If in leap-insert state at the end of the 380 * Leap second processing. If in leap-insert state at the end of the
@@ -475,8 +456,6 @@ int second_overflow(unsigned long secs)
475 time_adjust = 0; 456 time_adjust = 0;
476 457
477out: 458out:
478 raw_spin_unlock_irqrestore(&ntp_lock, flags);
479
480 return leap; 459 return leap;
481} 460}
482 461
@@ -571,10 +550,7 @@ static inline void process_adj_status(struct timex *txc, struct timespec *ts)
571 time_status |= txc->status & ~STA_RONLY; 550 time_status |= txc->status & ~STA_RONLY;
572} 551}
573 552
574/* 553
575 * Called with ntp_lock held, so we can access and modify
576 * all the global NTP state:
577 */
578static inline void process_adjtimex_modes(struct timex *txc, 554static inline void process_adjtimex_modes(struct timex *txc,
579 struct timespec *ts, 555 struct timespec *ts,
580 s32 *time_tai) 556 s32 *time_tai)
@@ -666,8 +642,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai)
666{ 642{
667 int result; 643 int result;
668 644
669 raw_spin_lock_irq(&ntp_lock);
670
671 if (txc->modes & ADJ_ADJTIME) { 645 if (txc->modes & ADJ_ADJTIME) {
672 long save_adjust = time_adjust; 646 long save_adjust = time_adjust;
673 647
@@ -708,8 +682,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai)
708 /* fill PPS status fields */ 682 /* fill PPS status fields */
709 pps_fill_timex(txc); 683 pps_fill_timex(txc);
710 684
711 raw_spin_unlock_irq(&ntp_lock);
712
713 txc->time.tv_sec = ts->tv_sec; 685 txc->time.tv_sec = ts->tv_sec;
714 txc->time.tv_usec = ts->tv_nsec; 686 txc->time.tv_usec = ts->tv_nsec;
715 if (!(time_status & STA_NANO)) 687 if (!(time_status & STA_NANO))
@@ -906,8 +878,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
906 878
907 pts_norm = pps_normalize_ts(*phase_ts); 879 pts_norm = pps_normalize_ts(*phase_ts);
908 880
909 raw_spin_lock_irqsave(&ntp_lock, flags);
910
911 /* clear the error bits, they will be set again if needed */ 881 /* clear the error bits, they will be set again if needed */
912 time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR); 882 time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
913 883
@@ -919,7 +889,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
919 * just start the frequency interval */ 889 * just start the frequency interval */
920 if (unlikely(pps_fbase.tv_sec == 0)) { 890 if (unlikely(pps_fbase.tv_sec == 0)) {
921 pps_fbase = *raw_ts; 891 pps_fbase = *raw_ts;
922 raw_spin_unlock_irqrestore(&ntp_lock, flags);
923 return; 892 return;
924 } 893 }
925 894
@@ -934,7 +903,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
934 time_status |= STA_PPSJITTER; 903 time_status |= STA_PPSJITTER;
935 /* restart the frequency calibration interval */ 904 /* restart the frequency calibration interval */
936 pps_fbase = *raw_ts; 905 pps_fbase = *raw_ts;
937 raw_spin_unlock_irqrestore(&ntp_lock, flags);
938 pr_err("hardpps: PPSJITTER: bad pulse\n"); 906 pr_err("hardpps: PPSJITTER: bad pulse\n");
939 return; 907 return;
940 } 908 }
@@ -951,7 +919,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
951 919
952 hardpps_update_phase(pts_norm.nsec); 920 hardpps_update_phase(pts_norm.nsec);
953 921
954 raw_spin_unlock_irqrestore(&ntp_lock, flags);
955} 922}
956#endif /* CONFIG_NTP_PPS */ 923#endif /* CONFIG_NTP_PPS */
957 924