From: Nicolai Stange <nicstange@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>,
linux-kernel@vger.kernel.org,
Nicolai Stange <nicstange@gmail.com>
Subject: [RFC v3 3/3] kernel/time/timekeeping: inform clockevents about freq adjustments
Date: Wed, 13 Jul 2016 15:00:17 +0200 [thread overview]
Message-ID: <20160713130017.8202-4-nicstange@gmail.com> (raw)
In-Reply-To: <20160713130017.8202-1-nicstange@gmail.com>
Upon adjustments of the monotonic clock's frequencies from the
timekeeping core, the clockevents devices' ->mult_mono should be changed
accordingly, too.
Introduce clockevents_adjust_all_freqs() which traverses all registered
clockevent devices and recalculates their ->mult_mono based on the
monotonic clock's current frequency.
Call clockevents_adjust_all_freqs() from timekeeping_apply_adjustment().
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
---
kernel/time/clockevents.c | 25 +++++++++++++++++++++++++
kernel/time/tick-internal.h | 1 +
kernel/time/timekeeping.c | 3 +++
3 files changed, 29 insertions(+)
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index ec01375..f3fb1e5 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -558,6 +558,31 @@ void __clockevents_adjust_freq(struct clock_event_device *dev)
mult_cs_raw);
}
+void clockevents_adjust_all_freqs(u32 mult_cs_mono, u32 mult_cs_raw)
+{
+ u32 last_mult_raw = 0, last_mult_mono = 0;
+ u32 mult_raw;
+ unsigned long flags;
+ struct clock_event_device *dev;
+
+ raw_spin_lock_irqsave(&clockevents_lock, flags);
+ list_for_each_entry(dev, &clockevent_devices, list) {
+ if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
+ continue;
+
+ mult_raw = dev->mult;
+ if (mult_raw != last_mult_raw) {
+ last_mult_raw = mult_raw;
+ last_mult_mono =
+ __clockevents_calc_adjust_freq(mult_raw,
+ mult_cs_mono,
+ mult_cs_raw);
+ }
+ dev->mult_mono = last_mult_mono;
+ }
+ raw_spin_unlock_irqrestore(&clockevents_lock, flags);
+}
+
int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
{
clockevents_config(dev, freq);
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 0b29d23..9162671 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -56,6 +56,7 @@ extern int clockevents_program_event(struct clock_event_device *dev,
ktime_t expires, bool force);
extern void clockevents_handle_noop(struct clock_event_device *dev);
extern int __clockevents_update_freq(struct clock_event_device *dev, u32 freq);
+extern void clockevents_adjust_all_freqs(u32 mult_cs_mono, u32 mult_cs_raw);
extern void timekeeping_get_mono_mult(u32 *mult_cs_mono, u32 *mult_cs_raw);
extern ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index a011ae1..e98f67c 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1852,6 +1852,9 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk,
tk->xtime_interval += interval;
tk->tkr_mono.xtime_nsec -= offset;
tk->ntp_error -= (interval - offset) << tk->ntp_error_shift;
+
+ clockevents_adjust_all_freqs(tk->tkr_mono.mult,
+ tk->tkr_mono.clock->mult);
}
/*
--
2.9.0
prev parent reply other threads:[~2016-07-13 13:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 13:00 [RFC v3 0/3] adapt clockevents frequencies to mono clock Nicolai Stange
2016-07-13 13:00 ` [RFC v3 1/3] kernel/time/clockevents: initial support for mono to raw time conversion Nicolai Stange
2016-07-21 18:08 ` John Stultz
2016-07-21 19:11 ` Nicolai Stange
2016-07-13 13:00 ` [RFC v3 2/3] kernel/time/clockevents: make setting of ->mult and ->mult_mono atomic Nicolai Stange
2016-07-21 18:16 ` John Stultz
2016-07-21 19:24 ` Nicolai Stange
2016-07-21 19:31 ` John Stultz
2016-07-13 13:00 ` Nicolai Stange [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160713130017.8202-4-nicstange@gmail.com \
--to=nicstange@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.