[PATCH] hrtimers: cleanup locking
[sfrench/cifs-2.6.git] / include / linux / hrtimer.h
index e4bccbcc2750a3f19711996f764fce80b6d7962a..e00fc4d3d74f2490301ef37fb0a233c72b140d9a 100644 (file)
 #include <linux/list.h>
 #include <linux/wait.h>
 
+struct hrtimer_clock_base;
+struct hrtimer_cpu_base;
+
 /*
  * Mode arguments of xxx_hrtimer functions:
  */
 enum hrtimer_mode {
-       HRTIMER_ABS,    /* Time value is absolute */
-       HRTIMER_REL,    /* Time value is relative to now */
+       HRTIMER_MODE_ABS,       /* Time value is absolute */
+       HRTIMER_MODE_REL,       /* Time value is relative to now */
 };
 
+/*
+ * Return values for the callback function
+ */
 enum hrtimer_restart {
-       HRTIMER_NORESTART,
-       HRTIMER_RESTART,
+       HRTIMER_NORESTART,      /* Timer is not restarted */
+       HRTIMER_RESTART,        /* Timer must be restarted */
 };
 
-#define HRTIMER_INACTIVE       ((void *)1UL)
-
-struct hrtimer_base;
-
 /**
  * struct hrtimer - the basic hrtimer structure
  * @node:      red black tree node for time ordered insertion
@@ -50,10 +52,10 @@ struct hrtimer_base;
  * The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE()
  */
 struct hrtimer {
-       struct rb_node          node;
-       ktime_t                 expires;
-       int                     (*function)(struct hrtimer *);
-       struct hrtimer_base     *base;
+       struct rb_node                  node;
+       ktime_t                         expires;
+       enum hrtimer_restart            (*function)(struct hrtimer *);
+       struct hrtimer_clock_base       *base;
 };
 
 /**
@@ -70,28 +72,41 @@ struct hrtimer_sleeper {
 
 /**
  * struct hrtimer_base - the timer base for a specific clock
- * @index:             clock type index for per_cpu support when moving a timer
- *                     to a base on another cpu.
- * @lock:              lock protecting the base and associated timers
+ * @index:             clock type index for per_cpu support when moving a
+ *                     timer to a base on another cpu.
  * @active:            red black tree root node for the active timers
  * @first:             pointer to the timer node which expires first
  * @resolution:                the resolution of the clock, in nanoseconds
  * @get_time:          function to retrieve the current time of the clock
  * @get_softirq_time:  function to retrieve the current time from the softirq
- * @curr_timer:                the timer which is executing a callback right now
  * @softirq_time:      the time when running the hrtimer queue in the softirq
  */
-struct hrtimer_base {
+struct hrtimer_clock_base {
+       struct hrtimer_cpu_base *cpu_base;
        clockid_t               index;
-       spinlock_t              lock;
        struct rb_root          active;
        struct rb_node          *first;
        ktime_t                 resolution;
        ktime_t                 (*get_time)(void);
        ktime_t                 (*get_softirq_time)(void);
-       struct hrtimer          *curr_timer;
        ktime_t                 softirq_time;
-       struct lock_class_key lock_key;
+};
+
+#define HRTIMER_MAX_CLOCK_BASES 2
+
+/*
+ * struct hrtimer_cpu_base - the per cpu clock bases
+ * @lock:              lock protecting the base and associated clock bases
+ *                     and timers
+ * @lock_key:          the lock_class_key for use with lockdep
+ * @clock_base:                array of clock bases for this cpu
+ * @curr_timer:                the timer which is executing a callback right now
+ */
+struct hrtimer_cpu_base {
+       spinlock_t                      lock;
+       struct lock_class_key           lock_key;
+       struct hrtimer_clock_base       clock_base[HRTIMER_MAX_CLOCK_BASES];
+       struct hrtimer                  *curr_timer;
 };
 
 /*
@@ -113,7 +128,10 @@ extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
 extern int hrtimer_cancel(struct hrtimer *timer);
 extern int hrtimer_try_to_cancel(struct hrtimer *timer);
 
-#define hrtimer_restart(timer) hrtimer_start((timer), (timer)->expires, HRTIMER_ABS)
+static inline int hrtimer_restart(struct hrtimer *timer)
+{
+       return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
+}
 
 /* Query timers: */
 extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer);
@@ -137,6 +155,7 @@ extern long hrtimer_nanosleep(struct timespec *rqtp,
                              struct timespec __user *rmtp,
                              const enum hrtimer_mode mode,
                              const clockid_t clockid);
+extern long hrtimer_nanosleep_restart(struct restart_block *restart_block);
 
 extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
                                 struct task_struct *tsk);
@@ -144,6 +163,9 @@ extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
 /* Soft interrupt function to run the hrtimer queues: */
 extern void hrtimer_run_queues(void);
 
+/* Resume notification */
+void hrtimer_notify_resume(void);
+
 /* Bootup initialization: */
 extern void __init hrtimers_init(void);