tick-internal.h 4.6 KB

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