From: sjg@chromium.org (Simon Glass)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 3/3] bootstage: Get u-boot timing from the device tree.
Date: Fri, 23 Sep 2011 16:03:18 -0700 [thread overview]
Message-ID: <1316818998-30711-4-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1316818998-30711-1-git-send-email-sjg@chromium.org>
From: Da Zheng <zhengda@chromium.org>
From: Da Zheng <zhengda@chromium.org>
The bootstage driver accesses the u-boot timings in the device tree
and copies them to its array during initialization.
Signed-off-by: Da Zheng <zhengda@chromium.com>
---
arch/arm/kernel/time.c | 29 +++++++++++++++++++++++++++++
include/linux/bootstage.h | 1 +
init/bootstage.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index cb634c3..524a1f5 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -24,6 +24,8 @@
#include <linux/syscore_ops.h>
#include <linux/timer.h>
#include <linux/irq.h>
+#include <linux/bootstage.h>
+#include <linux/of.h>
#include <linux/mc146818rtc.h>
@@ -156,3 +158,30 @@ void __init time_init(void)
#endif
}
+#ifdef CONFIG_BOOTSTAGE
+int get_prekernel_timing(void)
+{
+ struct device_node *node;
+ struct device_node *child;
+ int i = 0;
+
+ printk(KERN_INFO "TEST: bootstage_init is called in tegra\n");
+ node = of_find_node_by_path("/bootstage");
+ if (node == NULL)
+ return 0;
+
+ for_each_child_of_node(node, child) {
+ const char *name = of_get_property(child, "name", NULL);
+ const int *timep = of_get_property(child, "time", NULL);
+
+ if (name && timep) {
+ insert_bootstage(i, name,
+ (unsigned long) be32_to_cpu(*timep));
+ i++;
+ }
+ }
+ of_node_put(node);
+
+ return 0;
+}
+#endif
diff --git a/include/linux/bootstage.h b/include/linux/bootstage.h
index 08df102..95e837c 100644
--- a/include/linux/bootstage.h
+++ b/include/linux/bootstage.h
@@ -4,6 +4,7 @@
#ifdef CONFIG_BOOTSTAGE
unsigned long bootstage_mark(const char *name);
unsigned long bootstage_mark_early(const char *name);
+void insert_bootstage(int idx, const char *name, unsigned long time);
#else
static inline unsigned long bootstage_mark(const char *name)
{
diff --git a/init/bootstage.c b/init/bootstage.c
index 6f4668f..51f731d 100644
--- a/init/bootstage.c
+++ b/init/bootstage.c
@@ -75,6 +75,32 @@ static inline int __inc_bootstages(void)
}
/*
+ * Insert a new bootstage in the slot specified by `idx'.
+ * If the slot is already used, move it and slots behind it
+ * before inserting the new bootstage.
+ */
+void insert_bootstage(int idx, const char *name, unsigned long time)
+{
+ mutex_lock(&bootstage_mutex);
+
+ if (num_bootstages == cap_bootstages) {
+ if (__inc_bootstages() < 0) {
+ mutex_unlock(&bootstage_mutex);
+ return;
+ }
+ }
+
+ if (idx < num_bootstages)
+ memmove(&full_bootstages[idx + 1], &full_bootstages[idx],
+ sizeof(*full_bootstages) * (num_bootstages - idx));
+
+ strlcpy(full_bootstages[idx].name, name, MAX_NAME);
+ full_bootstages[idx].time = time;
+ num_bootstages++;
+ mutex_unlock(&bootstage_mutex);
+}
+
+/*
* This is used during the initialization of the kernel.
*/
unsigned long bootstage_mark(const char *name)
@@ -211,10 +237,20 @@ static const struct file_operations mark_operations = {
.write = bootstage_write,
};
+/*
+ * Get the timings that were recorded before the kernel is initialized.
+ */
+int __attribute__((weak)) get_prekernel_timing(void)
+{
+ return 0;
+}
+
static int __init bootstage_init(void)
{
struct dentry *dir;
+ get_prekernel_timing();
+
dir = debugfs_create_dir("bootstage", NULL);
if (dir && !IS_ERR(dir)) {
debugfs_create_file("report", S_IFREG|S_IRUSR|S_IRGRP|S_IROTH,
--
1.7.3.1
next prev parent reply other threads:[~2011-09-23 23:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-23 23:03 [RFC PATCH 0/3] Add accurate boot timing to a Linux system Simon Glass
2011-09-23 23:03 ` [RFC PATCH 1/3] bootstage: Add bootstages to record timing in the kernel Simon Glass
2011-09-23 23:03 ` [RFC PATCH 2/3] bootstage: Insert bootstage_mark to record timing for bootup Simon Glass
2011-09-25 12:59 ` Bjorn Helgaas
2011-09-23 23:03 ` Simon Glass [this message]
2011-09-23 23:34 ` [RFC PATCH 0/3] Add accurate boot timing to a Linux system Valdis.Kletnieks at vt.edu
2011-09-24 4:10 ` Simon Glass
2011-09-24 8:32 ` Russell King - ARM Linux
2011-09-24 14:06 ` Simon Glass
2011-09-26 7:53 ` Matthieu CASTET
2011-09-27 18:29 ` Simon Glass
2011-09-25 12:54 ` Bjorn Helgaas
2011-09-27 18:26 ` Simon Glass
2011-09-27 17:56 ` Tim Bird
2011-09-27 17:57 ` Tim Bird
2011-09-27 18:42 ` Simon Glass
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=1316818998-30711-4-git-send-email-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).