tick-internal.h 3.6 KB

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