tick-internal.h 4.1 KB

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