Commit a076b214 authored by John Stultz's avatar John Stultz

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: default avatarJohn Stultz <john.stultz@linaro.org>
parent 0b5154fb
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
/* /*
* NTP timekeeping variables: * NTP timekeeping variables:
*
* Note: All of the NTP state is protected by the timekeeping locks.
*/ */
DEFINE_RAW_SPINLOCK(ntp_lock);
/* USER_HZ period (usecs): */ /* USER_HZ period (usecs): */
unsigned long tick_usec = TICK_USEC; unsigned long tick_usec = TICK_USEC;
...@@ -132,8 +132,6 @@ static inline void pps_reset_freq_interval(void) ...@@ -132,8 +132,6 @@ static inline void pps_reset_freq_interval(void)
/** /**
* pps_clear - Clears the PPS state variables * pps_clear - Clears the PPS state variables
*
* Must be called while holding a write on the ntp_lock
*/ */
static inline void pps_clear(void) static inline void pps_clear(void)
{ {
...@@ -148,8 +146,6 @@ static inline void pps_clear(void) ...@@ -148,8 +146,6 @@ static inline void pps_clear(void)
/* Decrease pps_valid to indicate that another second has passed since /* Decrease pps_valid to indicate that another second has passed since
* the last PPS signal. When it reaches 0, indicate that PPS signal is * the last PPS signal. When it reaches 0, indicate that PPS signal is
* missing. * missing.
*
* Must be called while holding a write on the ntp_lock
*/ */
static inline void pps_dec_valid(void) static inline void pps_dec_valid(void)
{ {
...@@ -344,10 +340,6 @@ static void ntp_update_offset(long offset) ...@@ -344,10 +340,6 @@ static void ntp_update_offset(long offset)
*/ */
void ntp_clear(void) void ntp_clear(void)
{ {
unsigned long flags;
raw_spin_lock_irqsave(&ntp_lock, flags);
time_adjust = 0; /* stop active adjtime() */ time_adjust = 0; /* stop active adjtime() */
time_status |= STA_UNSYNC; time_status |= STA_UNSYNC;
time_maxerror = NTP_PHASE_LIMIT; time_maxerror = NTP_PHASE_LIMIT;
...@@ -360,20 +352,12 @@ void ntp_clear(void) ...@@ -360,20 +352,12 @@ void ntp_clear(void)
/* Clear PPS state variables */ /* Clear PPS state variables */
pps_clear(); pps_clear();
raw_spin_unlock_irqrestore(&ntp_lock, flags);
} }
u64 ntp_tick_length(void) u64 ntp_tick_length(void)
{ {
unsigned long flags; return tick_length;
s64 ret;
raw_spin_lock_irqsave(&ntp_lock, flags);
ret = tick_length;
raw_spin_unlock_irqrestore(&ntp_lock, flags);
return ret;
} }
...@@ -391,9 +375,6 @@ int second_overflow(unsigned long secs) ...@@ -391,9 +375,6 @@ int second_overflow(unsigned long secs)
{ {
s64 delta; s64 delta;
int leap = 0; int leap = 0;
unsigned long flags;
raw_spin_lock_irqsave(&ntp_lock, flags);
/* /*
* Leap second processing. If in leap-insert state at the end of the * Leap second processing. If in leap-insert state at the end of the
...@@ -475,8 +456,6 @@ int second_overflow(unsigned long secs) ...@@ -475,8 +456,6 @@ int second_overflow(unsigned long secs)
time_adjust = 0; time_adjust = 0;
out: out:
raw_spin_unlock_irqrestore(&ntp_lock, flags);
return leap; return leap;
} }
...@@ -571,10 +550,7 @@ static inline void process_adj_status(struct timex *txc, struct timespec *ts) ...@@ -571,10 +550,7 @@ static inline void process_adj_status(struct timex *txc, struct timespec *ts)
time_status |= txc->status & ~STA_RONLY; time_status |= txc->status & ~STA_RONLY;
} }
/*
* Called with ntp_lock held, so we can access and modify
* all the global NTP state:
*/
static inline void process_adjtimex_modes(struct timex *txc, static inline void process_adjtimex_modes(struct timex *txc,
struct timespec *ts, struct timespec *ts,
s32 *time_tai) s32 *time_tai)
...@@ -666,8 +642,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) ...@@ -666,8 +642,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai)
{ {
int result; int result;
raw_spin_lock_irq(&ntp_lock);
if (txc->modes & ADJ_ADJTIME) { if (txc->modes & ADJ_ADJTIME) {
long save_adjust = time_adjust; long save_adjust = time_adjust;
...@@ -708,8 +682,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) ...@@ -708,8 +682,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai)
/* fill PPS status fields */ /* fill PPS status fields */
pps_fill_timex(txc); pps_fill_timex(txc);
raw_spin_unlock_irq(&ntp_lock);
txc->time.tv_sec = ts->tv_sec; txc->time.tv_sec = ts->tv_sec;
txc->time.tv_usec = ts->tv_nsec; txc->time.tv_usec = ts->tv_nsec;
if (!(time_status & STA_NANO)) if (!(time_status & STA_NANO))
...@@ -906,8 +878,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) ...@@ -906,8 +878,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
pts_norm = pps_normalize_ts(*phase_ts); pts_norm = pps_normalize_ts(*phase_ts);
raw_spin_lock_irqsave(&ntp_lock, flags);
/* clear the error bits, they will be set again if needed */ /* clear the error bits, they will be set again if needed */
time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR); time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
...@@ -919,7 +889,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) ...@@ -919,7 +889,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
* just start the frequency interval */ * just start the frequency interval */
if (unlikely(pps_fbase.tv_sec == 0)) { if (unlikely(pps_fbase.tv_sec == 0)) {
pps_fbase = *raw_ts; pps_fbase = *raw_ts;
raw_spin_unlock_irqrestore(&ntp_lock, flags);
return; return;
} }
...@@ -934,7 +903,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) ...@@ -934,7 +903,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
time_status |= STA_PPSJITTER; time_status |= STA_PPSJITTER;
/* restart the frequency calibration interval */ /* restart the frequency calibration interval */
pps_fbase = *raw_ts; pps_fbase = *raw_ts;
raw_spin_unlock_irqrestore(&ntp_lock, flags);
pr_err("hardpps: PPSJITTER: bad pulse\n"); pr_err("hardpps: PPSJITTER: bad pulse\n");
return; return;
} }
...@@ -951,7 +919,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) ...@@ -951,7 +919,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
hardpps_update_phase(pts_norm.nsec); hardpps_update_phase(pts_norm.nsec);
raw_spin_unlock_irqrestore(&ntp_lock, flags);
} }
#endif /* CONFIG_NTP_PPS */ #endif /* CONFIG_NTP_PPS */
......
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