arm/bL_switcher: Kill tick suspend hackery
[cascardo/linux.git] / include / linux / tick.h
1 /*
2  * Tick related global functions
3  */
4 #ifndef _LINUX_TICK_H
5 #define _LINUX_TICK_H
6
7 #include <linux/clockchips.h>
8 #include <linux/irqflags.h>
9 #include <linux/percpu.h>
10 #include <linux/context_tracking_state.h>
11 #include <linux/cpumask.h>
12 #include <linux/sched.h>
13
14 #ifdef CONFIG_GENERIC_CLOCKEVENTS
15 extern void __init tick_init(void);
16 extern void tick_freeze(void);
17 extern void tick_unfreeze(void);
18 /* Should be core only, but ARM BL switcher requires it */
19 extern void tick_suspend_local(void);
20 /* Should be core only, but XEN resume magic and ARM BL switcher require it */
21 extern void tick_resume_local(void);
22 #else /* CONFIG_GENERIC_CLOCKEVENTS */
23 static inline void tick_init(void) { }
24 static inline void tick_freeze(void) { }
25 static inline void tick_unfreeze(void) { }
26 static inline void tick_suspend_local(void) { }
27 static inline void tick_resume_local(void) { }
28 #endif /* !CONFIG_GENERIC_CLOCKEVENTS */
29
30 #ifdef CONFIG_TICK_ONESHOT
31 extern void tick_irq_enter(void);
32 #  ifndef arch_needs_cpu
33 #   define arch_needs_cpu() (0)
34 #  endif
35 # else
36 static inline void tick_irq_enter(void) { }
37 #endif
38
39 #ifdef CONFIG_NO_HZ_COMMON
40 extern int tick_nohz_tick_stopped(void);
41 extern void tick_nohz_idle_enter(void);
42 extern void tick_nohz_idle_exit(void);
43 extern void tick_nohz_irq_exit(void);
44 extern ktime_t tick_nohz_get_sleep_length(void);
45 extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);
46 extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time);
47 #else /* !CONFIG_NO_HZ_COMMON */
48 static inline int tick_nohz_tick_stopped(void) { return 0; }
49 static inline void tick_nohz_idle_enter(void) { }
50 static inline void tick_nohz_idle_exit(void) { }
51
52 static inline ktime_t tick_nohz_get_sleep_length(void)
53 {
54         ktime_t len = { .tv64 = NSEC_PER_SEC/HZ };
55
56         return len;
57 }
58 static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; }
59 static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; }
60 #endif /* !CONFIG_NO_HZ_COMMON */
61
62 #ifdef CONFIG_NO_HZ_FULL
63 extern bool tick_nohz_full_running;
64 extern cpumask_var_t tick_nohz_full_mask;
65 extern cpumask_var_t housekeeping_mask;
66
67 static inline bool tick_nohz_full_enabled(void)
68 {
69         if (!context_tracking_is_enabled())
70                 return false;
71
72         return tick_nohz_full_running;
73 }
74
75 static inline bool tick_nohz_full_cpu(int cpu)
76 {
77         if (!tick_nohz_full_enabled())
78                 return false;
79
80         return cpumask_test_cpu(cpu, tick_nohz_full_mask);
81 }
82
83 extern void __tick_nohz_full_check(void);
84 extern void tick_nohz_full_kick(void);
85 extern void tick_nohz_full_kick_cpu(int cpu);
86 extern void tick_nohz_full_kick_all(void);
87 extern void __tick_nohz_task_switch(struct task_struct *tsk);
88 #else
89 static inline bool tick_nohz_full_enabled(void) { return false; }
90 static inline bool tick_nohz_full_cpu(int cpu) { return false; }
91 static inline void __tick_nohz_full_check(void) { }
92 static inline void tick_nohz_full_kick_cpu(int cpu) { }
93 static inline void tick_nohz_full_kick(void) { }
94 static inline void tick_nohz_full_kick_all(void) { }
95 static inline void __tick_nohz_task_switch(struct task_struct *tsk) { }
96 #endif
97
98 static inline bool is_housekeeping_cpu(int cpu)
99 {
100 #ifdef CONFIG_NO_HZ_FULL
101         if (tick_nohz_full_enabled())
102                 return cpumask_test_cpu(cpu, housekeeping_mask);
103 #endif
104         return true;
105 }
106
107 static inline void housekeeping_affine(struct task_struct *t)
108 {
109 #ifdef CONFIG_NO_HZ_FULL
110         if (tick_nohz_full_enabled())
111                 set_cpus_allowed_ptr(t, housekeeping_mask);
112
113 #endif
114 }
115
116 static inline void tick_nohz_full_check(void)
117 {
118         if (tick_nohz_full_enabled())
119                 __tick_nohz_full_check();
120 }
121
122 static inline void tick_nohz_task_switch(struct task_struct *tsk)
123 {
124         if (tick_nohz_full_enabled())
125                 __tick_nohz_task_switch(tsk);
126 }
127
128 #endif