tick-internal.h 4.9 KB

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