diff options
| -rw-r--r-- | arch/arm/include/asm/sched_clock.h | 2 | ||||
| -rw-r--r-- | arch/arm/kernel/sched_clock.c | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/arch/arm/include/asm/sched_clock.h b/arch/arm/include/asm/sched_clock.h index e3f757263438..05b8e82ec9f5 100644 --- a/arch/arm/include/asm/sched_clock.h +++ b/arch/arm/include/asm/sched_clock.h | |||
| @@ -10,5 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | extern void sched_clock_postinit(void); | 11 | extern void sched_clock_postinit(void); |
| 12 | extern void setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate); | 12 | extern void setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate); |
| 13 | extern void setup_sched_clock_needs_suspend(u32 (*read)(void), int bits, | ||
| 14 | unsigned long rate); | ||
| 13 | 15 | ||
| 14 | #endif | 16 | #endif |
diff --git a/arch/arm/kernel/sched_clock.c b/arch/arm/kernel/sched_clock.c index 27d186abbc06..f4515393248d 100644 --- a/arch/arm/kernel/sched_clock.c +++ b/arch/arm/kernel/sched_clock.c | |||
| @@ -21,6 +21,8 @@ struct clock_data { | |||
| 21 | u32 epoch_cyc_copy; | 21 | u32 epoch_cyc_copy; |
| 22 | u32 mult; | 22 | u32 mult; |
| 23 | u32 shift; | 23 | u32 shift; |
| 24 | bool suspended; | ||
| 25 | bool needs_suspend; | ||
| 24 | }; | 26 | }; |
| 25 | 27 | ||
| 26 | static void sched_clock_poll(unsigned long wrap_ticks); | 28 | static void sched_clock_poll(unsigned long wrap_ticks); |
| @@ -49,6 +51,9 @@ static unsigned long long cyc_to_sched_clock(u32 cyc, u32 mask) | |||
| 49 | u64 epoch_ns; | 51 | u64 epoch_ns; |
| 50 | u32 epoch_cyc; | 52 | u32 epoch_cyc; |
| 51 | 53 | ||
| 54 | if (cd.suspended) | ||
| 55 | return cd.epoch_ns; | ||
| 56 | |||
| 52 | /* | 57 | /* |
| 53 | * Load the epoch_cyc and epoch_ns atomically. We do this by | 58 | * Load the epoch_cyc and epoch_ns atomically. We do this by |
| 54 | * ensuring that we always write epoch_cyc, epoch_ns and | 59 | * ensuring that we always write epoch_cyc, epoch_ns and |
| @@ -98,6 +103,13 @@ static void sched_clock_poll(unsigned long wrap_ticks) | |||
| 98 | update_sched_clock(); | 103 | update_sched_clock(); |
| 99 | } | 104 | } |
| 100 | 105 | ||
| 106 | void __init setup_sched_clock_needs_suspend(u32 (*read)(void), int bits, | ||
| 107 | unsigned long rate) | ||
| 108 | { | ||
| 109 | setup_sched_clock(read, bits, rate); | ||
| 110 | cd.needs_suspend = true; | ||
| 111 | } | ||
| 112 | |||
| 101 | void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate) | 113 | void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate) |
| 102 | { | 114 | { |
| 103 | unsigned long r, w; | 115 | unsigned long r, w; |
| @@ -169,11 +181,23 @@ void __init sched_clock_postinit(void) | |||
| 169 | static int sched_clock_suspend(void) | 181 | static int sched_clock_suspend(void) |
| 170 | { | 182 | { |
| 171 | sched_clock_poll(sched_clock_timer.data); | 183 | sched_clock_poll(sched_clock_timer.data); |
| 184 | if (cd.needs_suspend) | ||
| 185 | cd.suspended = true; | ||
| 172 | return 0; | 186 | return 0; |
| 173 | } | 187 | } |
| 174 | 188 | ||
| 189 | static void sched_clock_resume(void) | ||
| 190 | { | ||
| 191 | if (cd.needs_suspend) { | ||
| 192 | cd.epoch_cyc = read_sched_clock(); | ||
| 193 | cd.epoch_cyc_copy = cd.epoch_cyc; | ||
| 194 | cd.suspended = false; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 175 | static struct syscore_ops sched_clock_ops = { | 198 | static struct syscore_ops sched_clock_ops = { |
| 176 | .suspend = sched_clock_suspend, | 199 | .suspend = sched_clock_suspend, |
| 200 | .resume = sched_clock_resume, | ||
| 177 | }; | 201 | }; |
| 178 | 202 | ||
| 179 | static int __init sched_clock_syscore_init(void) | 203 | static int __init sched_clock_syscore_init(void) |
