lkml.org 
[lkml]   [2018]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 3/3] arm64: Early boot time stamps
Date
Allow printk time stamps/sched_clock() to be available from the early
boot.

Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
---
arch/arm64/kernel/setup.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 4b0e1231625c..28126facc4ed 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -40,6 +40,7 @@
#include <linux/efi.h>
#include <linux/psci.h>
#include <linux/sched/task.h>
+#include <linux/sched_clock.h>
#include <linux/mm.h>

#include <asm/acpi.h>
@@ -279,8 +280,32 @@ arch_initcall(reserve_memblock_reserved_regions);

u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };

+/*
+ * Get time stamps available early in boot, useful to identify boot time issues
+ * from the early boot.
+ */
+static __init void sched_clock_early_init(void)
+{
+ u64 (*read_time)(void) = arch_counter_get_cntvct;
+ u64 freq = arch_timer_get_cntfrq();
+
+ /*
+ * The arm64 boot protocol mandates that CNTFRQ_EL0 reflects
+ * the timer frequency. To avoid breakage on misconfigured
+ * systems, do not register the early sched_clock if the
+ * programmed value if zero. Other random values will just
+ * result in random output.
+ */
+ if (!freq)
+ return;
+
+ sched_clock_register(read_time, ARCH_TIMER_NBITS, freq);
+}
+
void __init setup_arch(char **cmdline_p)
{
+ sched_clock_early_init();
+
init_mm.start_code = (unsigned long) _text;
init_mm.end_code = (unsigned long) _etext;
init_mm.end_data = (unsigned long) _edata;
--
2.20.1
\
 
 \ /
  Last update: 2018-12-26 17:45    [W:1.821 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site