tick-internal.h 3.9 KB

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