From: Mark Rutland <mark.rutland@arm.com>
To: Bogdan Mirea <Bogdan-Stefan_mirea@mentor.com>
Cc: linux-kernel@vger.kernel.org, john.stultz@linaro.org,
tglx@linutronix.de, ore@pengutronix.de, kernel@pengutronix.de
Subject: Re: [PATCH v3] Added "Preserve Boot Time Support"
Date: Fri, 26 May 2017 12:09:59 +0100 [thread overview]
Message-ID: <20170526110959.GB21770@leverpostej> (raw)
In-Reply-To: <1495188983-47002-1-git-send-email-Bogdan-Stefan_mirea@mentor.com>
On Fri, May 19, 2017 at 01:16:23PM +0300, Bogdan Mirea wrote:
> This option enables Boot Time Preservation between Bootloader and
> Linux Kernel. It is based on the idea that the Bootloader (or any
> other early firmware) will start the HW Timer and Linux Kernel will
> count the time starting with the cycles elapsed since timer start.
>
> The sched_clock part is preserving boottime for kmsg which should be in
> sync with system uptime. The system uptime part is driver specific and I
> updated the arm_arch_timer with an arch_timer_setsystime() function
> which will call do_settimeofday64() with the values read from arch timer
> counter.
>
> This way both kmsg and uptime will be in sync, otherwise inconsistencies
> will appear between the two.
>
> The "preserve_boot_time" parameter should be appended to kernel cmdline
> from bootloader for kernel acknowledgment that the timer is running in
> bootloader.
>
> Signed-off-by: Bogdan Mirea <Bogdan-Stefan_mirea@mentor.com>
> ---
> drivers/clocksource/arm_arch_timer.c | 33 +++++++++++++++++++++++++++++++++
In future, *please* use get_maintainer.pl, and ensure all relevant
maintainers are on Cc. e.g.
[mark@leverpostej:~/src/linux]% ./scripts/get_maintainer.pl -f drivers/clocksource/arm_arch_timer.c
Mark Rutland <mark.rutland@arm.com> (maintainer:ARM ARCHITECTED TIMER DRIVER)
Marc Zyngier <marc.zyngier@arm.com> (maintainer:ARM ARCHITECTED TIMER DRIVER)
Daniel Lezcano <daniel.lezcano@linaro.org> (supporter:CLOCKSOURCE, CLOCKEVENT DRIVERS)
Thomas Gleixner <tglx@linutronix.de> (supporter:CLOCKSOURCE, CLOCKEVENT DRIVERS)
linux-arm-kernel@lists.infradead.org (moderated list:ARM ARCHITECTED TIMER DRIVER)
linux-kernel@vger.kernel.org (open list:CLOCKSOURCE, CLOCKEVENT DRIVERS)
As I was not Cc'd, I only spotted this by chance.
[...]
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index 5152b38..95699cd 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -475,6 +475,35 @@ struct timecounter *arch_timer_get_timecounter(void)
> return &timecounter;
> }
>
> +#ifdef CONFIG_BOOT_TIME_PRESERVE
> +/*
> + * Set the real system time(including the time spent in bootloader)
> + * based on the timer counter.
> + */
> +
> +#ifndef BOOT_TIME_PRESERVE_CMDLINE
> + #define BOOT_TIME_PRESERVE_CMDLINE "preserve_boot_time"
> +#endif
> +void arch_timer_setsystime(void)
> +{
> + static struct timespec64 boot_ts;
> + static cycles_t cycles;
> + unsigned long long nsecs;
> +
> + if (!strstr(boot_command_line, BOOT_TIME_PRESERVE_CMDLINE))
> + return;
> +
> + cycles = arch_timer_read_counter() ? arch_timer_read_counter() : 0;
> +
> + nsecs = clocksource_cyc2ns(cycles, clocksource_counter.mult,
> + clocksource_counter.shift);
> + timespec64_add_ns(&boot_ts, nsecs);
> +
> + if (do_settimeofday64(&boot_ts))
> + pr_warn("arch_timer: unable to set systime\n");
> +}
> +#endif /* CONFIG_BOOT_TIME_PRESERVE */
> +
> static void __init arch_counter_register(unsigned type)
> {
> u64 start_count;
> @@ -504,6 +533,10 @@ static void __init arch_counter_register(unsigned type)
>
> /* 56 bits minimum, so we assume worst case rollover */
> sched_clock_register(arch_timer_read_counter, 56, arch_timer_rate);
> +#ifdef CONFIG_BOOT_TIME_PRESERVE
> + /* Set systime */
> + arch_timer_setsystime();
> +#endif /* CONFIG_BOOT_TIME_PRESERVE */
> }
Regardless of what this is trying to achieve, this does not belong in
the arch timer driver, as Thomas has already said.
Thanks,
Mark.
prev parent reply other threads:[~2017-05-26 11:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 10:16 [PATCH v3] Added "Preserve Boot Time Support" Bogdan Mirea
2017-05-21 21:36 ` Thomas Gleixner
2017-05-23 15:50 ` Mirea, Bogdan-Stefan
2017-05-23 16:39 ` Thomas Gleixner
2017-05-24 9:35 ` Mirea, Bogdan-Stefan
2017-05-26 10:04 ` Thomas Gleixner
2017-05-30 10:07 ` Mirea, Bogdan-Stefan
2017-05-25 17:05 ` Pavel Machek
2017-05-26 11:09 ` Mark Rutland [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=20170526110959.GB21770@leverpostej \
--to=mark.rutland@arm.com \
--cc=Bogdan-Stefan_mirea@mentor.com \
--cc=john.stultz@linaro.org \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=ore@pengutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox