]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Revert "ntp: Add ntp_lock to replace xtime_locking"
authorGuangyu Sun <guangyu.sun@oracle.com>
Thu, 4 Oct 2012 22:47:00 +0000 (15:47 -0700)
committerGuangyu Sun <guangyu.sun@oracle.com>
Thu, 4 Oct 2012 22:47:00 +0000 (15:47 -0700)
This reverts commit ee6d47e3b9100076c325af2becf3431fb833f4e0.

Signed-off-by: Guangyu Sun <guangyu.sun@oracle.com>
kernel/time/ntp.c

index 6e039b144daf0359ecaffcbc00227a7233fd0dd3..dfb85ef81b84eda59021d2c132292f8d0817093c 100644 (file)
@@ -22,9 +22,6 @@
  * NTP timekeeping variables:
  */
 
-DEFINE_SPINLOCK(ntp_lock);
-
-
 /* USER_HZ period (usecs): */
 unsigned long                  tick_usec = TICK_USEC;
 
@@ -136,7 +133,7 @@ static inline void pps_reset_freq_interval(void)
 /**
  * pps_clear - Clears the PPS state variables
  *
- * Must be called while holding a write on the ntp_lock
+ * Must be called while holding a write on the xtime_lock
  */
 static inline void pps_clear(void)
 {
@@ -152,7 +149,7 @@ static inline void pps_clear(void)
  * the last PPS signal. When it reaches 0, indicate that PPS signal is
  * missing.
  *
- * Must be called while holding a write on the ntp_lock
+ * Must be called while holding a write on the xtime_lock
  */
 static inline void pps_dec_valid(void)
 {
@@ -344,13 +341,11 @@ static void ntp_update_offset(long offset)
 
 /**
  * ntp_clear - Clears the NTP state variables
+ *
+ * Must be called while holding a write on the xtime_lock
  */
 void ntp_clear(void)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&ntp_lock, flags);
-
        time_adjust     = 0;            /* stop active adjtime() */
        time_status     |= STA_UNSYNC;
        time_maxerror   = NTP_PHASE_LIMIT;
@@ -363,20 +358,12 @@ void ntp_clear(void)
 
        /* Clear PPS state variables */
        pps_clear();
-       spin_unlock_irqrestore(&ntp_lock, flags);
-
 }
 
 
 u64 ntp_tick_length(void)
 {
-       unsigned long flags;
-       s64 ret;
-
-       spin_lock_irqsave(&ntp_lock, flags);
-       ret = tick_length;
-       spin_unlock_irqrestore(&ntp_lock, flags);
-       return ret;
+       return tick_length;
 }
 
 
@@ -388,15 +375,14 @@ u64 ntp_tick_length(void)
 static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
 {
        enum hrtimer_restart res = HRTIMER_NORESTART;
-       unsigned long flags;
-       int leap = 0;
 
-       spin_lock_irqsave(&ntp_lock, flags);
+       write_seqlock(&xtime_lock);
+
        switch (time_state) {
        case TIME_OK:
                break;
        case TIME_INS:
-               leap = -1;
+               timekeeping_leap_insert(-1);
                time_state = TIME_OOP;
                printk(KERN_NOTICE
                        "Clock: inserting leap second 23:59:60 UTC\n");
@@ -404,7 +390,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
                res = HRTIMER_RESTART;
                break;
        case TIME_DEL:
-               leap = 1;
+               timekeeping_leap_insert(1);
                time_tai--;
                time_state = TIME_WAIT;
                printk(KERN_NOTICE
@@ -419,14 +405,8 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
                        time_state = TIME_OK;
                break;
        }
-       spin_unlock_irqrestore(&ntp_lock, flags);
 
-       /*
-        * We have to call this outside of the ntp_lock to keep
-        * the proper locking hierarchy
-        */
-       if (leap)
-               timekeeping_leap_insert(leap);
+       write_sequnlock(&xtime_lock);
 
        return res;
 }
@@ -442,9 +422,6 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
 void second_overflow(void)
 {
        s64 delta;
-       unsigned long flags;
-
-       spin_lock_irqsave(&ntp_lock, flags);
 
        /* Bump the maxerror field */
        time_maxerror += MAXFREQ / NSEC_PER_USEC;
@@ -464,25 +441,23 @@ void second_overflow(void)
        pps_dec_valid();
 
        if (!time_adjust)
-               goto out;
+               return;
 
        if (time_adjust > MAX_TICKADJ) {
                time_adjust -= MAX_TICKADJ;
                tick_length += MAX_TICKADJ_SCALED;
-               goto out;
+               return;
        }
 
        if (time_adjust < -MAX_TICKADJ) {
                time_adjust += MAX_TICKADJ;
                tick_length -= MAX_TICKADJ_SCALED;
-               goto out;
+               return;
        }
 
        tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
                                                         << NTP_SCALE_SHIFT;
        time_adjust = 0;
-out:
-       spin_unlock_irqrestore(&ntp_lock, flags);
 }
 
 #ifdef CONFIG_GENERIC_CMOS_UPDATE
@@ -706,7 +681,7 @@ int do_adjtimex(struct timex *txc)
 
        getnstimeofday(&ts);
 
-       spin_lock_irq(&ntp_lock);
+       write_seqlock_irq(&xtime_lock);
 
        if (txc->modes & ADJ_ADJTIME) {
                long save_adjust = time_adjust;
@@ -748,7 +723,7 @@ int do_adjtimex(struct timex *txc)
        /* fill PPS status fields */
        pps_fill_timex(txc);
 
-       spin_unlock_irq(&ntp_lock);
+       write_sequnlock_irq(&xtime_lock);
 
        txc->time.tv_sec = ts.tv_sec;
        txc->time.tv_usec = ts.tv_nsec;
@@ -946,7 +921,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
 
        pts_norm = pps_normalize_ts(*phase_ts);
 
-       spin_lock_irqsave(&ntp_lock, flags);
+       write_seqlock_irqsave(&xtime_lock, flags);
 
        /* clear the error bits, they will be set again if needed */
        time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
@@ -959,7 +934,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
         * just start the frequency interval */
        if (unlikely(pps_fbase.tv_sec == 0)) {
                pps_fbase = *raw_ts;
-               spin_unlock_irqrestore(&ntp_lock, flags);
+               write_sequnlock_irqrestore(&xtime_lock, flags);
                return;
        }
 
@@ -974,7 +949,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
                time_status |= STA_PPSJITTER;
                /* restart the frequency calibration interval */
                pps_fbase = *raw_ts;
-               spin_unlock_irqrestore(&ntp_lock, flags);
+               write_sequnlock_irqrestore(&xtime_lock, flags);
                pr_err("hardpps: PPSJITTER: bad pulse\n");
                return;
        }
@@ -991,7 +966,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
 
        hardpps_update_phase(pts_norm.nsec);
 
-       spin_unlock_irqrestore(&ntp_lock, flags);
+       write_sequnlock_irqrestore(&xtime_lock, flags);
 }
 EXPORT_SYMBOL(hardpps);