1 /* 2 * tick internal variable and functions used by low/high res code 3 */ 4 #include <linux/hrtimer.h> 5 #include <linux/tick.h> 6 7 #include "timekeeping.h" 8 9 extern seqlock_t jiffies_lock; 10 11 #define CS_NAME_LEN 32 12 13 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD 14 15 #define TICK_DO_TIMER_NONE -1 16 #define TICK_DO_TIMER_BOOT -2 17 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; 22 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); 33 34 extern void clockevents_shutdown(struct clock_event_device *dev); 35 36 extern ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt); 37 38 /* 39 * NO_HZ / high resolution timer shared code 40 */ 41 #ifdef CONFIG_TICK_ONESHOT 42 extern void tick_setup_oneshot(struct clock_event_device *newdev, 43 void (*handler)(struct clock_event_device *), 44 ktime_t nextevt); 45 extern int tick_program_event(ktime_t expires, int force); 46 extern void tick_oneshot_notify(void); 47 extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); 48 extern void tick_resume_oneshot(void); 49 # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 50 extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc); 51 extern int tick_broadcast_oneshot_control(unsigned long reason); 52 extern void tick_broadcast_switch_to_oneshot(void); 53 extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); 54 extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); 55 extern int tick_broadcast_oneshot_active(void); 56 extern void tick_check_oneshot_broadcast_this_cpu(void); 57 bool tick_broadcast_oneshot_available(void); 58 # else /* BROADCAST */ 59 static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) 60 { 61 BUG(); 62 } 63 static inline int tick_broadcast_oneshot_control(unsigned long reason) { return 0; } 64 static inline void tick_broadcast_switch_to_oneshot(void) { } 65 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } 66 static inline int tick_broadcast_oneshot_active(void) { return 0; } 67 static inline void tick_check_oneshot_broadcast_this_cpu(void) { } 68 static inline bool tick_broadcast_oneshot_available(void) { return true; } 69 # endif /* !BROADCAST */ 70 71 #else /* !ONESHOT */ 72 static inline 73 void tick_setup_oneshot(struct clock_event_device *newdev, 74 void (*handler)(struct clock_event_device *), 75 ktime_t nextevt) 76 { 77 BUG(); 78 } 79 static inline void tick_resume_oneshot(void) 80 { 81 BUG(); 82 } 83 static inline int tick_program_event(ktime_t expires, int force) 84 { 85 return 0; 86 } 87 static inline void tick_oneshot_notify(void) { } 88 static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) 89 { 90 BUG(); 91 } 92 static inline int tick_broadcast_oneshot_control(unsigned long reason) { return 0; } 93 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } 94 static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc) 95 { 96 return 0; 97 } 98 static inline int tick_broadcast_oneshot_active(void) { return 0; } 99 static inline bool tick_broadcast_oneshot_available(void) { return false; } 100 #endif /* !TICK_ONESHOT */ 101 102 /* 103 * Broadcasting support 104 */ 105 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 106 extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); 107 extern void tick_install_broadcast_device(struct clock_event_device *dev); 108 extern int tick_is_broadcast_device(struct clock_event_device *dev); 109 extern void tick_broadcast_on_off(unsigned long reason, int *oncpu); 110 extern void tick_shutdown_broadcast(unsigned int *cpup); 111 extern void tick_suspend_broadcast(void); 112 extern int tick_resume_broadcast(void); 113 extern void tick_broadcast_init(void); 114 extern void 115 tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); 116 int tick_broadcast_update_freq(struct clock_event_device *dev, u32 freq); 117 118 #else /* !BROADCAST */ 119 120 static inline void tick_install_broadcast_device(struct clock_event_device *dev) 121 { 122 } 123 124 static inline int tick_is_broadcast_device(struct clock_event_device *dev) 125 { 126 return 0; 127 } 128 static inline int tick_device_uses_broadcast(struct clock_event_device *dev, 129 int cpu) 130 { 131 return 0; 132 } 133 static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } 134 static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } 135 static inline void tick_shutdown_broadcast(unsigned int *cpup) { } 136 static inline void tick_suspend_broadcast(void) { } 137 static inline int tick_resume_broadcast(void) { return 0; } 138 static inline void tick_broadcast_init(void) { } 139 static inline int tick_broadcast_update_freq(struct clock_event_device *dev, 140 u32 freq) { return -ENODEV; } 141 142 /* 143 * Set the periodic handler in non broadcast mode 144 */ 145 static inline void tick_set_periodic_handler(struct clock_event_device *dev, 146 int broadcast) 147 { 148 dev->event_handler = tick_handle_periodic; 149 } 150 #endif /* !BROADCAST */ 151 152 /* 153 * Check, if the device is functional or a dummy for broadcast 154 */ 155 static inline int tick_device_is_functional(struct clock_event_device *dev) 156 { 157 return !(dev->features & CLOCK_EVT_FEAT_DUMMY); 158 } 159 160 int __clockevents_update_freq(struct clock_event_device *dev, u32 freq); 161 162 #endif 163 164 extern void do_timer(unsigned long ticks); 165 extern void update_wall_time(void); 166