tick-internal.h 5.2 KB

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