diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2013-07-18 19:21:18 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2013-10-09 19:54:10 -0400 |
commit | 65cd4f6c99c1170bd0114dbd71b978012ea44d28 (patch) | |
tree | fbde89149eb5032b49875cddf728d598ffd349ad | |
parent | 07783397c6e3757de805bda5e1139a9e47aa7d74 (diff) |
arch_timer: Move to generic sched_clock framework
Register with the generic sched_clock framework now that it
supports 64 bits. This fixes two problems with the current
sched_clock support for machines using the architected timers.
First off, we don't subtract the start value from subsequent
sched_clock calls so we can potentially start off with
sched_clock returning gigantic numbers. Second, there is no
support for suspend/resume handling so problems such as discussed
in 6a4dae5 (ARM: 7565/1: sched: stop sched_clock() during
suspend, 2012-10-23) can happen without this patch. Finally, it
allows us to move the sched_clock setup into drivers clocksource
out of the arch ports.
Cc: Christopher Covington <cov@codeaurora.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | arch/arm/kernel/arch_timer.c | 14 | ||||
-rw-r--r-- | arch/arm64/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm64/kernel/time.c | 10 | ||||
-rw-r--r-- | drivers/clocksource/arm_arch_timer.c | 10 |
4 files changed, 11 insertions, 24 deletions
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c index 221f07b11ccb..1791f12c180b 100644 --- a/arch/arm/kernel/arch_timer.c +++ b/arch/arm/kernel/arch_timer.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/sched_clock.h> | ||
15 | 14 | ||
16 | #include <asm/delay.h> | 15 | #include <asm/delay.h> |
17 | 16 | ||
@@ -22,13 +21,6 @@ static unsigned long arch_timer_read_counter_long(void) | |||
22 | return arch_timer_read_counter(); | 21 | return arch_timer_read_counter(); |
23 | } | 22 | } |
24 | 23 | ||
25 | static u32 sched_clock_mult __read_mostly; | ||
26 | |||
27 | static unsigned long long notrace arch_timer_sched_clock(void) | ||
28 | { | ||
29 | return arch_timer_read_counter() * sched_clock_mult; | ||
30 | } | ||
31 | |||
32 | static struct delay_timer arch_delay_timer; | 24 | static struct delay_timer arch_delay_timer; |
33 | 25 | ||
34 | static void __init arch_timer_delay_timer_register(void) | 26 | static void __init arch_timer_delay_timer_register(void) |
@@ -48,11 +40,5 @@ int __init arch_timer_arch_init(void) | |||
48 | 40 | ||
49 | arch_timer_delay_timer_register(); | 41 | arch_timer_delay_timer_register(); |
50 | 42 | ||
51 | /* Cache the sched_clock multiplier to save a divide in the hot path. */ | ||
52 | sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; | ||
53 | sched_clock_func = arch_timer_sched_clock; | ||
54 | pr_info("sched_clock: ARM arch timer >56 bits at %ukHz, resolution %uns\n", | ||
55 | arch_timer_rate / 1000, sched_clock_mult); | ||
56 | |||
57 | return 0; | 43 | return 0; |
58 | } | 44 | } |
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c04454876bcb..35fd0eb57270 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig | |||
@@ -14,6 +14,7 @@ config ARM64 | |||
14 | select GENERIC_IOMAP | 14 | select GENERIC_IOMAP |
15 | select GENERIC_IRQ_PROBE | 15 | select GENERIC_IRQ_PROBE |
16 | select GENERIC_IRQ_SHOW | 16 | select GENERIC_IRQ_SHOW |
17 | select GENERIC_SCHED_CLOCK | ||
17 | select GENERIC_SMP_IDLE_THREAD | 18 | select GENERIC_SMP_IDLE_THREAD |
18 | select GENERIC_TIME_VSYSCALL | 19 | select GENERIC_TIME_VSYSCALL |
19 | select HARDIRQS_SW_RESEND | 20 | select HARDIRQS_SW_RESEND |
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index 03dc3718eb13..29c39d5d77e3 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c | |||
@@ -61,13 +61,6 @@ unsigned long profile_pc(struct pt_regs *regs) | |||
61 | EXPORT_SYMBOL(profile_pc); | 61 | EXPORT_SYMBOL(profile_pc); |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | static u64 sched_clock_mult __read_mostly; | ||
65 | |||
66 | unsigned long long notrace sched_clock(void) | ||
67 | { | ||
68 | return arch_timer_read_counter() * sched_clock_mult; | ||
69 | } | ||
70 | |||
71 | void __init time_init(void) | 64 | void __init time_init(void) |
72 | { | 65 | { |
73 | u32 arch_timer_rate; | 66 | u32 arch_timer_rate; |
@@ -78,9 +71,6 @@ void __init time_init(void) | |||
78 | if (!arch_timer_rate) | 71 | if (!arch_timer_rate) |
79 | panic("Unable to initialise architected timer.\n"); | 72 | panic("Unable to initialise architected timer.\n"); |
80 | 73 | ||
81 | /* Cache the sched_clock multiplier to save a divide in the hot path. */ | ||
82 | sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; | ||
83 | |||
84 | /* Calibrate the delay loop directly */ | 74 | /* Calibrate the delay loop directly */ |
85 | lpj_fine = arch_timer_rate / HZ; | 75 | lpj_fine = arch_timer_rate / HZ; |
86 | } | 76 | } |
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index fbd9ccd5e114..5d527895c74d 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/of_address.h> | 19 | #include <linux/of_address.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/sched_clock.h> | ||
22 | 23 | ||
23 | #include <asm/arch_timer.h> | 24 | #include <asm/arch_timer.h> |
24 | #include <asm/virt.h> | 25 | #include <asm/virt.h> |
@@ -471,6 +472,15 @@ static int __init arch_timer_register(void) | |||
471 | goto out; | 472 | goto out; |
472 | } | 473 | } |
473 | 474 | ||
475 | clocksource_register_hz(&clocksource_counter, arch_timer_rate); | ||
476 | cyclecounter.mult = clocksource_counter.mult; | ||
477 | cyclecounter.shift = clocksource_counter.shift; | ||
478 | timecounter_init(&timecounter, &cyclecounter, | ||
479 | arch_counter_get_cntvct()); | ||
480 | |||
481 | /* 56 bits minimum, so we assume worst case rollover */ | ||
482 | sched_clock_register(arch_timer_read_counter, 56, arch_timer_rate); | ||
483 | |||
474 | if (arch_timer_use_virtual) { | 484 | if (arch_timer_use_virtual) { |
475 | ppi = arch_timer_ppi[VIRT_PPI]; | 485 | ppi = arch_timer_ppi[VIRT_PPI]; |
476 | err = request_percpu_irq(ppi, arch_timer_handler_virt, | 486 | err = request_percpu_irq(ppi, arch_timer_handler_virt, |