diff options
author | Rob Herring <rob.herring@calxeda.com> | 2013-03-11 17:23:46 -0400 |
---|---|---|
committer | Rob Herring <rob.herring@calxeda.com> | 2013-04-11 16:11:14 -0400 |
commit | 023796b9be3a77481cd5ee0b64a13a55bb0d5df4 (patch) | |
tree | ecf5a33e6deb251eee4cb61a12b5f60273c72bf2 /arch/arm/kernel | |
parent | 7e48c0b9d9ab07c92cd26f167010cd5a50eb0cec (diff) |
ARM: arch_timer: use full 64-bit counter for sched_clock
Only 32-bits of the arch timer were being used and wrapping was needlessly
being done in s/w. By using the full counter (56-64 bits), we don't need
to deal with wrapping and can simplify the implementation when using
arch timer.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r-- | arch/arm/kernel/arch_timer.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c index d957a51435d8..80c458fc4a30 100644 --- a/arch/arm/kernel/arch_timer.c +++ b/arch/arm/kernel/arch_timer.c | |||
@@ -22,9 +22,11 @@ static unsigned long arch_timer_read_counter_long(void) | |||
22 | return arch_timer_read_counter(); | 22 | return arch_timer_read_counter(); |
23 | } | 23 | } |
24 | 24 | ||
25 | static u32 arch_timer_read_counter_u32(void) | 25 | static u32 sched_clock_mult __read_mostly; |
26 | |||
27 | static unsigned long long notrace arch_timer_sched_clock(void) | ||
26 | { | 28 | { |
27 | return arch_timer_read_counter(); | 29 | return arch_timer_read_counter() * sched_clock_mult; |
28 | } | 30 | } |
29 | 31 | ||
30 | static struct delay_timer arch_delay_timer; | 32 | static struct delay_timer arch_delay_timer; |
@@ -52,10 +54,16 @@ int __init arch_timer_of_register(void) | |||
52 | 54 | ||
53 | int __init arch_timer_sched_clock_init(void) | 55 | int __init arch_timer_sched_clock_init(void) |
54 | { | 56 | { |
55 | if (arch_timer_get_rate() == 0) | 57 | u32 arch_timer_rate = arch_timer_get_rate(); |
58 | |||
59 | if (arch_timer_rate == 0) | ||
56 | return -ENXIO; | 60 | return -ENXIO; |
57 | 61 | ||
58 | setup_sched_clock(arch_timer_read_counter_u32, | 62 | /* Cache the sched_clock multiplier to save a divide in the hot path. */ |
59 | 32, arch_timer_get_rate()); | 63 | sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; |
64 | sched_clock_func = arch_timer_sched_clock; | ||
65 | pr_info("sched_clock: ARM arch timer >56 bits at %ukHz, resolution %uns\n", | ||
66 | arch_timer_rate / 1000, sched_clock_mult); | ||
67 | |||
60 | return 0; | 68 | return 0; |
61 | } | 69 | } |