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