tick-internal.h 5.7 KB

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