Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 135750
b: refs/heads/master
c: f939890
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Feb 25, 2009
1 parent 123b5da commit d4bd81a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bc26c31d446bc9c24cd6f7003777a05fe268ae48
refs/heads/master: f939890b6687e05c42361655fb6610fa08f5a601
44 changes: 30 additions & 14 deletions trunk/kernel/time/ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,27 @@ static void ntp_update_frequency(void)
tick_length_base = new_base;
}

static inline s64 ntp_update_offset_fll(s64 freq_adj, s64 offset64, long secs)
{
time_status &= ~STA_MODE;

if (secs < MINSEC)
return freq_adj;

if (!(time_status & STA_FLL) && (secs <= MAXSEC))
return freq_adj;

freq_adj += div_s64(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
time_status |= STA_MODE;

return freq_adj;
}

static void ntp_update_offset(long offset)
{
long mtemp;
s64 freq_adj;
s64 offset64;
long secs;

if (!(time_status & STA_PLL))
return;
Expand All @@ -127,22 +144,21 @@ static void ntp_update_offset(long offset)
*/
if (time_status & STA_FREQHOLD || time_reftime == 0)
time_reftime = xtime.tv_sec;
mtemp = xtime.tv_sec - time_reftime;

secs = xtime.tv_sec - time_reftime;
time_reftime = xtime.tv_sec;

freq_adj = (s64)offset * mtemp;
freq_adj <<= NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant);
time_status &= ~STA_MODE;
if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) {
freq_adj += div_s64((s64)offset << (NTP_SCALE_SHIFT - SHIFT_FLL),
mtemp);
time_status |= STA_MODE;
}
freq_adj += time_freq;
freq_adj = min(freq_adj, MAXFREQ_SCALED);
time_freq = max(freq_adj, -MAXFREQ_SCALED);
offset64 = offset;
freq_adj = (offset64 * secs) <<
(NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant));

freq_adj = ntp_update_offset_fll(freq_adj, offset64, secs);

freq_adj = min(freq_adj + time_freq, MAXFREQ_SCALED);

time_freq = max(freq_adj, -MAXFREQ_SCALED);

time_offset = div_s64((s64)offset << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
time_offset = div_s64(offset64 << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
}

/**
Expand Down

0 comments on commit d4bd81a

Please sign in to comment.