blob: 386374d19987449727ceb06f5d1cd138884d702c [file] [log] [blame]
Thomas Gleixnercff7d372016-02-26 18:43:28 +00001#ifndef __CPUHOTPLUG_H
2#define __CPUHOTPLUG_H
3
4enum cpuhp_state {
5 CPUHP_OFFLINE,
6 CPUHP_CREATE_THREADS,
7 CPUHP_NOTIFY_PREPARE,
8 CPUHP_BRINGUP_CPU,
Thomas Gleixnere69aab12016-02-26 18:43:43 +00009 CPUHP_AP_IDLE_DEAD,
Thomas Gleixner4baa0af2016-02-26 18:43:29 +000010 CPUHP_AP_OFFLINE,
Thomas Gleixner9cf72432016-03-10 12:54:09 +010011 CPUHP_AP_SCHED_STARTING,
Thomas Gleixner4baa0af2016-02-26 18:43:29 +000012 CPUHP_AP_NOTIFY_STARTING,
13 CPUHP_AP_ONLINE,
14 CPUHP_TEARDOWN_CPU,
Thomas Gleixnerfc6d73d2016-02-26 18:43:40 +000015 CPUHP_AP_ONLINE_IDLE,
Thomas Gleixner1cf4f622016-02-26 18:43:39 +000016 CPUHP_AP_SMPBOOT_THREADS,
17 CPUHP_AP_NOTIFY_ONLINE,
18 CPUHP_AP_ONLINE_DYN,
19 CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30,
Thomas Gleixneraaddd7d2016-03-10 12:54:19 +010020 CPUHP_AP_ACTIVE,
Thomas Gleixnercff7d372016-02-26 18:43:28 +000021 CPUHP_ONLINE,
22};
23
Thomas Gleixner5b7aa872016-02-26 18:43:33 +000024int __cpuhp_setup_state(enum cpuhp_state state, const char *name, bool invoke,
25 int (*startup)(unsigned int cpu),
26 int (*teardown)(unsigned int cpu));
27
28/**
29 * cpuhp_setup_state - Setup hotplug state callbacks with calling the callbacks
30 * @state: The state for which the calls are installed
31 * @name: Name of the callback (will be used in debug output)
32 * @startup: startup callback function
33 * @teardown: teardown callback function
34 *
35 * Installs the callback functions and invokes the startup callback on
36 * the present cpus which have already reached the @state.
37 */
38static inline int cpuhp_setup_state(enum cpuhp_state state,
39 const char *name,
40 int (*startup)(unsigned int cpu),
41 int (*teardown)(unsigned int cpu))
42{
43 return __cpuhp_setup_state(state, name, true, startup, teardown);
44}
45
46/**
47 * cpuhp_setup_state_nocalls - Setup hotplug state callbacks without calling the
48 * callbacks
49 * @state: The state for which the calls are installed
50 * @name: Name of the callback.
51 * @startup: startup callback function
52 * @teardown: teardown callback function
53 *
54 * Same as @cpuhp_setup_state except that no calls are executed are invoked
55 * during installation of this callback. NOP if SMP=n or HOTPLUG_CPU=n.
56 */
57static inline int cpuhp_setup_state_nocalls(enum cpuhp_state state,
58 const char *name,
59 int (*startup)(unsigned int cpu),
60 int (*teardown)(unsigned int cpu))
61{
62 return __cpuhp_setup_state(state, name, false, startup, teardown);
63}
64
65void __cpuhp_remove_state(enum cpuhp_state state, bool invoke);
66
67/**
68 * cpuhp_remove_state - Remove hotplug state callbacks and invoke the teardown
69 * @state: The state for which the calls are removed
70 *
71 * Removes the callback functions and invokes the teardown callback on
72 * the present cpus which have already reached the @state.
73 */
74static inline void cpuhp_remove_state(enum cpuhp_state state)
75{
76 __cpuhp_remove_state(state, true);
77}
78
79/**
80 * cpuhp_remove_state_nocalls - Remove hotplug state callbacks without invoking
81 * teardown
82 * @state: The state for which the calls are removed
83 */
84static inline void cpuhp_remove_state_nocalls(enum cpuhp_state state)
85{
86 __cpuhp_remove_state(state, false);
87}
88
Thomas Gleixner8df3e072016-02-26 18:43:41 +000089#ifdef CONFIG_SMP
90void cpuhp_online_idle(enum cpuhp_state state);
91#else
92static inline void cpuhp_online_idle(enum cpuhp_state state) { }
93#endif
94
Thomas Gleixnercff7d372016-02-26 18:43:28 +000095#endif