diff options
Diffstat (limited to 'include/linux/hrtimer.h')
-rw-r--r-- | include/linux/hrtimer.h | 105 |
1 files changed, 101 insertions, 4 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 9a4e35cd5f79..2b3645b1acf4 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/wait.h> | 22 | #include <linux/wait.h> |
23 | #include <linux/percpu.h> | ||
24 | |||
23 | 25 | ||
24 | struct hrtimer_clock_base; | 26 | struct hrtimer_clock_base; |
25 | struct hrtimer_cpu_base; | 27 | struct hrtimer_cpu_base; |
@@ -101,9 +103,14 @@ enum hrtimer_cb_mode { | |||
101 | /** | 103 | /** |
102 | * struct hrtimer - the basic hrtimer structure | 104 | * struct hrtimer - the basic hrtimer structure |
103 | * @node: red black tree node for time ordered insertion | 105 | * @node: red black tree node for time ordered insertion |
104 | * @expires: the absolute expiry time in the hrtimers internal | 106 | * @_expires: the absolute expiry time in the hrtimers internal |
105 | * representation. The time is related to the clock on | 107 | * representation. The time is related to the clock on |
106 | * which the timer is based. | 108 | * which the timer is based. Is setup by adding |
109 | * slack to the _softexpires value. For non range timers | ||
110 | * identical to _softexpires. | ||
111 | * @_softexpires: the absolute earliest expiry time of the hrtimer. | ||
112 | * The time which was given as expiry time when the timer | ||
113 | * was armed. | ||
107 | * @function: timer expiry callback function | 114 | * @function: timer expiry callback function |
108 | * @base: pointer to the timer base (per cpu and per clock) | 115 | * @base: pointer to the timer base (per cpu and per clock) |
109 | * @state: state information (See bit values above) | 116 | * @state: state information (See bit values above) |
@@ -121,7 +128,8 @@ enum hrtimer_cb_mode { | |||
121 | */ | 128 | */ |
122 | struct hrtimer { | 129 | struct hrtimer { |
123 | struct rb_node node; | 130 | struct rb_node node; |
124 | ktime_t expires; | 131 | ktime_t _expires; |
132 | ktime_t _softexpires; | ||
125 | enum hrtimer_restart (*function)(struct hrtimer *); | 133 | enum hrtimer_restart (*function)(struct hrtimer *); |
126 | struct hrtimer_clock_base *base; | 134 | struct hrtimer_clock_base *base; |
127 | unsigned long state; | 135 | unsigned long state; |
@@ -201,6 +209,71 @@ struct hrtimer_cpu_base { | |||
201 | #endif | 209 | #endif |
202 | }; | 210 | }; |
203 | 211 | ||
212 | static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) | ||
213 | { | ||
214 | timer->_expires = time; | ||
215 | timer->_softexpires = time; | ||
216 | } | ||
217 | |||
218 | static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta) | ||
219 | { | ||
220 | timer->_softexpires = time; | ||
221 | timer->_expires = ktime_add_safe(time, delta); | ||
222 | } | ||
223 | |||
224 | static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, unsigned long delta) | ||
225 | { | ||
226 | timer->_softexpires = time; | ||
227 | timer->_expires = ktime_add_safe(time, ns_to_ktime(delta)); | ||
228 | } | ||
229 | |||
230 | static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64) | ||
231 | { | ||
232 | timer->_expires.tv64 = tv64; | ||
233 | timer->_softexpires.tv64 = tv64; | ||
234 | } | ||
235 | |||
236 | static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time) | ||
237 | { | ||
238 | timer->_expires = ktime_add_safe(timer->_expires, time); | ||
239 | timer->_softexpires = ktime_add_safe(timer->_softexpires, time); | ||
240 | } | ||
241 | |||
242 | static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns) | ||
243 | { | ||
244 | timer->_expires = ktime_add_ns(timer->_expires, ns); | ||
245 | timer->_softexpires = ktime_add_ns(timer->_softexpires, ns); | ||
246 | } | ||
247 | |||
248 | static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer) | ||
249 | { | ||
250 | return timer->_expires; | ||
251 | } | ||
252 | |||
253 | static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer) | ||
254 | { | ||
255 | return timer->_softexpires; | ||
256 | } | ||
257 | |||
258 | static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer) | ||
259 | { | ||
260 | return timer->_expires.tv64; | ||
261 | } | ||
262 | static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer) | ||
263 | { | ||
264 | return timer->_softexpires.tv64; | ||
265 | } | ||
266 | |||
267 | static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer) | ||
268 | { | ||
269 | return ktime_to_ns(timer->_expires); | ||
270 | } | ||
271 | |||
272 | static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) | ||
273 | { | ||
274 | return ktime_sub(timer->_expires, timer->base->get_time()); | ||
275 | } | ||
276 | |||
204 | #ifdef CONFIG_HIGH_RES_TIMERS | 277 | #ifdef CONFIG_HIGH_RES_TIMERS |
205 | struct clock_event_device; | 278 | struct clock_event_device; |
206 | 279 | ||
@@ -221,6 +294,8 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer) | |||
221 | return timer->base->cpu_base->hres_active; | 294 | return timer->base->cpu_base->hres_active; |
222 | } | 295 | } |
223 | 296 | ||
297 | extern void hrtimer_peek_ahead_timers(void); | ||
298 | |||
224 | /* | 299 | /* |
225 | * The resolution of the clocks. The resolution value is returned in | 300 | * The resolution of the clocks. The resolution value is returned in |
226 | * the clock_getres() system call to give application programmers an | 301 | * the clock_getres() system call to give application programmers an |
@@ -243,6 +318,7 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer) | |||
243 | * is expired in the next softirq when the clock was advanced. | 318 | * is expired in the next softirq when the clock was advanced. |
244 | */ | 319 | */ |
245 | static inline void clock_was_set(void) { } | 320 | static inline void clock_was_set(void) { } |
321 | static inline void hrtimer_peek_ahead_timers(void) { } | ||
246 | 322 | ||
247 | static inline void hres_timers_resume(void) { } | 323 | static inline void hres_timers_resume(void) { } |
248 | 324 | ||
@@ -264,6 +340,10 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer) | |||
264 | extern ktime_t ktime_get(void); | 340 | extern ktime_t ktime_get(void); |
265 | extern ktime_t ktime_get_real(void); | 341 | extern ktime_t ktime_get_real(void); |
266 | 342 | ||
343 | |||
344 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); | ||
345 | |||
346 | |||
267 | /* Exported timer functions: */ | 347 | /* Exported timer functions: */ |
268 | 348 | ||
269 | /* Initialize timers: */ | 349 | /* Initialize timers: */ |
@@ -288,12 +368,25 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { } | |||
288 | /* Basic timer operations: */ | 368 | /* Basic timer operations: */ |
289 | extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, | 369 | extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, |
290 | const enum hrtimer_mode mode); | 370 | const enum hrtimer_mode mode); |
371 | extern int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, | ||
372 | unsigned long range_ns, const enum hrtimer_mode mode); | ||
291 | extern int hrtimer_cancel(struct hrtimer *timer); | 373 | extern int hrtimer_cancel(struct hrtimer *timer); |
292 | extern int hrtimer_try_to_cancel(struct hrtimer *timer); | 374 | extern int hrtimer_try_to_cancel(struct hrtimer *timer); |
293 | 375 | ||
376 | static inline int hrtimer_start_expires(struct hrtimer *timer, | ||
377 | enum hrtimer_mode mode) | ||
378 | { | ||
379 | unsigned long delta; | ||
380 | ktime_t soft, hard; | ||
381 | soft = hrtimer_get_softexpires(timer); | ||
382 | hard = hrtimer_get_expires(timer); | ||
383 | delta = ktime_to_ns(ktime_sub(hard, soft)); | ||
384 | return hrtimer_start_range_ns(timer, soft, delta, mode); | ||
385 | } | ||
386 | |||
294 | static inline int hrtimer_restart(struct hrtimer *timer) | 387 | static inline int hrtimer_restart(struct hrtimer *timer) |
295 | { | 388 | { |
296 | return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS); | 389 | return hrtimer_start_expires(timer, HRTIMER_MODE_ABS); |
297 | } | 390 | } |
298 | 391 | ||
299 | /* Query timers: */ | 392 | /* Query timers: */ |
@@ -350,6 +443,10 @@ extern long hrtimer_nanosleep_restart(struct restart_block *restart_block); | |||
350 | extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, | 443 | extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, |
351 | struct task_struct *tsk); | 444 | struct task_struct *tsk); |
352 | 445 | ||
446 | extern int schedule_hrtimeout_range(ktime_t *expires, unsigned long delta, | ||
447 | const enum hrtimer_mode mode); | ||
448 | extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode); | ||
449 | |||
353 | /* Soft interrupt function to run the hrtimer queues: */ | 450 | /* Soft interrupt function to run the hrtimer queues: */ |
354 | extern void hrtimer_run_queues(void); | 451 | extern void hrtimer_run_queues(void); |
355 | extern void hrtimer_run_pending(void); | 452 | extern void hrtimer_run_pending(void); |