tick-internal.h 4.6 KB

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