All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mason <mpeg.blue@free.fr>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: Linux ARM <linux-arm-kernel@lists.infradead.org>,
	cpufreq <cpufreq@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	John Stultz <john.stultz@linaro.org>,
	Stefan Agner <stefan@agner.ch>, Shawn Guo <shawn.guo@linaro.org>,
	Rob Herring <robh@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: Delays, clocks, timers, hrtimers, etc
Date: Wed, 11 Feb 2015 09:43:12 -0800	[thread overview]
Message-ID: <54DB94B0.8020000@free.fr> (raw)
In-Reply-To: <54D947B4.4080401@free.fr>

Mason wrote:

> Stephen Boyd wrote:
>
>> Mason wrote:
>>
>>> My platform provides a 32-bit counter, ticking at a constant 27 MHz.
>>> Reading this counter has a latency of roughly 70 ns (it has to go
>>> over the system memory bus). I think this is good enough for both
>>> the clock source and sched_clock, is it not?
>>>
>>> So the plan would be:
>>> - clocksource and sched_clock : 27 MHz, 32-bit counter, platform
>>> - clockevents : TWD, standard
>>
>> Yep, that sounds like a good plan. If your platform has the ARM global
>> timer (drivers/clocksource/arm_global_timer.c) then you don't need
>> anything besides that timer because it provides both the clocksource,
>> sched_clock, and clockevents. Sounds like you don't have that timer
>
> I'm using Cortex A9, so I do have the global timer (AFAIU).
>
> However, I don't think I can safely use it as a clock source because
> I'm also using cpufreq, and I don't think the arm_global_timer driver
> handles CPU frequency updates, while the TWD driver does (?)
>
> /*
>   * Updates clockevent frequency when the cpu frequency changes.
>   * Called on the cpu that is changing frequency with interrupts disabled.
>   */
>
> "The Interrupt Controller, global timer, private timers, and watchdogs
> are clocked with PERIPHCLK." And PERIPHCLK is tied to CLK, which is
> modified by cpufreq. I didn't see any code in the arm_global_timer
> driver to deal with with that.
>
> Did I overlook something fundamental?
>
>> though, so you have to write a driver for your custom platform timer and
>> at least hook up clocksource and sched_clock to it. If you have
>> interrupts with your platform timer you can skip out on TWD and also
>> register a clockevent in your platform timer driver.
>
> Registering a clock source or a sched_clock seems straight-forward.
> All I need to provide is a function to read the platform counter.
>
> However, why would I skip out on TWD?
> (I'm trying to minimize code needed for the port.)

Please forgive me for piling on extra questions:

Cortex A9 provides the global timer, and the local timers/watchdog,
both of which can be used for clockevents, AFAICT. Are there other
choices available, or are these the only (standard) options?

Also, you wrote "I don't see any problem with the TWD dropping the
dependency on SMP." Would something as simple as this be acceptable?
(Most probably NOT; there are a lot of smp* occurrences in smp_twd.c
even the file name.) What is the rationale for the dependency?


diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a34698d..47b02c8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1565,7 +1565,6 @@ config HAVE_ARM_ARCH_TIMER
  
  config HAVE_ARM_TWD
         bool
-       depends on SMP
         select CLKSRC_OF if OF
         help
           This options enables support for the ARM timer and watchdog unit


Regards.


WARNING: multiple messages have this Message-ID (diff)
From: mpeg.blue@free.fr (Mason)
To: linux-arm-kernel@lists.infradead.org
Subject: Delays, clocks, timers, hrtimers, etc
Date: Wed, 11 Feb 2015 09:43:12 -0800	[thread overview]
Message-ID: <54DB94B0.8020000@free.fr> (raw)
In-Reply-To: <54D947B4.4080401@free.fr>

Mason wrote:

> Stephen Boyd wrote:
>
>> Mason wrote:
>>
>>> My platform provides a 32-bit counter, ticking at a constant 27 MHz.
>>> Reading this counter has a latency of roughly 70 ns (it has to go
>>> over the system memory bus). I think this is good enough for both
>>> the clock source and sched_clock, is it not?
>>>
>>> So the plan would be:
>>> - clocksource and sched_clock : 27 MHz, 32-bit counter, platform
>>> - clockevents : TWD, standard
>>
>> Yep, that sounds like a good plan. If your platform has the ARM global
>> timer (drivers/clocksource/arm_global_timer.c) then you don't need
>> anything besides that timer because it provides both the clocksource,
>> sched_clock, and clockevents. Sounds like you don't have that timer
>
> I'm using Cortex A9, so I do have the global timer (AFAIU).
>
> However, I don't think I can safely use it as a clock source because
> I'm also using cpufreq, and I don't think the arm_global_timer driver
> handles CPU frequency updates, while the TWD driver does (?)
>
> /*
>   * Updates clockevent frequency when the cpu frequency changes.
>   * Called on the cpu that is changing frequency with interrupts disabled.
>   */
>
> "The Interrupt Controller, global timer, private timers, and watchdogs
> are clocked with PERIPHCLK." And PERIPHCLK is tied to CLK, which is
> modified by cpufreq. I didn't see any code in the arm_global_timer
> driver to deal with with that.
>
> Did I overlook something fundamental?
>
>> though, so you have to write a driver for your custom platform timer and
>> at least hook up clocksource and sched_clock to it. If you have
>> interrupts with your platform timer you can skip out on TWD and also
>> register a clockevent in your platform timer driver.
>
> Registering a clock source or a sched_clock seems straight-forward.
> All I need to provide is a function to read the platform counter.
>
> However, why would I skip out on TWD?
> (I'm trying to minimize code needed for the port.)

Please forgive me for piling on extra questions:

Cortex A9 provides the global timer, and the local timers/watchdog,
both of which can be used for clockevents, AFAICT. Are there other
choices available, or are these the only (standard) options?

Also, you wrote "I don't see any problem with the TWD dropping the
dependency on SMP." Would something as simple as this be acceptable?
(Most probably NOT; there are a lot of smp* occurrences in smp_twd.c
even the file name.) What is the rationale for the dependency?


diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a34698d..47b02c8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1565,7 +1565,6 @@ config HAVE_ARM_ARCH_TIMER
  
  config HAVE_ARM_TWD
         bool
-       depends on SMP
         select CLKSRC_OF if OF
         help
           This options enables support for the ARM timer and watchdog unit


Regards.

  reply	other threads:[~2015-02-11 17:43 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28 13:16 Delays, clocks, timers, hrtimers, etc Mason
2015-01-28 13:16 ` Mason
2015-01-29 13:57 ` Mason
2015-01-29 13:57   ` Mason
2015-02-03 12:09 ` Russell King - ARM Linux
2015-02-03 12:09   ` Russell King - ARM Linux
2015-02-06 18:37   ` Mason
2015-02-06 18:37     ` Mason
2015-02-06 19:14     ` Russell King - ARM Linux
2015-02-06 19:14       ` Russell King - ARM Linux
2015-02-06 21:03       ` Mason
2015-02-06 21:03         ` Mason
2015-02-07 10:42         ` Russell King - ARM Linux
2015-02-07 10:42           ` Russell King - ARM Linux
2015-02-09  7:45       ` Michal Simek
2015-02-09  7:45         ` Michal Simek
2015-02-09 16:10         ` Sören Brinkmann
2015-02-09 16:10           ` Sören Brinkmann
2015-02-09 23:27   ` Mason
2015-02-09 23:27     ` Mason
2015-02-06 20:25 ` Stefan Agner
2015-02-06 20:25   ` Stefan Agner
2015-02-06 21:17   ` Mason
2015-02-06 21:17     ` Mason
2015-02-06 21:31     ` Stefan Agner
2015-02-06 21:31       ` Stefan Agner
2015-02-07  2:21       ` Mason
2015-02-07  2:21         ` Mason
2015-02-07  9:51         ` Russell King - ARM Linux
2015-02-07  9:51           ` Russell King - ARM Linux
2015-02-09 19:01         ` Stephen Boyd
2015-02-09 19:01           ` Stephen Boyd
2015-02-09 22:31           ` Mason
2015-02-09 22:31             ` Mason
2015-02-09 23:17             ` Stephen Boyd
2015-02-09 23:17               ` Stephen Boyd
2015-02-09 23:50               ` Mason
2015-02-09 23:50                 ` Mason
2015-02-11 17:43                 ` Mason [this message]
2015-02-11 17:43                   ` Mason
2015-02-11 18:45                   ` Stephen Boyd
2015-02-11 18:45                     ` Stephen Boyd
2015-02-11 21:58                     ` Mason
2015-02-11 21:58                       ` Mason
2015-02-11 23:26                       ` Stephen Boyd
2015-02-11 23:26                         ` Stephen Boyd

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=54DB94B0.8020000@free.fr \
    --to=mpeg.blue@free.fr \
    --cc=cpufreq@vger.kernel.org \
    --cc=john.stultz@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=shawn.guo@linaro.org \
    --cc=stefan@agner.ch \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.