tick-internal.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_device_uses_broadcast(struct clock_event_device *dev, int cpu);
  70. extern int tick_check_broadcast_device(struct clock_event_device *dev);
  71. extern int tick_is_broadcast_device(struct clock_event_device *dev);
  72. extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
  73. extern void tick_shutdown_broadcast(unsigned int *cpup);
  74. extern void tick_suspend_broadcast(void);
  75. extern int tick_resume_broadcast(void);
  76. extern void
  77. tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
  78. #else /* !BROADCAST */
  79. static inline int tick_check_broadcast_device(struct clock_event_device *dev)
  80. {
  81. return 0;
  82. }
  83. static inline int tick_is_broadcast_device(struct clock_event_device *dev)
  84. {
  85. return 0;
  86. }
  87. static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
  88. int cpu)
  89. {
  90. return 0;
  91. }
  92. static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
  93. static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
  94. static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
  95. static inline void tick_suspend_broadcast(void) { }
  96. static inline int tick_resume_broadcast(void) { return 0; }
  97. /*
  98. * Set the periodic handler in non broadcast mode
  99. */
  100. static inline void tick_set_periodic_handler(struct clock_event_device *dev,
  101. int broadcast)
  102. {
  103. dev->event_handler = tick_handle_periodic;
  104. }
  105. #endif /* !BROADCAST */
  106. /*
  107. * Check, if the device is functional or a dummy for broadcast
  108. */
  109. static inline int tick_device_is_functional(struct clock_event_device *dev)
  110. {
  111. return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
  112. }