blob: 4aa263adc536dee04ecff034e696c4987dbed36b [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 Gleixner4baa0af2016-02-26 18:43:29 +00009 CPUHP_AP_OFFLINE,
10 CPUHP_AP_NOTIFY_STARTING,
11 CPUHP_AP_ONLINE,
12 CPUHP_TEARDOWN_CPU,
Thomas Gleixner949338e2016-02-26 18:43:35 +000013 CPUHP_CPU_SET_ACTIVE,
Thomas Gleixner1cf4f622016-02-26 18:43:39 +000014 CPUHP_KICK_AP_THREAD,
15 CPUHP_BP_ONLINE,
Thomas Gleixnerfc6d73d2016-02-26 18:43:40 +000016 CPUHP_AP_ONLINE_IDLE,
Thomas Gleixner1cf4f622016-02-26 18:43:39 +000017 CPUHP_AP_SMPBOOT_THREADS,
18 CPUHP_AP_NOTIFY_ONLINE,
19 CPUHP_AP_ONLINE_DYN,
20 CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30,
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 Gleixnercff7d372016-02-26 18:43:28 +000089#endif