Skip to content

Commit

Permalink
timekeeping: Add suspend and resume of clock event devices
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafael J. Wysocki committed Sep 3, 2012
1 parent 77f827d commit adc78e6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/linux/clockchips.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ struct clock_event_device {
void (*broadcast)(const struct cpumask *mask);
void (*set_mode)(enum clock_event_mode mode,
struct clock_event_device *);
void (*suspend)(struct clock_event_device *);
void (*resume)(struct clock_event_device *);
unsigned long min_delta_ticks;
unsigned long max_delta_ticks;

Expand Down Expand Up @@ -156,6 +158,9 @@ clockevents_calc_mult_shift(struct clock_event_device *ce, u32 freq, u32 minsec)
freq, minsec);
}

extern void clockevents_suspend(void);
extern void clockevents_resume(void);

#ifdef CONFIG_GENERIC_CLOCKEVENTS
extern void clockevents_notify(unsigned long reason, void *arg);
#else
Expand All @@ -164,6 +169,9 @@ extern void clockevents_notify(unsigned long reason, void *arg);

#else /* CONFIG_GENERIC_CLOCKEVENTS_BUILD */

static inline void clockevents_suspend(void) {}
static inline void clockevents_resume(void) {}

#define clockevents_notify(reason, arg) do { } while (0)

#endif
Expand Down
24 changes: 24 additions & 0 deletions kernel/time/clockevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,30 @@ void clockevents_exchange_device(struct clock_event_device *old,
local_irq_restore(flags);
}

/**
* clockevents_suspend - suspend clock devices
*/
void clockevents_suspend(void)
{
struct clock_event_device *dev;

list_for_each_entry_reverse(dev, &clockevent_devices, list)
if (dev->suspend)
dev->suspend(dev);
}

/**
* clockevents_resume - resume clock devices
*/
void clockevents_resume(void)
{
struct clock_event_device *dev;

list_for_each_entry(dev, &clockevent_devices, list)
if (dev->resume)
dev->resume(dev);
}

#ifdef CONFIG_GENERIC_CLOCKEVENTS
/**
* clockevents_notify - notification about relevant events
Expand Down
2 changes: 2 additions & 0 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ static void timekeeping_resume(void)

read_persistent_clock(&ts);

clockevents_resume();
clocksource_resume();

write_seqlock_irqsave(&tk->lock, flags);
Expand Down Expand Up @@ -832,6 +833,7 @@ static int timekeeping_suspend(void)

clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL);
clocksource_suspend();
clockevents_suspend();

return 0;
}
Expand Down

0 comments on commit adc78e6

Please sign in to comment.