hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/hrtimer.h
....@@ -1,6 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
2
- * include/linux/hrtimer.h
3
- *
43 * hrtimers - High-resolution kernel timers
54 *
65 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
....@@ -9,8 +8,6 @@
98 * data type definitions, declarations, prototypes
109 *
1110 * Started by: Thomas Gleixner and Ingo Molnar
12
- *
13
- * For licencing details see kernel-base/COPYING
1411 */
1512 #ifndef _LINUX_HRTIMER_H
1613 #define _LINUX_HRTIMER_H
....@@ -20,6 +17,7 @@
2017 #include <linux/init.h>
2118 #include <linux/list.h>
2219 #include <linux/percpu.h>
20
+#include <linux/seqlock.h>
2321 #include <linux/timer.h>
2422 #include <linux/timerqueue.h>
2523 #include <linux/android_kabi.h>
....@@ -36,6 +34,8 @@
3634 * when starting the timer)
3735 * HRTIMER_MODE_SOFT - Timer callback function will be executed in
3836 * soft irq context
37
+ * HRTIMER_MODE_HARD - Timer callback function will be executed in
38
+ * hard irq context even on PREEMPT_RT.
3939 */
4040 enum hrtimer_mode {
4141 HRTIMER_MODE_ABS = 0x00,
....@@ -111,6 +111,8 @@
111111 * @state: state information (See bit values above)
112112 * @is_rel: Set if the timer was armed relative
113113 * @is_soft: Set if hrtimer will be expired in soft interrupt context.
114
+ * @is_hard: Set if hrtimer will be expired in hard interrupt context
115
+ * even on RT.
114116 *
115117 * The hrtimer structure must be initialized by hrtimer_init()
116118 */
....@@ -122,6 +124,7 @@
122124 u8 state;
123125 u8 is_rel;
124126 u8 is_soft;
127
+ u8 is_hard;
125128
126129 ANDROID_KABI_RESERVE(1);
127130 };
....@@ -160,7 +163,7 @@
160163 struct hrtimer_cpu_base *cpu_base;
161164 unsigned int index;
162165 clockid_t clockid;
163
- seqcount_t seq;
166
+ seqcount_raw_spinlock_t seq;
164167 struct hrtimer *running;
165168 struct timerqueue_head active;
166169 ktime_t (*get_time)(void);
....@@ -197,6 +200,8 @@
197200 * @max_hang_time: Maximum time spent in hrtimer_interrupt
198201 * @softirq_expiry_lock: Lock which is taken while softirq based hrtimer are
199202 * expired
203
+ * @timer_waiters: A hrtimer_cancel() invocation waits for the timer
204
+ * callback to finish.
200205 * @expires_next: absolute time of the next event, is required for remote
201206 * hrtimer enqueue; it is the total first expiry time (hard
202207 * and soft hrtimer are taken into account)
....@@ -224,7 +229,10 @@
224229 unsigned short nr_hangs;
225230 unsigned int max_hang_time;
226231 #endif
232
+#ifdef CONFIG_PREEMPT_RT
227233 spinlock_t softirq_expiry_lock;
234
+ atomic_t timer_waiters;
235
+#endif
228236 ktime_t expires_next;
229237 struct hrtimer *next_timer;
230238 ktime_t softirq_expires_next;
....@@ -313,15 +321,11 @@
313321
314322 extern void hrtimer_interrupt(struct clock_event_device *dev);
315323
316
-extern void clock_was_set_delayed(void);
317
-
318324 extern unsigned int hrtimer_resolution;
319325
320326 #else
321327
322328 #define hrtimer_resolution (unsigned int)LOW_RES_NSEC
323
-
324
-static inline void clock_was_set_delayed(void) { }
325329
326330 #endif
327331
....@@ -346,7 +350,6 @@
346350 timer->base->get_time());
347351 }
348352
349
-extern void clock_was_set(void);
350353 #ifdef CONFIG_TIMERFD
351354 extern void timerfd_clock_was_set(void);
352355 #else
....@@ -356,6 +359,14 @@
356359
357360 DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
358361
362
+#ifdef CONFIG_PREEMPT_RT
363
+void hrtimer_cancel_wait_running(const struct hrtimer *timer);
364
+#else
365
+static inline void hrtimer_cancel_wait_running(struct hrtimer *timer)
366
+{
367
+ cpu_relax();
368
+}
369
+#endif
359370
360371 /* Exported timer functions: */
361372
....@@ -363,16 +374,14 @@
363374 extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
364375 enum hrtimer_mode mode);
365376 extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id,
366
- enum hrtimer_mode mode,
367
- struct task_struct *task);
377
+ enum hrtimer_mode mode);
368378
369379 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
370380 extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
371381 enum hrtimer_mode mode);
372382 extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
373383 clockid_t clock_id,
374
- enum hrtimer_mode mode,
375
- struct task_struct *task);
384
+ enum hrtimer_mode mode);
376385
377386 extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
378387 #else
....@@ -384,11 +393,10 @@
384393 }
385394
386395 static inline void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
387
- clockid_t clock_id,
388
- enum hrtimer_mode mode,
389
- struct task_struct *task)
396
+ clockid_t clock_id,
397
+ enum hrtimer_mode mode)
390398 {
391
- hrtimer_init_sleeper(sl, clock_id, mode, task);
399
+ hrtimer_init_sleeper(sl, clock_id, mode);
392400 }
393401
394402 static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
....@@ -414,7 +422,6 @@
414422
415423 extern int hrtimer_cancel(struct hrtimer *timer);
416424 extern int hrtimer_try_to_cancel(struct hrtimer *timer);
417
-extern void hrtimer_grab_expiry_lock(const struct hrtimer *timer);
418425
419426 static inline void hrtimer_start_expires(struct hrtimer *timer,
420427 enum hrtimer_mode mode)
....@@ -426,6 +433,9 @@
426433 delta = ktime_to_ns(ktime_sub(hard, soft));
427434 hrtimer_start_range_ns(timer, soft, delta, mode);
428435 }
436
+
437
+void hrtimer_sleeper_start_expires(struct hrtimer_sleeper *sl,
438
+ enum hrtimer_mode mode);
429439
430440 static inline void hrtimer_restart(struct hrtimer *timer)
431441 {
....@@ -497,12 +507,11 @@
497507 /* Precise sleep: */
498508
499509 extern int nanosleep_copyout(struct restart_block *, struct timespec64 *);
500
-extern long hrtimer_nanosleep(const struct timespec64 *rqtp,
501
- const enum hrtimer_mode mode,
510
+extern long hrtimer_nanosleep(ktime_t rqtp, const enum hrtimer_mode mode,
502511 const clockid_t clockid);
503512
504513 extern int schedule_hrtimeout_range(ktime_t *expires, u64 delta,
505
- const enum hrtimer_mode mode);
514
+ const enum hrtimer_mode mode);
506515 extern int schedule_hrtimeout_range_clock(ktime_t *expires,
507516 u64 delta,
508517 const enum hrtimer_mode mode,