Commit | Line | Data |
---|---|---|
f8381cba TG |
1 | /* |
2 | * tick internal variable and functions used by low/high res code | |
3 | */ | |
e2830b5c TH |
4 | #include <linux/hrtimer.h> |
5 | #include <linux/tick.h> | |
6441402b TG |
6 | |
7 | #define TICK_DO_TIMER_NONE -1 | |
8 | #define TICK_DO_TIMER_BOOT -2 | |
9 | ||
f8381cba | 10 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); |
f8381cba TG |
11 | extern ktime_t tick_next_period; |
12 | extern ktime_t tick_period; | |
d3ed7824 | 13 | extern int tick_do_timer_cpu __read_mostly; |
f8381cba TG |
14 | |
15 | extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); | |
16 | extern void tick_handle_periodic(struct clock_event_device *dev); | |
17 | ||
2344abbc TG |
18 | extern void clockevents_shutdown(struct clock_event_device *dev); |
19 | ||
79bf2bb3 TG |
20 | /* |
21 | * NO_HZ / high resolution timer shared code | |
22 | */ | |
23 | #ifdef CONFIG_TICK_ONESHOT | |
24 | extern void tick_setup_oneshot(struct clock_event_device *newdev, | |
25 | void (*handler)(struct clock_event_device *), | |
26 | ktime_t nextevt); | |
1fb9b7d2 TG |
27 | extern int tick_dev_program_event(struct clock_event_device *dev, |
28 | ktime_t expires, int force); | |
79bf2bb3 TG |
29 | extern int tick_program_event(ktime_t expires, int force); |
30 | extern void tick_oneshot_notify(void); | |
31 | extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); | |
cd05a1f8 | 32 | extern void tick_resume_oneshot(void); |
79bf2bb3 TG |
33 | # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
34 | extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc); | |
35 | extern void tick_broadcast_oneshot_control(unsigned long reason); | |
36 | extern void tick_broadcast_switch_to_oneshot(void); | |
37 | extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); | |
cd05a1f8 | 38 | extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); |
27ce4cb4 | 39 | extern int tick_broadcast_oneshot_active(void); |
fb02fbc1 | 40 | extern void tick_check_oneshot_broadcast(int cpu); |
79bf2bb3 TG |
41 | # else /* BROADCAST */ |
42 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) | |
43 | { | |
44 | BUG(); | |
45 | } | |
46 | static inline void tick_broadcast_oneshot_control(unsigned long reason) { } | |
47 | static inline void tick_broadcast_switch_to_oneshot(void) { } | |
48 | static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } | |
27ce4cb4 | 49 | static inline int tick_broadcast_oneshot_active(void) { return 0; } |
fb02fbc1 | 50 | static inline void tick_check_oneshot_broadcast(int cpu) { } |
79bf2bb3 TG |
51 | # endif /* !BROADCAST */ |
52 | ||
53 | #else /* !ONESHOT */ | |
54 | static inline | |
55 | void tick_setup_oneshot(struct clock_event_device *newdev, | |
56 | void (*handler)(struct clock_event_device *), | |
57 | ktime_t nextevt) | |
58 | { | |
59 | BUG(); | |
60 | } | |
cd05a1f8 TG |
61 | static inline void tick_resume_oneshot(void) |
62 | { | |
63 | BUG(); | |
64 | } | |
79bf2bb3 TG |
65 | static inline int tick_program_event(ktime_t expires, int force) |
66 | { | |
67 | return 0; | |
68 | } | |
69 | static inline void tick_oneshot_notify(void) { } | |
70 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) | |
71 | { | |
72 | BUG(); | |
73 | } | |
74 | static inline void tick_broadcast_oneshot_control(unsigned long reason) { } | |
75 | static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } | |
cd05a1f8 TG |
76 | static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc) |
77 | { | |
78 | return 0; | |
79 | } | |
f8e256c6 | 80 | static inline int tick_broadcast_oneshot_active(void) { return 0; } |
79bf2bb3 TG |
81 | #endif /* !TICK_ONESHOT */ |
82 | ||
f8381cba TG |
83 | /* |
84 | * Broadcasting support | |
85 | */ | |
86 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST | |
f8381cba TG |
87 | extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); |
88 | extern int tick_check_broadcast_device(struct clock_event_device *dev); | |
89 | extern int tick_is_broadcast_device(struct clock_event_device *dev); | |
90 | extern void tick_broadcast_on_off(unsigned long reason, int *oncpu); | |
91 | extern void tick_shutdown_broadcast(unsigned int *cpup); | |
6321dd60 TG |
92 | extern void tick_suspend_broadcast(void); |
93 | extern int tick_resume_broadcast(void); | |
f8381cba TG |
94 | |
95 | extern void | |
96 | tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); | |
97 | ||
98 | #else /* !BROADCAST */ | |
99 | ||
100 | static inline int tick_check_broadcast_device(struct clock_event_device *dev) | |
101 | { | |
102 | return 0; | |
103 | } | |
104 | ||
105 | static inline int tick_is_broadcast_device(struct clock_event_device *dev) | |
106 | { | |
107 | return 0; | |
108 | } | |
109 | static inline int tick_device_uses_broadcast(struct clock_event_device *dev, | |
110 | int cpu) | |
111 | { | |
112 | return 0; | |
113 | } | |
114 | static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } | |
115 | static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } | |
116 | static inline void tick_shutdown_broadcast(unsigned int *cpup) { } | |
6321dd60 TG |
117 | static inline void tick_suspend_broadcast(void) { } |
118 | static inline int tick_resume_broadcast(void) { return 0; } | |
f8381cba TG |
119 | |
120 | /* | |
121 | * Set the periodic handler in non broadcast mode | |
122 | */ | |
123 | static inline void tick_set_periodic_handler(struct clock_event_device *dev, | |
124 | int broadcast) | |
125 | { | |
126 | dev->event_handler = tick_handle_periodic; | |
127 | } | |
128 | #endif /* !BROADCAST */ | |
129 | ||
130 | /* | |
131 | * Check, if the device is functional or a dummy for broadcast | |
132 | */ | |
133 | static inline int tick_device_is_functional(struct clock_event_device *dev) | |
134 | { | |
135 | return !(dev->features & CLOCK_EVT_FEAT_DUMMY); | |
136 | } | |
e2830b5c TH |
137 | |
138 | extern void do_timer(unsigned long ticks); | |
139 | extern seqlock_t xtime_lock; |