diff options
| author | John Stultz <john.stultz@linaro.org> | 2013-03-22 14:37:28 -0400 |
|---|---|---|
| committer | John Stultz <john.stultz@linaro.org> | 2013-04-04 16:18:16 -0400 |
| commit | 06c017fdd4dc48451a29ac37fc1db4a3f86b7f40 (patch) | |
| tree | 3629e95c779bbc388aab162ddaf3d8c37a8b8b48 /kernel | |
| parent | cef90377fab488bd1f959efda178fb83250cf61d (diff) | |
timekeeping: Hold timekeepering locks in do_adjtimex and hardpps
In moving the NTP state to be protected by the timekeeping locks,
be sure to acquire the timekeeping locks prior to calling
ntp functions.
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')
| -rw-r--r-- | kernel/time/timekeeping.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index e44915c7b16c..d10bd734b151 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
| @@ -787,10 +787,10 @@ void __init timekeeping_init(void) | |||
| 787 | boot.tv_nsec = 0; | 787 | boot.tv_nsec = 0; |
| 788 | } | 788 | } |
| 789 | 789 | ||
| 790 | ntp_init(); | ||
| 791 | |||
| 792 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 790 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 793 | write_seqcount_begin(&timekeeper_seq); | 791 | write_seqcount_begin(&timekeeper_seq); |
| 792 | ntp_init(); | ||
| 793 | |||
| 794 | clock = clocksource_default_clock(); | 794 | clock = clocksource_default_clock(); |
| 795 | if (clock->enable) | 795 | if (clock->enable) |
| 796 | clock->enable(clock); | 796 | clock->enable(clock); |
| @@ -1618,6 +1618,7 @@ EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); | |||
| 1618 | */ | 1618 | */ |
| 1619 | int do_adjtimex(struct timex *txc) | 1619 | int do_adjtimex(struct timex *txc) |
| 1620 | { | 1620 | { |
| 1621 | unsigned long flags; | ||
| 1621 | struct timespec ts; | 1622 | struct timespec ts; |
| 1622 | s32 tai, orig_tai; | 1623 | s32 tai, orig_tai; |
| 1623 | int ret; | 1624 | int ret; |
| @@ -1641,8 +1642,14 @@ int do_adjtimex(struct timex *txc) | |||
| 1641 | getnstimeofday(&ts); | 1642 | getnstimeofday(&ts); |
| 1642 | orig_tai = tai = timekeeping_get_tai_offset(); | 1643 | orig_tai = tai = timekeeping_get_tai_offset(); |
| 1643 | 1644 | ||
| 1645 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | ||
| 1646 | write_seqcount_begin(&timekeeper_seq); | ||
| 1647 | |||
| 1644 | ret = __do_adjtimex(txc, &ts, &tai); | 1648 | ret = __do_adjtimex(txc, &ts, &tai); |
| 1645 | 1649 | ||
| 1650 | write_seqcount_end(&timekeeper_seq); | ||
| 1651 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 1652 | |||
| 1646 | if (tai != orig_tai) | 1653 | if (tai != orig_tai) |
| 1647 | timekeeping_set_tai_offset(tai); | 1654 | timekeeping_set_tai_offset(tai); |
| 1648 | 1655 | ||
| @@ -1655,7 +1662,15 @@ int do_adjtimex(struct timex *txc) | |||
| 1655 | */ | 1662 | */ |
| 1656 | void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) | 1663 | void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) |
| 1657 | { | 1664 | { |
| 1665 | unsigned long flags; | ||
| 1666 | |||
| 1667 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | ||
| 1668 | write_seqcount_begin(&timekeeper_seq); | ||
| 1669 | |||
| 1658 | __hardpps(phase_ts, raw_ts); | 1670 | __hardpps(phase_ts, raw_ts); |
| 1671 | |||
| 1672 | write_seqcount_end(&timekeeper_seq); | ||
| 1673 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 1659 | } | 1674 | } |
| 1660 | EXPORT_SYMBOL(hardpps); | 1675 | EXPORT_SYMBOL(hardpps); |
| 1661 | #endif | 1676 | #endif |
