Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 1 | /* |
| 2 | * tick internal variable and functions used by low/high res code |
| 3 | */ |
Torben Hohn | e2830b5 | 2011-01-27 16:00:32 +0100 | [diff] [blame] | 4 | #include <linux/hrtimer.h> |
| 5 | #include <linux/tick.h> |
Thomas Gleixner | 6441402 | 2008-09-22 18:46:37 +0200 | [diff] [blame] | 6 | |
Thomas Gleixner | eb93e4d | 2013-02-21 22:51:36 +0000 | [diff] [blame] | 7 | extern seqlock_t jiffies_lock; |
| 8 | |
Thomas Gleixner | 7cf37e8 | 2011-02-01 09:34:58 +0100 | [diff] [blame] | 9 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD |
Thomas Gleixner | 6441402 | 2008-09-22 18:46:37 +0200 | [diff] [blame] | 10 | |
| 11 | #define TICK_DO_TIMER_NONE -1 |
| 12 | #define TICK_DO_TIMER_BOOT -2 |
| 13 | |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 14 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 15 | extern ktime_t tick_next_period; |
| 16 | extern ktime_t tick_period; |
Thomas Gleixner | d3ed782 | 2007-05-08 00:30:03 -0700 | [diff] [blame] | 17 | extern int tick_do_timer_cpu __read_mostly; |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 18 | |
| 19 | extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); |
| 20 | extern void tick_handle_periodic(struct clock_event_device *dev); |
Thomas Gleixner | 7172a286 | 2013-04-25 20:31:47 +0000 | [diff] [blame] | 21 | extern void tick_check_new_device(struct clock_event_device *dev); |
Thomas Gleixner | 8c53daf | 2013-04-25 20:31:48 +0000 | [diff] [blame^] | 22 | extern void tick_handover_do_timer(int *cpup); |
| 23 | extern void tick_shutdown(unsigned int *cpup); |
| 24 | extern void tick_suspend(void); |
| 25 | extern void tick_resume(void); |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 26 | |
Thomas Gleixner | 2344abb | 2008-09-16 11:32:50 -0700 | [diff] [blame] | 27 | extern void clockevents_shutdown(struct clock_event_device *dev); |
| 28 | |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 29 | /* |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 30 | * NO_HZ / high resolution timer shared code |
| 31 | */ |
| 32 | #ifdef CONFIG_TICK_ONESHOT |
| 33 | extern void tick_setup_oneshot(struct clock_event_device *newdev, |
| 34 | void (*handler)(struct clock_event_device *), |
| 35 | ktime_t nextevt); |
| 36 | extern int tick_program_event(ktime_t expires, int force); |
| 37 | extern void tick_oneshot_notify(void); |
| 38 | extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 39 | extern void tick_resume_oneshot(void); |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 40 | # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
| 41 | extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc); |
| 42 | extern void tick_broadcast_oneshot_control(unsigned long reason); |
| 43 | extern void tick_broadcast_switch_to_oneshot(void); |
| 44 | extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 45 | extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); |
Thomas Gleixner | 27ce4cb | 2008-09-22 19:04:02 +0200 | [diff] [blame] | 46 | extern int tick_broadcast_oneshot_active(void); |
Thomas Gleixner | fb02fbc | 2008-10-17 10:01:23 +0200 | [diff] [blame] | 47 | extern void tick_check_oneshot_broadcast(int cpu); |
Thomas Gleixner | 3a142a0 | 2011-02-25 22:34:23 +0100 | [diff] [blame] | 48 | bool tick_broadcast_oneshot_available(void); |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 49 | # else /* BROADCAST */ |
| 50 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) |
| 51 | { |
| 52 | BUG(); |
| 53 | } |
| 54 | static inline void tick_broadcast_oneshot_control(unsigned long reason) { } |
| 55 | static inline void tick_broadcast_switch_to_oneshot(void) { } |
| 56 | static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } |
Thomas Gleixner | 27ce4cb | 2008-09-22 19:04:02 +0200 | [diff] [blame] | 57 | static inline int tick_broadcast_oneshot_active(void) { return 0; } |
Thomas Gleixner | fb02fbc | 2008-10-17 10:01:23 +0200 | [diff] [blame] | 58 | static inline void tick_check_oneshot_broadcast(int cpu) { } |
Thomas Gleixner | 3a142a0 | 2011-02-25 22:34:23 +0100 | [diff] [blame] | 59 | static inline bool tick_broadcast_oneshot_available(void) { return true; } |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 60 | # endif /* !BROADCAST */ |
| 61 | |
| 62 | #else /* !ONESHOT */ |
| 63 | static inline |
| 64 | void tick_setup_oneshot(struct clock_event_device *newdev, |
| 65 | void (*handler)(struct clock_event_device *), |
| 66 | ktime_t nextevt) |
| 67 | { |
| 68 | BUG(); |
| 69 | } |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 70 | static inline void tick_resume_oneshot(void) |
| 71 | { |
| 72 | BUG(); |
| 73 | } |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 74 | static inline int tick_program_event(ktime_t expires, int force) |
| 75 | { |
| 76 | return 0; |
| 77 | } |
| 78 | static inline void tick_oneshot_notify(void) { } |
| 79 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) |
| 80 | { |
| 81 | BUG(); |
| 82 | } |
| 83 | static inline void tick_broadcast_oneshot_control(unsigned long reason) { } |
| 84 | static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 85 | static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc) |
| 86 | { |
| 87 | return 0; |
| 88 | } |
Ingo Molnar | f8e256c | 2008-09-23 13:00:57 +0200 | [diff] [blame] | 89 | static inline int tick_broadcast_oneshot_active(void) { return 0; } |
Thomas Gleixner | 3a142a0 | 2011-02-25 22:34:23 +0100 | [diff] [blame] | 90 | static inline bool tick_broadcast_oneshot_available(void) { return false; } |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 91 | #endif /* !TICK_ONESHOT */ |
| 92 | |
| 93 | /* |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 94 | * Broadcasting support |
| 95 | */ |
| 96 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 97 | extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); |
Thomas Gleixner | 7172a286 | 2013-04-25 20:31:47 +0000 | [diff] [blame] | 98 | extern void tick_install_broadcast_device(struct clock_event_device *dev); |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 99 | extern int tick_is_broadcast_device(struct clock_event_device *dev); |
| 100 | extern void tick_broadcast_on_off(unsigned long reason, int *oncpu); |
| 101 | extern void tick_shutdown_broadcast(unsigned int *cpup); |
Thomas Gleixner | 6321dd6 | 2007-03-06 08:25:42 +0100 | [diff] [blame] | 102 | extern void tick_suspend_broadcast(void); |
| 103 | extern int tick_resume_broadcast(void); |
Thomas Gleixner | b352bc1 | 2013-03-05 14:25:32 +0100 | [diff] [blame] | 104 | extern void tick_broadcast_init(void); |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 105 | extern void |
| 106 | tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); |
| 107 | |
| 108 | #else /* !BROADCAST */ |
| 109 | |
Thomas Gleixner | 7172a286 | 2013-04-25 20:31:47 +0000 | [diff] [blame] | 110 | static inline void tick_install_broadcast_device(struct clock_event_device *dev) |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 111 | { |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | static inline int tick_is_broadcast_device(struct clock_event_device *dev) |
| 115 | { |
| 116 | return 0; |
| 117 | } |
| 118 | static inline int tick_device_uses_broadcast(struct clock_event_device *dev, |
| 119 | int cpu) |
| 120 | { |
| 121 | return 0; |
| 122 | } |
| 123 | static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } |
| 124 | static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } |
| 125 | static inline void tick_shutdown_broadcast(unsigned int *cpup) { } |
Thomas Gleixner | 6321dd6 | 2007-03-06 08:25:42 +0100 | [diff] [blame] | 126 | static inline void tick_suspend_broadcast(void) { } |
| 127 | static inline int tick_resume_broadcast(void) { return 0; } |
Thomas Gleixner | b352bc1 | 2013-03-05 14:25:32 +0100 | [diff] [blame] | 128 | static inline void tick_broadcast_init(void) { } |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 129 | |
| 130 | /* |
| 131 | * Set the periodic handler in non broadcast mode |
| 132 | */ |
| 133 | static inline void tick_set_periodic_handler(struct clock_event_device *dev, |
| 134 | int broadcast) |
| 135 | { |
| 136 | dev->event_handler = tick_handle_periodic; |
| 137 | } |
| 138 | #endif /* !BROADCAST */ |
| 139 | |
| 140 | /* |
| 141 | * Check, if the device is functional or a dummy for broadcast |
| 142 | */ |
| 143 | static inline int tick_device_is_functional(struct clock_event_device *dev) |
| 144 | { |
| 145 | return !(dev->features & CLOCK_EVT_FEAT_DUMMY); |
| 146 | } |
Torben Hohn | e2830b5 | 2011-01-27 16:00:32 +0100 | [diff] [blame] | 147 | |
Thomas Gleixner | 7cf37e8 | 2011-02-01 09:34:58 +0100 | [diff] [blame] | 148 | #endif |
| 149 | |
Torben Hohn | e2830b5 | 2011-01-27 16:00:32 +0100 | [diff] [blame] | 150 | extern void do_timer(unsigned long ticks); |