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