Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
97ac984d
cloud-kernel
项目概览
openanolis
/
cloud-kernel
接近 2 年 前同步成功
通知
169
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
97ac984d
编写于
2月 15, 2012
作者:
T
Thomas Gleixner
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fortglx/3.4/time' of
git://git.linaro.org/people/jstultz/linux
into timers/core
上级
8682df25
cc06268c
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
248 addition
and
190 deletion
+248
-190
include/linux/timex.h
include/linux/timex.h
+1
-16
kernel/time/ntp.c
kernel/time/ntp.c
+63
-20
kernel/time/timekeeping.c
kernel/time/timekeeping.c
+184
-154
未找到文件。
include/linux/timex.h
浏览文件 @
97ac984d
...
@@ -234,23 +234,9 @@ struct timex {
...
@@ -234,23 +234,9 @@ struct timex {
extern
unsigned
long
tick_usec
;
/* USER_HZ period (usec) */
extern
unsigned
long
tick_usec
;
/* USER_HZ period (usec) */
extern
unsigned
long
tick_nsec
;
/* ACTHZ period (nsec) */
extern
unsigned
long
tick_nsec
;
/* ACTHZ period (nsec) */
/*
* phase-lock loop variables
*/
extern
int
time_status
;
/* clock synchronization status bits */
extern
void
ntp_init
(
void
);
extern
void
ntp_init
(
void
);
extern
void
ntp_clear
(
void
);
extern
void
ntp_clear
(
void
);
/**
* ntp_synced - Returns 1 if the NTP status is not UNSYNC
*
*/
static
inline
int
ntp_synced
(
void
)
{
return
!
(
time_status
&
STA_UNSYNC
);
}
/* Required to safely shift negative values */
/* Required to safely shift negative values */
#define shift_right(x, s) ({ \
#define shift_right(x, s) ({ \
__typeof__(x) __x = (x); \
__typeof__(x) __x = (x); \
...
@@ -264,10 +250,9 @@ static inline int ntp_synced(void)
...
@@ -264,10 +250,9 @@ static inline int ntp_synced(void)
#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ)
#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ)
/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
extern
u64
tick_length
;
extern
u64
ntp_tick_length
(
void
)
;
extern
void
second_overflow
(
void
);
extern
void
second_overflow
(
void
);
extern
void
update_ntp_one_tick
(
void
);
extern
int
do_adjtimex
(
struct
timex
*
);
extern
int
do_adjtimex
(
struct
timex
*
);
extern
void
hardpps
(
const
struct
timespec
*
,
const
struct
timespec
*
);
extern
void
hardpps
(
const
struct
timespec
*
,
const
struct
timespec
*
);
...
...
kernel/time/ntp.c
浏览文件 @
97ac984d
...
@@ -22,13 +22,16 @@
...
@@ -22,13 +22,16 @@
* NTP timekeeping variables:
* NTP timekeeping variables:
*/
*/
DEFINE_SPINLOCK
(
ntp_lock
);
/* USER_HZ period (usecs): */
/* USER_HZ period (usecs): */
unsigned
long
tick_usec
=
TICK_USEC
;
unsigned
long
tick_usec
=
TICK_USEC
;
/* ACTHZ period (nsecs): */
/* ACTHZ period (nsecs): */
unsigned
long
tick_nsec
;
unsigned
long
tick_nsec
;
u64
tick_length
;
static
u64
tick_length
;
static
u64
tick_length_base
;
static
u64
tick_length_base
;
static
struct
hrtimer
leap_timer
;
static
struct
hrtimer
leap_timer
;
...
@@ -49,7 +52,7 @@ static struct hrtimer leap_timer;
...
@@ -49,7 +52,7 @@ static struct hrtimer leap_timer;
static
int
time_state
=
TIME_OK
;
static
int
time_state
=
TIME_OK
;
/* clock status bits: */
/* clock status bits: */
int
time_status
=
STA_UNSYNC
;
static
int
time_status
=
STA_UNSYNC
;
/* TAI offset (secs): */
/* TAI offset (secs): */
static
long
time_tai
;
static
long
time_tai
;
...
@@ -133,7 +136,7 @@ static inline void pps_reset_freq_interval(void)
...
@@ -133,7 +136,7 @@ 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
xtime
_lock
* Must be called while holding a write on the
ntp
_lock
*/
*/
static
inline
void
pps_clear
(
void
)
static
inline
void
pps_clear
(
void
)
{
{
...
@@ -149,7 +152,7 @@ static inline void pps_clear(void)
...
@@ -149,7 +152,7 @@ static inline void pps_clear(void)
* 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
xtime
_lock
* 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
)
{
{
...
@@ -233,6 +236,17 @@ static inline void pps_fill_timex(struct timex *txc)
...
@@ -233,6 +236,17 @@ static inline void pps_fill_timex(struct timex *txc)
#endif
/* CONFIG_NTP_PPS */
#endif
/* CONFIG_NTP_PPS */
/**
* ntp_synced - Returns 1 if the NTP status is not UNSYNC
*
*/
static
inline
int
ntp_synced
(
void
)
{
return
!
(
time_status
&
STA_UNSYNC
);
}
/*
/*
* NTP methods:
* NTP methods:
*/
*/
...
@@ -330,11 +344,13 @@ static void ntp_update_offset(long offset)
...
@@ -330,11 +344,13 @@ static void ntp_update_offset(long offset)
/**
/**
* ntp_clear - Clears the NTP state variables
* ntp_clear - Clears the NTP state variables
*
* Must be called while holding a write on the xtime_lock
*/
*/
void
ntp_clear
(
void
)
void
ntp_clear
(
void
)
{
{
unsigned
long
flags
;
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
;
...
@@ -347,8 +363,23 @@ void ntp_clear(void)
...
@@ -347,8 +363,23 @@ void ntp_clear(void)
/* Clear PPS state variables */
/* Clear PPS state variables */
pps_clear
();
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
;
}
/*
/*
* 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
* day, the system clock is set back one second; if in leap-delete
* day, the system clock is set back one second; if in leap-delete
...
@@ -357,14 +388,15 @@ void ntp_clear(void)
...
@@ -357,14 +388,15 @@ void ntp_clear(void)
static
enum
hrtimer_restart
ntp_leap_second
(
struct
hrtimer
*
timer
)
static
enum
hrtimer_restart
ntp_leap_second
(
struct
hrtimer
*
timer
)
{
{
enum
hrtimer_restart
res
=
HRTIMER_NORESTART
;
enum
hrtimer_restart
res
=
HRTIMER_NORESTART
;
unsigned
long
flags
;
int
leap
=
0
;
write_seqlock
(
&
xtime_lock
);
spin_lock_irqsave
(
&
ntp_lock
,
flags
);
switch
(
time_state
)
{
switch
(
time_state
)
{
case
TIME_OK
:
case
TIME_OK
:
break
;
break
;
case
TIME_INS
:
case
TIME_INS
:
timekeeping_leap_insert
(
-
1
)
;
leap
=
-
1
;
time_state
=
TIME_OOP
;
time_state
=
TIME_OOP
;
printk
(
KERN_NOTICE
printk
(
KERN_NOTICE
"Clock: inserting leap second 23:59:60 UTC
\n
"
);
"Clock: inserting leap second 23:59:60 UTC
\n
"
);
...
@@ -372,7 +404,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
...
@@ -372,7 +404,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
res
=
HRTIMER_RESTART
;
res
=
HRTIMER_RESTART
;
break
;
break
;
case
TIME_DEL
:
case
TIME_DEL
:
timekeeping_leap_insert
(
1
)
;
leap
=
1
;
time_tai
--
;
time_tai
--
;
time_state
=
TIME_WAIT
;
time_state
=
TIME_WAIT
;
printk
(
KERN_NOTICE
printk
(
KERN_NOTICE
...
@@ -387,8 +419,14 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
...
@@ -387,8 +419,14 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
time_state
=
TIME_OK
;
time_state
=
TIME_OK
;
break
;
break
;
}
}
spin_unlock_irqrestore
(
&
ntp_lock
,
flags
);
write_sequnlock
(
&
xtime_lock
);
/*
* We have to call this outside of the ntp_lock to keep
* the proper locking hierarchy
*/
if
(
leap
)
timekeeping_leap_insert
(
leap
);
return
res
;
return
res
;
}
}
...
@@ -404,6 +442,9 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
...
@@ -404,6 +442,9 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
void
second_overflow
(
void
)
void
second_overflow
(
void
)
{
{
s64
delta
;
s64
delta
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
ntp_lock
,
flags
);
/* Bump the maxerror field */
/* Bump the maxerror field */
time_maxerror
+=
MAXFREQ
/
NSEC_PER_USEC
;
time_maxerror
+=
MAXFREQ
/
NSEC_PER_USEC
;
...
@@ -423,23 +464,25 @@ void second_overflow(void)
...
@@ -423,23 +464,25 @@ void second_overflow(void)
pps_dec_valid
();
pps_dec_valid
();
if
(
!
time_adjust
)
if
(
!
time_adjust
)
return
;
goto
out
;
if
(
time_adjust
>
MAX_TICKADJ
)
{
if
(
time_adjust
>
MAX_TICKADJ
)
{
time_adjust
-=
MAX_TICKADJ
;
time_adjust
-=
MAX_TICKADJ
;
tick_length
+=
MAX_TICKADJ_SCALED
;
tick_length
+=
MAX_TICKADJ_SCALED
;
return
;
goto
out
;
}
}
if
(
time_adjust
<
-
MAX_TICKADJ
)
{
if
(
time_adjust
<
-
MAX_TICKADJ
)
{
time_adjust
+=
MAX_TICKADJ
;
time_adjust
+=
MAX_TICKADJ
;
tick_length
-=
MAX_TICKADJ_SCALED
;
tick_length
-=
MAX_TICKADJ_SCALED
;
return
;
goto
out
;
}
}
tick_length
+=
(
s64
)(
time_adjust
*
NSEC_PER_USEC
/
NTP_INTERVAL_FREQ
)
tick_length
+=
(
s64
)(
time_adjust
*
NSEC_PER_USEC
/
NTP_INTERVAL_FREQ
)
<<
NTP_SCALE_SHIFT
;
<<
NTP_SCALE_SHIFT
;
time_adjust
=
0
;
time_adjust
=
0
;
out:
spin_unlock_irqrestore
(
&
ntp_lock
,
flags
);
}
}
#ifdef CONFIG_GENERIC_CMOS_UPDATE
#ifdef CONFIG_GENERIC_CMOS_UPDATE
...
@@ -663,7 +706,7 @@ int do_adjtimex(struct timex *txc)
...
@@ -663,7 +706,7 @@ int do_adjtimex(struct timex *txc)
getnstimeofday
(
&
ts
);
getnstimeofday
(
&
ts
);
write_seqlock_irq
(
&
xtime
_lock
);
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
;
...
@@ -705,7 +748,7 @@ int do_adjtimex(struct timex *txc)
...
@@ -705,7 +748,7 @@ int do_adjtimex(struct timex *txc)
/* fill PPS status fields */
/* fill PPS status fields */
pps_fill_timex
(
txc
);
pps_fill_timex
(
txc
);
write_sequnlock_irq
(
&
xtime
_lock
);
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
;
...
@@ -903,7 +946,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
...
@@ -903,7 +946,7 @@ 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
);
write_seqlock_irqsave
(
&
xtime
_lock
,
flags
);
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
);
...
@@ -916,7 +959,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
...
@@ -916,7 +959,7 @@ 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
;
write_sequnlock_irqrestore
(
&
xtime
_lock
,
flags
);
spin_unlock_irqrestore
(
&
ntp
_lock
,
flags
);
return
;
return
;
}
}
...
@@ -931,7 +974,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
...
@@ -931,7 +974,7 @@ 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
;
write_sequnlock_irqrestore
(
&
xtime
_lock
,
flags
);
spin_unlock_irqrestore
(
&
ntp
_lock
,
flags
);
pr_err
(
"hardpps: PPSJITTER: bad pulse
\n
"
);
pr_err
(
"hardpps: PPSJITTER: bad pulse
\n
"
);
return
;
return
;
}
}
...
@@ -948,7 +991,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
...
@@ -948,7 +991,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
hardpps_update_phase
(
pts_norm
.
nsec
);
hardpps_update_phase
(
pts_norm
.
nsec
);
write_sequnlock_irqrestore
(
&
xtime
_lock
,
flags
);
spin_unlock_irqrestore
(
&
ntp
_lock
,
flags
);
}
}
EXPORT_SYMBOL
(
hardpps
);
EXPORT_SYMBOL
(
hardpps
);
...
...
kernel/time/timekeeping.c
浏览文件 @
97ac984d
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录