tick-internal.h 4.1 KB

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