From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: David Engraf <david.engraf@sysgo.com>
Cc: <daniel.lezcano@linaro.org>, <tglx@linutronix.de>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tcb_clksrc: Use 32 bit tcb as sched_clock
Date: Tue, 24 Jan 2017 14:39:10 +0100 [thread overview]
Message-ID: <a32d362e-0197-708e-2cee-98a1cd75981d@atmel.com> (raw)
In-Reply-To: <20170111135059.21318-1-david.engraf@sysgo.com>
Le 11/01/2017 à 14:50, David Engraf a écrit :
> On newer boards the TC can be read as single 32 bit value without locking.
> Thus the clock can be used as reference for sched_clock which is much more
> accurate than the jiffies implementation.
>
> Tested on a Atmel SAMA5D2 board.
>
> Signed-off-by: David Engraf <david.engraf@sysgo.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Thanks,
> ---
> drivers/clocksource/tcb_clksrc.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
> index d4ca996..745844e 100644
> --- a/drivers/clocksource/tcb_clksrc.c
> +++ b/drivers/clocksource/tcb_clksrc.c
> @@ -10,6 +10,7 @@
> #include <linux/io.h>
> #include <linux/platform_device.h>
> #include <linux/atmel_tc.h>
> +#include <linux/sched_clock.h>
>
>
> /*
> @@ -56,11 +57,16 @@ static u64 tc_get_cycles(struct clocksource *cs)
> return (upper << 16) | lower;
> }
>
> -static u64 tc_get_cycles32(struct clocksource *cs)
> +static u32 tc_get_cv32(void)
> {
> return __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
> }
>
> +static u64 tc_get_cycles32(struct clocksource *cs)
> +{
> + return tc_get_cv32();
> +}
> +
> static struct clocksource clksrc = {
> .name = "tcb_clksrc",
> .rating = 200,
> @@ -69,6 +75,11 @@ static struct clocksource clksrc = {
> .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> };
>
> +static u64 notrace tc_read_sched_clock(void)
> +{
> + return tc_get_cv32();
> +}
> +
> #ifdef CONFIG_GENERIC_CLOCKEVENTS
>
> struct tc_clkevt_device {
> @@ -339,6 +350,9 @@ static int __init tcb_clksrc_init(void)
> clksrc.read = tc_get_cycles32;
> /* setup ony channel 0 */
> tcb_setup_single_chan(tc, best_divisor_idx);
> +
> + /* register sched_clock on chips with single 32 bit counter */
> + sched_clock_register(tc_read_sched_clock, 32, divided_rate);
> } else {
> /* tclib will give us three clocks no matter what the
> * underlying platform supports.
>
--
Nicolas Ferre
prev parent reply other threads:[~2017-01-24 13:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 13:50 David Engraf
[not found] ` <e9fa8375-70e9-e621-954e-48c3190171ad@linaro.org>
2017-01-17 9:29 ` David Engraf
2017-01-17 9:42 ` Mason
2017-01-17 14:44 ` Romain Izard
2017-01-23 13:59 ` Daniel Lezcano
2017-01-24 13:39 ` Nicolas Ferre
2017-01-24 13:39 ` Nicolas Ferre [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=a32d362e-0197-708e-2cee-98a1cd75981d@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=daniel.lezcano@linaro.org \
--cc=david.engraf@sysgo.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®