From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/13] ARM: pxa: convert sched_clock() to use new infrastructure
Date: Thu, 16 Dec 2010 09:28:48 +0000 [thread overview]
Message-ID: <E1PTA8m-00079T-Ce@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20101216092527.GL9937@n2100.arm.linux.org.uk>
Convert pxa to use the new sched_clock() infrastructure for extending
32bit counters to full 64-bit nanoseconds.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/Kconfig | 1 +
arch/arm/mach-pxa/time.c | 29 +++++++++--------------------
2 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0208e1e..23035d6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -593,6 +593,7 @@ config ARCH_PXA
select COMMON_CLKDEV
select ARCH_REQUIRE_GPIOLIB
select GENERIC_CLOCKEVENTS
+ select HAVE_SCHED_CLOCK
select TICK_ONESHOT
select PLAT_PXA
select SPARSE_IRQ
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index b8d9dff..e7f64d9 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -17,11 +17,11 @@
#include <linux/interrupt.h>
#include <linux/clockchips.h>
#include <linux/sched.h>
-#include <linux/cnt32_to_63.h>
#include <asm/div64.h>
#include <asm/mach/irq.h>
#include <asm/mach/time.h>
+#include <asm/sched_clock.h>
#include <mach/regs-ost.h>
/*
@@ -32,29 +32,18 @@
* long as there is always less than 582 seconds between successive
* calls to sched_clock() which should always be the case in practice.
*/
+static DEFINE_CLOCK_DATA(cd);
-#define OSCR2NS_SCALE_FACTOR 10
-
-static unsigned long oscr2ns_scale;
-
-static void __init set_oscr2ns_scale(unsigned long oscr_rate)
+unsigned long long notrace sched_clock(void)
{
- unsigned long long v = 1000000000ULL << OSCR2NS_SCALE_FACTOR;
- do_div(v, oscr_rate);
- oscr2ns_scale = v;
- /*
- * We want an even value to automatically clear the top bit
- * returned by cnt32_to_63() without an additional run time
- * instruction. So if the LSB is 1 then round it up.
- */
- if (oscr2ns_scale & 1)
- oscr2ns_scale++;
+ u32 cyc = OSCR;
+ return cyc_to_sched_clock(&cd, cyc, (u32)~0);
}
-unsigned long long notrace sched_clock(void)
+static void notrace pxa_update_sched_clock(void)
{
- unsigned long long v = cnt32_to_63(OSCR);
- return (v * oscr2ns_scale) >> OSCR2NS_SCALE_FACTOR;
+ u32 cyc = OSCR;
+ update_sched_clock(&cd, cyc, (u32)~0);
}
@@ -144,7 +133,7 @@ static void __init pxa_timer_init(void)
OIER = 0;
OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3;
- set_oscr2ns_scale(clock_tick_rate);
+ init_sched_clock(&cd, pxa_update_sched_clock, 32, clock_tick_rate);
ckevt_pxa_osmr0.mult =
div_sc(clock_tick_rate, NSEC_PER_SEC, ckevt_pxa_osmr0.shift);
--
1.6.2.5
next prev parent reply other threads:[~2010-12-16 9:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-16 9:25 [PATCH 0/13] 64-bit sched_clock Russell King - ARM Linux
2010-12-16 9:27 ` [PATCH 01/13] ARM: sched_clock: provide common infrastructure for sched_clock() Russell King - ARM Linux
2010-12-16 12:52 ` Russell King - ARM Linux
2010-12-16 9:28 ` [PATCH 02/13] ARM: ixp4xx: convert sched_clock() to use new infrastructure Russell King - ARM Linux
2010-12-16 9:28 ` [PATCH 03/13] ARM: mmp: " Russell King - ARM Linux
2010-12-16 9:28 ` Russell King - ARM Linux [this message]
2010-12-16 10:05 ` [PATCH 04/13] ARM: pxa: " Uwe Kleine-König
2010-12-16 10:14 ` Russell King - ARM Linux
2010-12-16 9:29 ` [PATCH 05/13] ARM: sa1100: " Russell King - ARM Linux
2010-12-16 9:29 ` [PATCH 06/13] ARM: tegra: " Russell King - ARM Linux
2010-12-16 9:29 ` [PATCH 07/13] ARM: u300: " Russell King - ARM Linux
2010-12-16 9:30 ` [PATCH 08/13] ARM: iop: " Russell King - ARM Linux
2010-12-16 9:30 ` [PATCH 09/13] ARM: nomadik: " Russell King - ARM Linux
2010-12-16 9:31 ` [PATCH 10/13] ARM: omap: " Russell King - ARM Linux
2010-12-16 9:31 ` [PATCH 11/13] ARM: orion: " Russell King - ARM Linux
2010-12-16 9:31 ` [PATCH 12/13] ARM: versatile: " Russell King - ARM Linux
2010-12-16 9:32 ` [PATCH 13/13] ARM: vexpress: add sched_clock() for Versatile Express Russell King - ARM Linux
2010-12-16 13:04 ` [PATCH 0/13] 64-bit sched_clock Russell King - ARM Linux
2010-12-19 22:23 ` Linus Walleij
2010-12-19 23:39 ` Russell King - ARM Linux
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=E1PTA8m-00079T-Ce@rmk-PC.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/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).