From: Pavel Tatashin <pasha.tatashin@soleen.com>
To: catalin.marinas@arm.com, will.deacon@arm.com,
akpm@linux-foundation.org, rppt@linux.vnet.ibm.com,
mhocko@suse.com, ard.biesheuvel@linaro.org,
andrew.murray@arm.com, james.morse@arm.com, marc.zyngier@arm.com,
sboyd@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com
Subject: [PATCH v2 1/1] arm64: Early boot time stamps
Date: Tue, 20 Nov 2018 09:43:40 -0500 [thread overview]
Message-ID: <20181120144340.30201-2-pasha.tatashin@soleen.com> (raw)
In-Reply-To: <20181120144340.30201-1-pasha.tatashin@soleen.com>
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 +++++++++++++++++++++++++
drivers/clocksource/arm_arch_timer.c | 8 ++++----
include/clocksource/arm_arch_timer.h | 3 +++
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index f4fc1e0544b7..7a43e63b737b 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 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;
+
+ arch_timer_read_counter = arch_counter_get_cntvct;
+ sched_clock_register(arch_timer_read_counter, 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;
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 9a7d4dc00b6e..e4843ad48bd3 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -175,13 +175,13 @@ static struct clocksource clocksource_counter = {
.name = "arch_sys_counter",
.rating = 400,
.read = arch_counter_read,
- .mask = CLOCKSOURCE_MASK(56),
+ .mask = CLOCKSOURCE_MASK(ARCH_TIMER_NBITS),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
static struct cyclecounter cyclecounter __ro_after_init = {
.read = arch_counter_read_cc,
- .mask = CLOCKSOURCE_MASK(56),
+ .mask = CLOCKSOURCE_MASK(ARCH_TIMER_NBITS),
};
struct ate_acpi_oem_info {
@@ -963,8 +963,8 @@ static void __init arch_counter_register(unsigned type)
timecounter_init(&arch_timer_kvm_info.timecounter,
&cyclecounter, start_count);
- /* 56 bits minimum, so we assume worst case rollover */
- sched_clock_register(arch_timer_read_counter, 56, arch_timer_rate);
+ sched_clock_register(arch_timer_read_counter, ARCH_TIMER_NBITS,
+ arch_timer_rate);
}
static void arch_timer_stop(struct clock_event_device *clk)
diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
index 349e5957c949..c485512e1d01 100644
--- a/include/clocksource/arm_arch_timer.h
+++ b/include/clocksource/arm_arch_timer.h
@@ -71,6 +71,9 @@ enum arch_timer_spi_nr {
#define ARCH_TIMER_EVT_STREAM_FREQ \
(USEC_PER_SEC / ARCH_TIMER_EVT_STREAM_PERIOD_US)
+/* 56 bits minimum, so we assume worst case rollover */
+#define ARCH_TIMER_NBITS 56
+
struct arch_timer_kvm_info {
struct timecounter timecounter;
int virtual_irq;
--
2.19.1
next prev parent reply other threads:[~2018-11-20 14:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 14:43 [PATCH v2 0/1] Early boot time stamps for arm64 Pavel Tatashin
2018-11-20 14:43 ` Pavel Tatashin [this message]
2018-11-21 17:47 ` [PATCH v2 1/1] arm64: Early boot time stamps Will Deacon
2018-11-21 17:58 ` Pavel Tatashin
2018-11-22 14:14 ` Marc Zyngier
2018-12-05 16:01 ` Pavel Tatashin
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=20181120144340.30201-2-pasha.tatashin@soleen.com \
--to=pasha.tatashin@soleen.com \
--cc=akpm@linux-foundation.org \
--cc=andrew.murray@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mhocko@suse.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=sboyd@kernel.org \
--cc=will.deacon@arm.com \
/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).