All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carsten Emde <C.Emde@osadl.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	RT-users <linux-rt-users@vger.kernel.org>
Subject: Re: [PATCH V2 RESEND  1/1] Clocksource: Add sched_clock to Atmel TCB clocksource
Date: Wed, 03 Jun 2015 00:08:05 +0200	[thread overview]
Message-ID: <556E2945.4090800@osadl.org> (raw)
In-Reply-To: <20150602215215.577791619@osadl.org>

[Sorry, picked wrong patch]

The default sched_clock provides a maximum resolution of 1 ms which
normally is not sufficient to investigate scheduling related
irregularities - more so, if a low-latency or even a real-time kernel is
used. Therefore, register the Atmel TCB clocksource that provides a
resolution of 63 ns as sched_clock.

Signed-off-by: Carsten Emde <C.Emde@osadl.org>

---
  drivers/clocksource/tcb_clksrc.c |   11 +++++++++++
  1 file changed, 11 insertions(+)

Index: linux/drivers/clocksource/tcb_clksrc.c
===================================================================
--- linux.orig/drivers/clocksource/tcb_clksrc.c
+++ linux/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>


  /*
@@ -69,6 +70,11 @@ static struct clocksource clksrc = {
  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
  };

+static u64 sched_clock_get_cycles(void)
+{
+	return (u64) clksrc.read(NULL);
+}
+
  #ifdef CONFIG_GENERIC_CLOCKEVENTS

  struct tc_clkevt_device {
@@ -273,6 +279,7 @@ static int __init tcb_clksrc_init(void)
  	int clk32k_divisor_idx = -1;
  	int i;
  	int ret;
+	unsigned long flags;

  	tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK);
  	if (!tc) {
@@ -339,6 +346,10 @@ static int __init tcb_clksrc_init(void)
  	if (ret)
  		goto err_disable_t1;

+	local_irq_save(flags);
+	sched_clock_register(sched_clock_get_cycles, 32, divided_rate);
+	local_irq_restore(flags);
+
  	/* channel 2:  periodic and oneshot timer support */
  	ret = setup_clkevents(tc, clk32k_divisor_idx);
  	if (ret)

  reply	other threads:[~2015-06-02 22:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 21:46 [PATCH V2 1/1] Clocksource: Add sched_clock to Atmel TCB clocksource Carsten Emde
2015-06-02 22:08 ` Carsten Emde [this message]
2015-06-11 15:15   ` [PATCH V2 RESEND " Sebastian Andrzej Siewior

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=556E2945.4090800@osadl.org \
    --to=c.emde@osadl.org \
    --cc=bigeasy@linutronix.de \
    --cc=linux-rt-users@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 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.