2 * tick internal variable and functions used by low/high res code
4 #include <linux/hrtimer.h>
5 #include <linux/tick.h>
7 #include "timekeeping.h"
9 extern seqlock_t jiffies_lock
;
11 #define CS_NAME_LEN 32
13 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD
15 #define TICK_DO_TIMER_NONE -1
16 #define TICK_DO_TIMER_BOOT -2
18 DECLARE_PER_CPU(struct tick_device
, tick_cpu_device
);
19 extern ktime_t tick_next_period
;
20 extern ktime_t tick_period
;
21 extern int tick_do_timer_cpu __read_mostly
;
23 extern void tick_setup_periodic(struct clock_event_device
*dev
, int broadcast
);
24 extern void tick_handle_periodic(struct clock_event_device
*dev
);
25 extern void tick_check_new_device(struct clock_event_device
*dev
);
26 extern void tick_handover_do_timer(int *cpup
);
27 extern void tick_shutdown(unsigned int *cpup
);
28 extern void tick_suspend(void);
29 extern void tick_resume(void);
30 extern bool tick_check_replacement(struct clock_event_device
*curdev
,
31 struct clock_event_device
*newdev
);
32 extern void tick_install_replacement(struct clock_event_device
*dev
);
34 extern void clockevents_shutdown(struct clock_event_device
*dev
);
35 extern int clockevents_tick_resume(struct clock_event_device
*dev
);
37 extern ssize_t
sysfs_get_uname(const char *buf
, char *dst
, size_t cnt
);
40 * NO_HZ / high resolution timer shared code
42 #ifdef CONFIG_TICK_ONESHOT
43 extern void tick_setup_oneshot(struct clock_event_device
*newdev
,
44 void (*handler
)(struct clock_event_device
*),
46 extern int tick_program_event(ktime_t expires
, int force
);
47 extern void tick_oneshot_notify(void);
48 extern int tick_switch_to_oneshot(void (*handler
)(struct clock_event_device
*));
49 extern void tick_resume_oneshot(void);
50 # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
51 extern void tick_broadcast_setup_oneshot(struct clock_event_device
*bc
);
52 extern int tick_broadcast_oneshot_control(unsigned long reason
);
53 extern void tick_broadcast_switch_to_oneshot(void);
54 extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup
);
55 extern int tick_resume_broadcast_oneshot(struct clock_event_device
*bc
);
56 extern int tick_broadcast_oneshot_active(void);
57 extern void tick_check_oneshot_broadcast_this_cpu(void);
58 bool tick_broadcast_oneshot_available(void);
59 # else /* BROADCAST */
60 static inline void tick_broadcast_setup_oneshot(struct clock_event_device
*bc
)
64 static inline int tick_broadcast_oneshot_control(unsigned long reason
) { return 0; }
65 static inline void tick_broadcast_switch_to_oneshot(void) { }
66 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup
) { }
67 static inline int tick_broadcast_oneshot_active(void) { return 0; }
68 static inline void tick_check_oneshot_broadcast_this_cpu(void) { }
69 static inline bool tick_broadcast_oneshot_available(void) { return true; }
70 # endif /* !BROADCAST */
74 void tick_setup_oneshot(struct clock_event_device
*newdev
,
75 void (*handler
)(struct clock_event_device
*),
80 static inline void tick_resume_oneshot(void)
84 static inline int tick_program_event(ktime_t expires
, int force
)
88 static inline void tick_oneshot_notify(void) { }
89 static inline void tick_broadcast_setup_oneshot(struct clock_event_device
*bc
)
93 static inline int tick_broadcast_oneshot_control(unsigned long reason
) { return 0; }
94 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup
) { }
95 static inline int tick_resume_broadcast_oneshot(struct clock_event_device
*bc
)
99 static inline int tick_broadcast_oneshot_active(void) { return 0; }
100 static inline bool tick_broadcast_oneshot_available(void) { return false; }
101 #endif /* !TICK_ONESHOT */
103 /* NO_HZ_FULL internal */
104 #ifdef CONFIG_NO_HZ_FULL
105 extern void tick_nohz_init(void);
107 static inline void tick_nohz_init(void) { }
111 * Broadcasting support
113 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
114 extern int tick_device_uses_broadcast(struct clock_event_device
*dev
, int cpu
);
115 extern void tick_install_broadcast_device(struct clock_event_device
*dev
);
116 extern int tick_is_broadcast_device(struct clock_event_device
*dev
);
117 extern void tick_broadcast_on_off(unsigned long reason
, int *oncpu
);
118 extern void tick_shutdown_broadcast(unsigned int *cpup
);
119 extern void tick_suspend_broadcast(void);
120 extern int tick_resume_broadcast(void);
121 extern void tick_broadcast_init(void);
123 tick_set_periodic_handler(struct clock_event_device
*dev
, int broadcast
);
124 int tick_broadcast_update_freq(struct clock_event_device
*dev
, u32 freq
);
126 #else /* !BROADCAST */
128 static inline void tick_install_broadcast_device(struct clock_event_device
*dev
)
132 static inline int tick_is_broadcast_device(struct clock_event_device
*dev
)
136 static inline int tick_device_uses_broadcast(struct clock_event_device
*dev
,
141 static inline void tick_do_periodic_broadcast(struct clock_event_device
*d
) { }
142 static inline void tick_broadcast_on_off(unsigned long reason
, int *oncpu
) { }
143 static inline void tick_shutdown_broadcast(unsigned int *cpup
) { }
144 static inline void tick_suspend_broadcast(void) { }
145 static inline int tick_resume_broadcast(void) { return 0; }
146 static inline void tick_broadcast_init(void) { }
147 static inline int tick_broadcast_update_freq(struct clock_event_device
*dev
,
148 u32 freq
) { return -ENODEV
; }
151 * Set the periodic handler in non broadcast mode
153 static inline void tick_set_periodic_handler(struct clock_event_device
*dev
,
156 dev
->event_handler
= tick_handle_periodic
;
158 #endif /* !BROADCAST */
161 * Check, if the device is functional or a dummy for broadcast
163 static inline int tick_device_is_functional(struct clock_event_device
*dev
)
165 return !(dev
->features
& CLOCK_EVT_FEAT_DUMMY
);
168 int __clockevents_update_freq(struct clock_event_device
*dev
, u32 freq
);
172 extern void do_timer(unsigned long ticks
);
173 extern void update_wall_time(void);