diff options
Diffstat (limited to 'kernel/time/tick-internal.h')
| -rw-r--r-- | kernel/time/tick-internal.h | 211 |
1 files changed, 89 insertions, 122 deletions
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index 366aeb4f2c66..b64fdd8054c5 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h | |||
| @@ -5,15 +5,12 @@ | |||
| 5 | #include <linux/tick.h> | 5 | #include <linux/tick.h> |
| 6 | 6 | ||
| 7 | #include "timekeeping.h" | 7 | #include "timekeeping.h" |
| 8 | #include "tick-sched.h" | ||
| 8 | 9 | ||
| 9 | extern seqlock_t jiffies_lock; | 10 | #ifdef CONFIG_GENERIC_CLOCKEVENTS |
| 10 | 11 | ||
| 11 | #define CS_NAME_LEN 32 | 12 | # define TICK_DO_TIMER_NONE -1 |
| 12 | 13 | # define TICK_DO_TIMER_BOOT -2 | |
| 13 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD | ||
| 14 | |||
| 15 | #define TICK_DO_TIMER_NONE -1 | ||
| 16 | #define TICK_DO_TIMER_BOOT -2 | ||
| 17 | 14 | ||
| 18 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); | 15 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); |
| 19 | extern ktime_t tick_next_period; | 16 | extern ktime_t tick_next_period; |
| @@ -23,21 +20,72 @@ extern int tick_do_timer_cpu __read_mostly; | |||
| 23 | extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); | 20 | extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); |
| 24 | extern void tick_handle_periodic(struct clock_event_device *dev); | 21 | extern void tick_handle_periodic(struct clock_event_device *dev); |
| 25 | extern void tick_check_new_device(struct clock_event_device *dev); | 22 | extern void tick_check_new_device(struct clock_event_device *dev); |
| 26 | extern void tick_handover_do_timer(int *cpup); | 23 | extern void tick_shutdown(unsigned int cpu); |
| 27 | extern void tick_shutdown(unsigned int *cpup); | ||
| 28 | extern void tick_suspend(void); | 24 | extern void tick_suspend(void); |
| 29 | extern void tick_resume(void); | 25 | extern void tick_resume(void); |
| 30 | extern bool tick_check_replacement(struct clock_event_device *curdev, | 26 | extern bool tick_check_replacement(struct clock_event_device *curdev, |
| 31 | struct clock_event_device *newdev); | 27 | struct clock_event_device *newdev); |
| 32 | extern void tick_install_replacement(struct clock_event_device *dev); | 28 | extern void tick_install_replacement(struct clock_event_device *dev); |
| 29 | extern int tick_is_oneshot_available(void); | ||
| 30 | extern struct tick_device *tick_get_device(int cpu); | ||
| 33 | 31 | ||
| 34 | extern void clockevents_shutdown(struct clock_event_device *dev); | 32 | extern int clockevents_tick_resume(struct clock_event_device *dev); |
| 33 | /* Check, if the device is functional or a dummy for broadcast */ | ||
| 34 | static inline int tick_device_is_functional(struct clock_event_device *dev) | ||
| 35 | { | ||
| 36 | return !(dev->features & CLOCK_EVT_FEAT_DUMMY); | ||
| 37 | } | ||
| 35 | 38 | ||
| 39 | extern void clockevents_shutdown(struct clock_event_device *dev); | ||
| 40 | extern void clockevents_exchange_device(struct clock_event_device *old, | ||
| 41 | struct clock_event_device *new); | ||
| 42 | extern void clockevents_set_state(struct clock_event_device *dev, | ||
| 43 | enum clock_event_state state); | ||
| 44 | extern int clockevents_program_event(struct clock_event_device *dev, | ||
| 45 | ktime_t expires, bool force); | ||
| 46 | extern void clockevents_handle_noop(struct clock_event_device *dev); | ||
| 47 | extern int __clockevents_update_freq(struct clock_event_device *dev, u32 freq); | ||
| 36 | extern ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt); | 48 | extern ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt); |
| 37 | 49 | ||
| 38 | /* | 50 | /* Broadcasting support */ |
| 39 | * NO_HZ / high resolution timer shared code | 51 | # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
| 40 | */ | 52 | extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); |
| 53 | extern void tick_install_broadcast_device(struct clock_event_device *dev); | ||
| 54 | extern int tick_is_broadcast_device(struct clock_event_device *dev); | ||
| 55 | extern void tick_shutdown_broadcast(unsigned int cpu); | ||
| 56 | extern void tick_suspend_broadcast(void); | ||
| 57 | extern void tick_resume_broadcast(void); | ||
| 58 | extern bool tick_resume_check_broadcast(void); | ||
| 59 | extern void tick_broadcast_init(void); | ||
| 60 | extern void tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); | ||
| 61 | extern int tick_broadcast_update_freq(struct clock_event_device *dev, u32 freq); | ||
| 62 | extern struct tick_device *tick_get_broadcast_device(void); | ||
| 63 | extern struct cpumask *tick_get_broadcast_mask(void); | ||
| 64 | # else /* !CONFIG_GENERIC_CLOCKEVENTS_BROADCAST: */ | ||
| 65 | static inline void tick_install_broadcast_device(struct clock_event_device *dev) { } | ||
| 66 | static inline int tick_is_broadcast_device(struct clock_event_device *dev) { return 0; } | ||
| 67 | static inline int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) { return 0; } | ||
| 68 | static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } | ||
| 69 | static inline void tick_shutdown_broadcast(unsigned int cpu) { } | ||
| 70 | static inline void tick_suspend_broadcast(void) { } | ||
| 71 | static inline void tick_resume_broadcast(void) { } | ||
| 72 | static inline bool tick_resume_check_broadcast(void) { return false; } | ||
| 73 | static inline void tick_broadcast_init(void) { } | ||
| 74 | static inline int tick_broadcast_update_freq(struct clock_event_device *dev, u32 freq) { return -ENODEV; } | ||
| 75 | |||
| 76 | /* Set the periodic handler in non broadcast mode */ | ||
| 77 | static inline void tick_set_periodic_handler(struct clock_event_device *dev, int broadcast) | ||
| 78 | { | ||
| 79 | dev->event_handler = tick_handle_periodic; | ||
| 80 | } | ||
| 81 | # endif /* !CONFIG_GENERIC_CLOCKEVENTS_BROADCAST */ | ||
| 82 | |||
| 83 | #else /* !GENERIC_CLOCKEVENTS: */ | ||
| 84 | static inline void tick_suspend(void) { } | ||
| 85 | static inline void tick_resume(void) { } | ||
| 86 | #endif /* !GENERIC_CLOCKEVENTS */ | ||
| 87 | |||
| 88 | /* Oneshot related functions */ | ||
| 41 | #ifdef CONFIG_TICK_ONESHOT | 89 | #ifdef CONFIG_TICK_ONESHOT |
| 42 | extern void tick_setup_oneshot(struct clock_event_device *newdev, | 90 | extern void tick_setup_oneshot(struct clock_event_device *newdev, |
| 43 | void (*handler)(struct clock_event_device *), | 91 | void (*handler)(struct clock_event_device *), |
| @@ -46,58 +94,42 @@ extern int tick_program_event(ktime_t expires, int force); | |||
| 46 | extern void tick_oneshot_notify(void); | 94 | extern void tick_oneshot_notify(void); |
| 47 | extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); | 95 | extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); |
| 48 | extern void tick_resume_oneshot(void); | 96 | extern void tick_resume_oneshot(void); |
| 49 | # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST | 97 | static inline bool tick_oneshot_possible(void) { return true; } |
| 98 | extern int tick_oneshot_mode_active(void); | ||
| 99 | extern void tick_clock_notify(void); | ||
| 100 | extern int tick_check_oneshot_change(int allow_nohz); | ||
| 101 | extern int tick_init_highres(void); | ||
| 102 | #else /* !CONFIG_TICK_ONESHOT: */ | ||
| 103 | static inline | ||
| 104 | void tick_setup_oneshot(struct clock_event_device *newdev, | ||
| 105 | void (*handler)(struct clock_event_device *), | ||
| 106 | ktime_t nextevt) { BUG(); } | ||
| 107 | static inline void tick_resume_oneshot(void) { BUG(); } | ||
| 108 | static inline int tick_program_event(ktime_t expires, int force) { return 0; } | ||
| 109 | static inline void tick_oneshot_notify(void) { } | ||
| 110 | static inline bool tick_oneshot_possible(void) { return false; } | ||
| 111 | static inline int tick_oneshot_mode_active(void) { return 0; } | ||
| 112 | static inline void tick_clock_notify(void) { } | ||
| 113 | static inline int tick_check_oneshot_change(int allow_nohz) { return 0; } | ||
| 114 | #endif /* !CONFIG_TICK_ONESHOT */ | ||
| 115 | |||
| 116 | /* Functions related to oneshot broadcasting */ | ||
| 117 | #if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && defined(CONFIG_TICK_ONESHOT) | ||
| 50 | extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc); | 118 | 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); | 119 | extern void tick_broadcast_switch_to_oneshot(void); |
| 53 | extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); | 120 | extern void tick_shutdown_broadcast_oneshot(unsigned int cpu); |
| 54 | extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); | ||
| 55 | extern int tick_broadcast_oneshot_active(void); | 121 | extern int tick_broadcast_oneshot_active(void); |
| 56 | extern void tick_check_oneshot_broadcast_this_cpu(void); | 122 | extern void tick_check_oneshot_broadcast_this_cpu(void); |
| 57 | bool tick_broadcast_oneshot_available(void); | 123 | bool tick_broadcast_oneshot_available(void); |
| 58 | # else /* BROADCAST */ | 124 | extern struct cpumask *tick_get_broadcast_oneshot_mask(void); |
| 59 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) | 125 | #else /* !(BROADCAST && ONESHOT): */ |
| 60 | { | 126 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) { BUG(); } |
| 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) { } | 127 | static inline void tick_broadcast_switch_to_oneshot(void) { } |
| 65 | static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } | 128 | static inline void tick_shutdown_broadcast_oneshot(unsigned int cpu) { } |
| 66 | static inline int tick_broadcast_oneshot_active(void) { return 0; } | 129 | static inline int tick_broadcast_oneshot_active(void) { return 0; } |
| 67 | static inline void tick_check_oneshot_broadcast_this_cpu(void) { } | 130 | static inline void tick_check_oneshot_broadcast_this_cpu(void) { } |
| 68 | static inline bool tick_broadcast_oneshot_available(void) { return true; } | 131 | static inline bool tick_broadcast_oneshot_available(void) { return tick_oneshot_possible(); } |
| 69 | # endif /* !BROADCAST */ | 132 | #endif /* !(BROADCAST && ONESHOT) */ |
| 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 | 133 | ||
| 102 | /* NO_HZ_FULL internal */ | 134 | /* NO_HZ_FULL internal */ |
| 103 | #ifdef CONFIG_NO_HZ_FULL | 135 | #ifdef CONFIG_NO_HZ_FULL |
| @@ -105,68 +137,3 @@ extern void tick_nohz_init(void); | |||
| 105 | # else | 137 | # else |
| 106 | static inline void tick_nohz_init(void) { } | 138 | static inline void tick_nohz_init(void) { } |
| 107 | #endif | 139 | #endif |
| 108 | |||
| 109 | /* | ||
| 110 | * Broadcasting support | ||
| 111 | */ | ||
| 112 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST | ||
| 113 | extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); | ||
| 114 | extern void tick_install_broadcast_device(struct clock_event_device *dev); | ||
| 115 | extern int tick_is_broadcast_device(struct clock_event_device *dev); | ||
| 116 | extern void tick_broadcast_on_off(unsigned long reason, int *oncpu); | ||
| 117 | extern void tick_shutdown_broadcast(unsigned int *cpup); | ||
| 118 | extern void tick_suspend_broadcast(void); | ||
| 119 | extern int tick_resume_broadcast(void); | ||
| 120 | extern void tick_broadcast_init(void); | ||
| 121 | extern void | ||
| 122 | tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); | ||
| 123 | int tick_broadcast_update_freq(struct clock_event_device *dev, u32 freq); | ||
| 124 | |||
| 125 | #else /* !BROADCAST */ | ||
| 126 | |||
| 127 | static inline void tick_install_broadcast_device(struct clock_event_device *dev) | ||
| 128 | { | ||
| 129 | } | ||
| 130 | |||
| 131 | static inline int tick_is_broadcast_device(struct clock_event_device *dev) | ||
| 132 | { | ||
| 133 | return 0; | ||
| 134 | } | ||
| 135 | static inline int tick_device_uses_broadcast(struct clock_event_device *dev, | ||
| 136 | int cpu) | ||
| 137 | { | ||
| 138 | return 0; | ||
| 139 | } | ||
| 140 | static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } | ||
| 141 | static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } | ||
| 142 | static inline void tick_shutdown_broadcast(unsigned int *cpup) { } | ||
| 143 | static inline void tick_suspend_broadcast(void) { } | ||
| 144 | static inline int tick_resume_broadcast(void) { return 0; } | ||
| 145 | static inline void tick_broadcast_init(void) { } | ||
| 146 | static inline int tick_broadcast_update_freq(struct clock_event_device *dev, | ||
| 147 | u32 freq) { return -ENODEV; } | ||
| 148 | |||
| 149 | /* | ||
| 150 | * Set the periodic handler in non broadcast mode | ||
| 151 | */ | ||
| 152 | static inline void tick_set_periodic_handler(struct clock_event_device *dev, | ||
| 153 | int broadcast) | ||
| 154 | { | ||
| 155 | dev->event_handler = tick_handle_periodic; | ||
| 156 | } | ||
| 157 | #endif /* !BROADCAST */ | ||
| 158 | |||
| 159 | /* | ||
| 160 | * Check, if the device is functional or a dummy for broadcast | ||
| 161 | */ | ||
| 162 | static inline int tick_device_is_functional(struct clock_event_device *dev) | ||
| 163 | { | ||
| 164 | return !(dev->features & CLOCK_EVT_FEAT_DUMMY); | ||
| 165 | } | ||
| 166 | |||
| 167 | int __clockevents_update_freq(struct clock_event_device *dev, u32 freq); | ||
| 168 | |||
| 169 | #endif | ||
| 170 | |||
| 171 | extern void do_timer(unsigned long ticks); | ||
| 172 | extern void update_wall_time(void); | ||
