Blame view
include/linux/cpu.h
7.86 KB
1da177e4c
|
1 2 3 4 5 6 7 8 |
/* * include/linux/cpu.h - generic cpu definition * * This is mainly for topological representation. We define the * basic 'struct cpu' here, which can be embedded in per-arch * definitions of processors. * * Basic handling of the devices is done in drivers/base/cpu.c |
1da177e4c
|
9 |
* |
611a75e18
|
10 |
* CPUs are exported via sysfs in the devices/system/cpu |
1da177e4c
|
11 |
* directory. |
1da177e4c
|
12 13 14 |
*/ #ifndef _LINUX_CPU_H_ #define _LINUX_CPU_H_ |
1da177e4c
|
15 16 17 |
#include <linux/node.h> #include <linux/compiler.h> #include <linux/cpumask.h> |
cff7d378d
|
18 |
#include <linux/cpuhotplug.h> |
1da177e4c
|
19 |
|
313162d0b
|
20 |
struct device; |
d1cb9d1af
|
21 |
struct device_node; |
3d52943b3
|
22 |
struct attribute_group; |
313162d0b
|
23 |
|
1da177e4c
|
24 25 |
struct cpu { int node_id; /* The node which contains the CPU */ |
72486f1f8
|
26 |
int hotpluggable; /* creates sysfs control file if hotpluggable */ |
8a25a2fd1
|
27 |
struct device dev; |
1da177e4c
|
28 |
}; |
cff7d378d
|
29 30 |
extern void boot_cpu_init(void); extern void boot_cpu_state_init(void); |
76b67ed9d
|
31 |
extern int register_cpu(struct cpu *cpu, int num); |
8a25a2fd1
|
32 |
extern struct device *get_cpu_device(unsigned cpu); |
2987557f5
|
33 |
extern bool cpu_is_hotpluggable(unsigned cpu); |
183912d35
|
34 |
extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id); |
d1cb9d1af
|
35 36 |
extern bool arch_find_n_match_cpu_physical_id(struct device_node *cpun, int cpu, unsigned int *thread); |
0344c6c53
|
37 |
|
8a25a2fd1
|
38 39 |
extern int cpu_add_dev_attr(struct device_attribute *attr); extern void cpu_remove_dev_attr(struct device_attribute *attr); |
0344c6c53
|
40 |
|
8a25a2fd1
|
41 42 |
extern int cpu_add_dev_attr_group(struct attribute_group *attrs); extern void cpu_remove_dev_attr_group(struct attribute_group *attrs); |
0344c6c53
|
43 |
|
8db148606
|
44 45 46 47 |
extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata, const struct attribute_group **groups, const char *fmt, ...); |
1da177e4c
|
48 |
#ifdef CONFIG_HOTPLUG_CPU |
76b67ed9d
|
49 |
extern void unregister_cpu(struct cpu *cpu); |
12633e803
|
50 51 |
extern ssize_t arch_cpu_probe(const char *, size_t); extern ssize_t arch_cpu_release(const char *, size_t); |
1da177e4c
|
52 53 |
#endif struct notifier_block; |
80f1ff97d
|
54 55 56 57 58 59 |
#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ #define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ #define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ #define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ #define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ |
80f1ff97d
|
60 61 |
#define CPU_POST_DEAD 0x0009 /* CPU (unsigned)v dead, cpu_hotplug * lock is dropped */ |
27d50c7ee
|
62 |
#define CPU_BROKEN 0x000B /* CPU (unsigned)v did not die properly, |
8038dad7e
|
63 |
* perhaps due to preemption. */ |
80f1ff97d
|
64 65 66 67 68 69 70 71 72 73 74 75 |
/* Used for CPU hotplug events occurring while tasks are frozen due to a suspend * operation in progress */ #define CPU_TASKS_FROZEN 0x0010 #define CPU_ONLINE_FROZEN (CPU_ONLINE | CPU_TASKS_FROZEN) #define CPU_UP_PREPARE_FROZEN (CPU_UP_PREPARE | CPU_TASKS_FROZEN) #define CPU_UP_CANCELED_FROZEN (CPU_UP_CANCELED | CPU_TASKS_FROZEN) #define CPU_DOWN_PREPARE_FROZEN (CPU_DOWN_PREPARE | CPU_TASKS_FROZEN) #define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN) #define CPU_DEAD_FROZEN (CPU_DEAD | CPU_TASKS_FROZEN) |
80f1ff97d
|
76 |
|
1da177e4c
|
77 |
#ifdef CONFIG_SMP |
090e77c39
|
78 |
extern bool cpuhp_tasks_frozen; |
1da177e4c
|
79 |
/* Need to know about CPUs going up/down? */ |
799e64f05
|
80 81 |
#if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) #define cpu_notifier(fn, pri) { \ |
0db0628d9
|
82 |
static struct notifier_block fn##_nb = \ |
799e64f05
|
83 84 85 |
{ .notifier_call = fn, .priority = pri }; \ register_cpu_notifier(&fn##_nb); \ } |
93ae4f978
|
86 87 88 89 90 91 |
#define __cpu_notifier(fn, pri) { \ static struct notifier_block fn##_nb = \ { .notifier_call = fn, .priority = pri }; \ __register_cpu_notifier(&fn##_nb); \ } |
799e64f05
|
92 93 |
#else /* #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */ #define cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
93ae4f978
|
94 |
#define __cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
799e64f05
|
95 |
#endif /* #else #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */ |
93ae4f978
|
96 |
|
65edc68c3
|
97 |
#ifdef CONFIG_HOTPLUG_CPU |
47e627bc8
|
98 |
extern int register_cpu_notifier(struct notifier_block *nb); |
93ae4f978
|
99 |
extern int __register_cpu_notifier(struct notifier_block *nb); |
1da177e4c
|
100 |
extern void unregister_cpu_notifier(struct notifier_block *nb); |
93ae4f978
|
101 |
extern void __unregister_cpu_notifier(struct notifier_block *nb); |
65edc68c3
|
102 |
#else |
47e627bc8
|
103 104 105 |
#ifndef MODULE extern int register_cpu_notifier(struct notifier_block *nb); |
93ae4f978
|
106 |
extern int __register_cpu_notifier(struct notifier_block *nb); |
47e627bc8
|
107 108 109 110 111 |
#else static inline int register_cpu_notifier(struct notifier_block *nb) { return 0; } |
93ae4f978
|
112 113 114 115 116 |
static inline int __register_cpu_notifier(struct notifier_block *nb) { return 0; } |
47e627bc8
|
117 |
#endif |
65edc68c3
|
118 119 120 |
static inline void unregister_cpu_notifier(struct notifier_block *nb) { } |
93ae4f978
|
121 122 123 124 |
static inline void __unregister_cpu_notifier(struct notifier_block *nb) { } |
65edc68c3
|
125 |
#endif |
1da177e4c
|
126 127 |
int cpu_up(unsigned int cpu); |
e545a6140
|
128 |
void notify_cpu_starting(unsigned int cpu); |
3da1c84c0
|
129 130 |
extern void cpu_maps_update_begin(void); extern void cpu_maps_update_done(void); |
d0d23b543
|
131 |
|
93ae4f978
|
132 133 |
#define cpu_notifier_register_begin cpu_maps_update_begin #define cpu_notifier_register_done cpu_maps_update_done |
3da1c84c0
|
134 |
#else /* CONFIG_SMP */ |
090e77c39
|
135 |
#define cpuhp_tasks_frozen 0 |
1da177e4c
|
136 |
|
799e64f05
|
137 |
#define cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
93ae4f978
|
138 |
#define __cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
799e64f05
|
139 |
|
1da177e4c
|
140 141 142 143 |
static inline int register_cpu_notifier(struct notifier_block *nb) { return 0; } |
d0d23b543
|
144 |
|
93ae4f978
|
145 146 147 148 |
static inline int __register_cpu_notifier(struct notifier_block *nb) { return 0; } |
1da177e4c
|
149 150 151 |
static inline void unregister_cpu_notifier(struct notifier_block *nb) { } |
93ae4f978
|
152 153 154 |
static inline void __unregister_cpu_notifier(struct notifier_block *nb) { } |
3da1c84c0
|
155 156 157 158 159 160 161 |
static inline void cpu_maps_update_begin(void) { } static inline void cpu_maps_update_done(void) { } |
93ae4f978
|
162 163 164 165 166 167 168 |
static inline void cpu_notifier_register_begin(void) { } static inline void cpu_notifier_register_done(void) { } |
1da177e4c
|
169 |
#endif /* CONFIG_SMP */ |
8a25a2fd1
|
170 |
extern struct bus_type cpu_subsys; |
1da177e4c
|
171 172 173 |
#ifdef CONFIG_HOTPLUG_CPU /* Stop CPUs going up and down. */ |
f7dff2b12
|
174 |
|
b9d10be7a
|
175 176 |
extern void cpu_hotplug_begin(void); extern void cpu_hotplug_done(void); |
86ef5c9a8
|
177 178 |
extern void get_online_cpus(void); extern void put_online_cpus(void); |
16e53dbf1
|
179 180 |
extern void cpu_hotplug_disable(void); extern void cpu_hotplug_enable(void); |
799e64f05
|
181 |
#define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri) |
93ae4f978
|
182 |
#define __hotcpu_notifier(fn, pri) __cpu_notifier(fn, pri) |
39f4885c5
|
183 |
#define register_hotcpu_notifier(nb) register_cpu_notifier(nb) |
93ae4f978
|
184 |
#define __register_hotcpu_notifier(nb) __register_cpu_notifier(nb) |
39f4885c5
|
185 |
#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) |
93ae4f978
|
186 |
#define __unregister_hotcpu_notifier(nb) __unregister_cpu_notifier(nb) |
cb79295e2
|
187 |
void clear_tasks_mm_cpumask(int cpu); |
1da177e4c
|
188 |
int cpu_down(unsigned int cpu); |
f7dff2b12
|
189 190 |
#else /* CONFIG_HOTPLUG_CPU */ |
b9d10be7a
|
191 192 |
static inline void cpu_hotplug_begin(void) {} static inline void cpu_hotplug_done(void) {} |
86ef5c9a8
|
193 194 |
#define get_online_cpus() do { } while (0) #define put_online_cpus() do { } while (0) |
16e53dbf1
|
195 196 |
#define cpu_hotplug_disable() do { } while (0) #define cpu_hotplug_enable() do { } while (0) |
023160678
|
197 |
#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) |
93ae4f978
|
198 |
#define __hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) |
761bb4319
|
199 200 |
/* These aren't inline functions due to a GCC bug. */ #define register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) |
93ae4f978
|
201 |
#define __register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) |
761bb4319
|
202 |
#define unregister_hotcpu_notifier(nb) ({ (void)(nb); }) |
93ae4f978
|
203 |
#define __unregister_hotcpu_notifier(nb) ({ (void)(nb); }) |
f7dff2b12
|
204 |
#endif /* CONFIG_HOTPLUG_CPU */ |
1da177e4c
|
205 |
|
f3de4be9d
|
206 |
#ifdef CONFIG_PM_SLEEP_SMP |
d391e5522
|
207 208 209 210 211 |
extern int freeze_secondary_cpus(int primary); static inline int disable_nonboot_cpus(void) { return freeze_secondary_cpus(0); } |
e3920fb42
|
212 |
extern void enable_nonboot_cpus(void); |
f3de4be9d
|
213 |
#else /* !CONFIG_PM_SLEEP_SMP */ |
e3920fb42
|
214 215 |
static inline int disable_nonboot_cpus(void) { return 0; } static inline void enable_nonboot_cpus(void) {} |
f3de4be9d
|
216 |
#endif /* !CONFIG_PM_SLEEP_SMP */ |
e3920fb42
|
217 |
|
a1a04ec3c
|
218 |
void cpu_startup_entry(enum cpuhp_state state); |
a1a04ec3c
|
219 |
|
d16699123
|
220 |
void cpu_idle_poll_ctrl(bool enable); |
6727ad9e2
|
221 222 223 224 |
/* Attach to any functions which should be considered cpuidle. */ #define __cpuidle __attribute__((__section__(".cpuidle.text"))) bool cpu_in_idle(unsigned long pc); |
d16699123
|
225 226 227 228 229 |
void arch_cpu_idle(void); void arch_cpu_idle_prepare(void); void arch_cpu_idle_enter(void); void arch_cpu_idle_exit(void); void arch_cpu_idle_dead(void); |
8038dad7e
|
230 231 232 233 234 235 |
int cpu_report_state(int cpu); int cpu_check_up_prepare(int cpu); void cpu_set_state_online(int cpu); #ifdef CONFIG_HOTPLUG_CPU bool cpu_wait_death(unsigned int cpu, int seconds); bool cpu_report_death(void); |
e69aab131
|
236 237 238 |
void cpuhp_report_idle_dead(void); #else static inline void cpuhp_report_idle_dead(void) { } |
8038dad7e
|
239 |
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
1da177e4c
|
240 |
#endif /* _LINUX_CPU_H_ */ |