tick-internal.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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
  65. tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
  66. #else /* !BROADCAST */
  67. static inline int tick_check_broadcast_device(struct clock_event_device *dev)
  68. {
  69. return 0;
  70. }
  71. static inline int tick_is_broadcast_device(struct clock_event_device *dev)
  72. {
  73. return 0;
  74. }
  75. static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
  76. int cpu)
  77. {
  78. return 0;
  79. }
  80. static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
  81. static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
  82. static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
  83. /*
  84. * Set the periodic handler in non broadcast mode
  85. */
  86. static inline void tick_set_periodic_handler(struct clock_event_device *dev,
  87. int broadcast)
  88. {
  89. dev->event_handler = tick_handle_periodic;
  90. }
  91. #endif /* !BROADCAST */
  92. /*
  93. * Check, if the device is functional or a dummy for broadcast
  94. */
  95. static inline int tick_device_is_functional(struct clock_event_device *dev)
  96. {
  97. return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
  98. }