tick-internal.h 4.8 KB

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