aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-08-05 19:40:41 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-09-03 19:36:01 -0400
commitadc78e6b9946a4b22e22403d961f3b03c469e5d3 (patch)
treee0837d6a5778c9bfa0a698f10a7cbedf9cf76cd0
parent77f827de07432a74821cf0f831d699544b2d474f (diff)
timekeeping: Add suspend and resume of clock event devices
Some clock event devices, for example such that belong to PM domains, need to be handled in a spcial way during the timekeeping suspend and resume (which takes place in the system core, or "syscore", stages of system power transitions) in analogy with clock sources. Introduce .suspend() and .resume() callbacks for clock event devices that will be executed by timekeeping_suspend/_resume(), respectively, next the the clock sources' .suspend() and .resume() callbacks. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
-rw-r--r--include/linux/clockchips.h8
-rw-r--r--kernel/time/clockevents.c24
-rw-r--r--kernel/time/timekeeping.c2
3 files changed, 34 insertions, 0 deletions
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index acba894374a1..8a7096fcb01e 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -97,6 +97,8 @@ struct clock_event_device {
97 void (*broadcast)(const struct cpumask *mask); 97 void (*broadcast)(const struct cpumask *mask);
98 void (*set_mode)(enum clock_event_mode mode, 98 void (*set_mode)(enum clock_event_mode mode,
99 struct clock_event_device *); 99 struct clock_event_device *);
100 void (*suspend)(struct clock_event_device *);
101 void (*resume)(struct clock_event_device *);
100 unsigned long min_delta_ticks; 102 unsigned long min_delta_ticks;
101 unsigned long max_delta_ticks; 103 unsigned long max_delta_ticks;
102 104
@@ -156,6 +158,9 @@ clockevents_calc_mult_shift(struct clock_event_device *ce, u32 freq, u32 minsec)
156 freq, minsec); 158 freq, minsec);
157} 159}
158 160
161extern void clockevents_suspend(void);
162extern void clockevents_resume(void);
163
159#ifdef CONFIG_GENERIC_CLOCKEVENTS 164#ifdef CONFIG_GENERIC_CLOCKEVENTS
160extern void clockevents_notify(unsigned long reason, void *arg); 165extern void clockevents_notify(unsigned long reason, void *arg);
161#else 166#else
@@ -164,6 +169,9 @@ extern void clockevents_notify(unsigned long reason, void *arg);
164 169
165#else /* CONFIG_GENERIC_CLOCKEVENTS_BUILD */ 170#else /* CONFIG_GENERIC_CLOCKEVENTS_BUILD */
166 171
172static inline void clockevents_suspend(void) {}
173static inline void clockevents_resume(void) {}
174
167#define clockevents_notify(reason, arg) do { } while (0) 175#define clockevents_notify(reason, arg) do { } while (0)
168 176
169#endif 177#endif
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 7e1ce012a851..30b6de0d977c 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -397,6 +397,30 @@ void clockevents_exchange_device(struct clock_event_device *old,
397 local_irq_restore(flags); 397 local_irq_restore(flags);
398} 398}
399 399
400/**
401 * clockevents_suspend - suspend clock devices
402 */
403void clockevents_suspend(void)
404{
405 struct clock_event_device *dev;
406
407 list_for_each_entry_reverse(dev, &clockevent_devices, list)
408 if (dev->suspend)
409 dev->suspend(dev);
410}
411
412/**
413 * clockevents_resume - resume clock devices
414 */
415void clockevents_resume(void)
416{
417 struct clock_event_device *dev;
418
419 list_for_each_entry(dev, &clockevent_devices, list)
420 if (dev->resume)
421 dev->resume(dev);
422}
423
400#ifdef CONFIG_GENERIC_CLOCKEVENTS 424#ifdef CONFIG_GENERIC_CLOCKEVENTS
401/** 425/**
402 * clockevents_notify - notification about relevant events 426 * clockevents_notify - notification about relevant events
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 34e5eac81424..312a675cb240 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -773,6 +773,7 @@ static void timekeeping_resume(void)
773 773
774 read_persistent_clock(&ts); 774 read_persistent_clock(&ts);
775 775
776 clockevents_resume();
776 clocksource_resume(); 777 clocksource_resume();
777 778
778 write_seqlock_irqsave(&tk->lock, flags); 779 write_seqlock_irqsave(&tk->lock, flags);
@@ -832,6 +833,7 @@ static int timekeeping_suspend(void)
832 833
833 clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); 834 clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL);
834 clocksource_suspend(); 835 clocksource_suspend();
836 clockevents_suspend();
835 837
836 return 0; 838 return 0;
837} 839}