diff options
author | Nicolas Pitre <nico@cam.org> | 2006-12-04 14:25:47 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-12-07 11:06:50 -0500 |
commit | 2f1675c11a0a214855ff6cba23aca239eef7a5fb (patch) | |
tree | dd5b3d6dee3037023b0d3b832202433e8d87cfa2 | |
parent | 838ccbc35eae5b44d47724e5f694dbec4a26d269 (diff) |
[ARM] 3979/1: extend the SA11x0 sched_clock implementation from 32 to 63 bit period
This provides a 63 bit clock counter guaranteed to be monotonic over a
period of 370 days instead of a clock wrap every 19.4 minutes, as long
as sched_clock() is called at least once every 9.7 minutes which
shouldn't be a problem in practice.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/mach-sa1100/generic.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 4575f316e141..e510295c2580 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | 21 | ||
22 | #include <asm/div64.h> | 22 | #include <asm/div64.h> |
23 | #include <asm/cnt32_to_63.h> | ||
23 | #include <asm/hardware.h> | 24 | #include <asm/hardware.h> |
24 | #include <asm/system.h> | 25 | #include <asm/system.h> |
25 | #include <asm/pgtable.h> | 26 | #include <asm/pgtable.h> |
@@ -118,15 +119,21 @@ EXPORT_SYMBOL(cpufreq_get); | |||
118 | 119 | ||
119 | /* | 120 | /* |
120 | * This is the SA11x0 sched_clock implementation. This has | 121 | * This is the SA11x0 sched_clock implementation. This has |
121 | * a resolution of 271ns, and a maximum value of 1165s. | 122 | * a resolution of 271ns, and a maximum value of 32025597s (370 days). |
123 | * | ||
124 | * The return value is guaranteed to be monotonic in that range as | ||
125 | * long as there is always less than 582 seconds between successive | ||
126 | * calls to this function. | ||
127 | * | ||
122 | * ( * 1E9 / 3686400 => * 78125 / 288) | 128 | * ( * 1E9 / 3686400 => * 78125 / 288) |
123 | */ | 129 | */ |
124 | unsigned long long sched_clock(void) | 130 | unsigned long long sched_clock(void) |
125 | { | 131 | { |
126 | unsigned long long v; | 132 | unsigned long long v = cnt32_to_63(OSCR); |
127 | 133 | ||
128 | v = (unsigned long long)OSCR * 78125; | 134 | /* the <<1 gets rid of the cnt_32_to_63 top bit saving on a bic insn */ |
129 | do_div(v, 288); | 135 | v *= 78125<<1; |
136 | do_div(v, 288<<1); | ||
130 | 137 | ||
131 | return v; | 138 | return v; |
132 | } | 139 | } |