blob: 06bfc8802dfbd91973d337650fb620d8503a5ff7 [file] [log] [blame]
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08001/*
2 * tick internal variable and functions used by low/high res code
3 */
Torben Hohne2830b52011-01-27 16:00:32 +01004#include <linux/hrtimer.h>
5#include <linux/tick.h>
Thomas Gleixner64414022008-09-22 18:46:37 +02006
Thomas Gleixnereb93e4d2013-02-21 22:51:36 +00007extern seqlock_t jiffies_lock;
8
Thomas Gleixner7cf37e82011-02-01 09:34:58 +01009#ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD
Thomas Gleixner64414022008-09-22 18:46:37 +020010
11#define TICK_DO_TIMER_NONE -1
12#define TICK_DO_TIMER_BOOT -2
13
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080014DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080015extern ktime_t tick_next_period;
16extern ktime_t tick_period;
Thomas Gleixnerd3ed7822007-05-08 00:30:03 -070017extern int tick_do_timer_cpu __read_mostly;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080018
19extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
20extern void tick_handle_periodic(struct clock_event_device *dev);
Thomas Gleixner7172a2862013-04-25 20:31:47 +000021extern void tick_check_new_device(struct clock_event_device *dev);
Thomas Gleixner8c53daf2013-04-25 20:31:48 +000022extern void tick_handover_do_timer(int *cpup);
23extern void tick_shutdown(unsigned int *cpup);
24extern void tick_suspend(void);
25extern void tick_resume(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080026
Thomas Gleixner2344abb2008-09-16 11:32:50 -070027extern void clockevents_shutdown(struct clock_event_device *dev);
28
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080029/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080030 * NO_HZ / high resolution timer shared code
31 */
32#ifdef CONFIG_TICK_ONESHOT
33extern void tick_setup_oneshot(struct clock_event_device *newdev,
34 void (*handler)(struct clock_event_device *),
35 ktime_t nextevt);
36extern int tick_program_event(ktime_t expires, int force);
37extern void tick_oneshot_notify(void);
38extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010039extern void tick_resume_oneshot(void);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080040# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
41extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
42extern void tick_broadcast_oneshot_control(unsigned long reason);
43extern void tick_broadcast_switch_to_oneshot(void);
44extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010045extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020046extern int tick_broadcast_oneshot_active(void);
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020047extern void tick_check_oneshot_broadcast(int cpu);
Thomas Gleixner3a142a02011-02-25 22:34:23 +010048bool tick_broadcast_oneshot_available(void);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080049# else /* BROADCAST */
50static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
51{
52 BUG();
53}
54static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
55static inline void tick_broadcast_switch_to_oneshot(void) { }
56static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020057static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020058static inline void tick_check_oneshot_broadcast(int cpu) { }
Thomas Gleixner3a142a02011-02-25 22:34:23 +010059static inline bool tick_broadcast_oneshot_available(void) { return true; }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080060# endif /* !BROADCAST */
61
62#else /* !ONESHOT */
63static inline
64void tick_setup_oneshot(struct clock_event_device *newdev,
65 void (*handler)(struct clock_event_device *),
66 ktime_t nextevt)
67{
68 BUG();
69}
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010070static inline void tick_resume_oneshot(void)
71{
72 BUG();
73}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080074static inline int tick_program_event(ktime_t expires, int force)
75{
76 return 0;
77}
78static inline void tick_oneshot_notify(void) { }
79static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
80{
81 BUG();
82}
83static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
84static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010085static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
86{
87 return 0;
88}
Ingo Molnarf8e256c2008-09-23 13:00:57 +020089static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixner3a142a02011-02-25 22:34:23 +010090static inline bool tick_broadcast_oneshot_available(void) { return false; }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080091#endif /* !TICK_ONESHOT */
92
93/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080094 * Broadcasting support
95 */
96#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080097extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
Thomas Gleixner7172a2862013-04-25 20:31:47 +000098extern void tick_install_broadcast_device(struct clock_event_device *dev);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080099extern int tick_is_broadcast_device(struct clock_event_device *dev);
100extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
101extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100102extern void tick_suspend_broadcast(void);
103extern int tick_resume_broadcast(void);
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100104extern void tick_broadcast_init(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800105extern void
106tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
107
108#else /* !BROADCAST */
109
Thomas Gleixner7172a2862013-04-25 20:31:47 +0000110static inline void tick_install_broadcast_device(struct clock_event_device *dev)
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800111{
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800112}
113
114static inline int tick_is_broadcast_device(struct clock_event_device *dev)
115{
116 return 0;
117}
118static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
119 int cpu)
120{
121 return 0;
122}
123static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
124static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
125static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100126static inline void tick_suspend_broadcast(void) { }
127static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100128static inline void tick_broadcast_init(void) { }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800129
130/*
131 * Set the periodic handler in non broadcast mode
132 */
133static inline void tick_set_periodic_handler(struct clock_event_device *dev,
134 int broadcast)
135{
136 dev->event_handler = tick_handle_periodic;
137}
138#endif /* !BROADCAST */
139
140/*
141 * Check, if the device is functional or a dummy for broadcast
142 */
143static inline int tick_device_is_functional(struct clock_event_device *dev)
144{
145 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
146}
Torben Hohne2830b52011-01-27 16:00:32 +0100147
Thomas Gleixner7cf37e82011-02-01 09:34:58 +0100148#endif
149
Torben Hohne2830b52011-01-27 16:00:32 +0100150extern void do_timer(unsigned long ticks);