From: Lei Wen <leiwen@marvell.com>
To: John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@codeaurora.org>,
Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Michael Opdenacker <michael.opdenacker@free-electrons.com>,
Joe Perches <joe@perches.com>, Tejun Heo <tj@kernel.org>,
Petr Mladek <pmladek@suse.cz>, <linux-kernel@vger.kernel.org>,
<leiwen@marvell.com>
Subject: [PATCH 2/3] timekeeping: move clocksource init to the early place
Date: Fri, 4 Apr 2014 11:18:41 +0800 [thread overview]
Message-ID: <1396581522-3309-3-git-send-email-leiwen@marvell.com> (raw)
In-Reply-To: <1396581522-3309-1-git-send-email-leiwen@marvell.com>
So that in the very early booting place, we could call timekeeping
code, while it would not cause system panic, since clock is not
init yet.
And for system default clock is always jiffies, so that it shall be
safe to do so.
Signed-off-by: Lei Wen <leiwen@marvell.com>
---
include/linux/time.h | 1 +
init/main.c | 1 +
kernel/time/timekeeping.c | 22 +++++++++++++++-------
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/include/linux/time.h b/include/linux/time.h
index a2f5079..e2d4899 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -127,6 +127,7 @@ extern void read_boot_clock(struct timespec *ts);
extern int persistent_clock_is_local;
extern int update_persistent_clock(struct timespec now);
void timekeeping_init(void);
+void timekeeping_init_early(void);
extern int timekeeping_suspended;
unsigned long get_seconds(void);
diff --git a/init/main.c b/init/main.c
index 9c7fd4c..5723933 100644
--- a/init/main.c
+++ b/init/main.c
@@ -494,6 +494,7 @@ asmlinkage void __init start_kernel(void)
*/
boot_init_stack_canary();
+ timekeeping_init_early();
cgroup_init_early();
local_irq_disable();
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index c196111..b8f850b 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -782,12 +782,25 @@ void __attribute__((weak)) read_boot_clock(struct timespec *ts)
}
/*
- * timekeeping_init - Initializes the clocksource and common timekeeping values
+ * timekeeping_init_early - setup clocksource early
*/
-void __init timekeeping_init(void)
+void __init timekeeping_init_early(void)
{
struct timekeeper *tk = &timekeeper;
struct clocksource *clock;
+
+ clock = clocksource_default_clock();
+ if (clock->enable)
+ clock->enable(clock);
+ tk_setup_internals(tk, clock);
+}
+
+/*
+ * timekeeping_init - Initializes common timekeeping values
+ */
+void __init timekeeping_init(void)
+{
+ struct timekeeper *tk = &timekeeper;
unsigned long flags;
struct timespec now, boot, tmp;
@@ -813,11 +826,6 @@ void __init timekeeping_init(void)
write_seqcount_begin(&timekeeper_seq);
ntp_init();
- clock = clocksource_default_clock();
- if (clock->enable)
- clock->enable(clock);
- tk_setup_internals(tk, clock);
-
tk_set_xtime(tk, &now);
tk->raw_time.tv_sec = 0;
tk->raw_time.tv_nsec = 0;
--
1.8.3.2
next prev parent reply other threads:[~2014-04-04 3:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-04 3:18 [PATCH 0/3] switch printk timestamp to use booting time Lei Wen
2014-04-04 3:18 ` [PATCH 1/3] time: create __get_monotonic_boottime for WARNless calls Lei Wen
2014-04-04 3:18 ` Lei Wen [this message]
2014-04-04 3:18 ` [PATCH 3/3] printk: using booting time as the timestamp Lei Wen
2014-04-04 21:55 ` John Stultz
2014-04-05 8:01 ` Peter Zijlstra
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=1396581522-3309-3-git-send-email-leiwen@marvell.com \
--to=leiwen@marvell.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.opdenacker@free-electrons.com \
--cc=pmladek@suse.cz \
--cc=rostedt@goodmis.org \
--cc=sboyd@codeaurora.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®