blob: ad5d7fcb013021811c57a87bc8a7b6e798142a34 [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 Gleixnerfc6d73d2016-02-26 18:43:40 +000013 CPUHP_AP_ONLINE_IDLE,
Thomas Gleixner1cf4f622016-02-26 18:43:39 +000014 CPUHP_AP_SMPBOOT_THREADS,
15 CPUHP_AP_NOTIFY_ONLINE,
16 CPUHP_AP_ONLINE_DYN,
17 CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30,
Thomas Gleixnercff7d372016-02-26 18:43:28 +000018 CPUHP_ONLINE,
19};
20
Thomas Gleixner5b7aa872016-02-26 18:43:33 +000021int __cpuhp_setup_state(enum cpuhp_state state, const char *name, bool invoke,
22 int (*startup)(unsigned int cpu),
23 int (*teardown)(unsigned int cpu));
24
25/**
26 * cpuhp_setup_state - Setup hotplug state callbacks with calling the callbacks
27 * @state: The state for which the calls are installed
28 * @name: Name of the callback (will be used in debug output)
29 * @startup: startup callback function
30 * @teardown: teardown callback function
31 *
32 * Installs the callback functions and invokes the startup callback on
33 * the present cpus which have already reached the @state.
34 */
35static inline int cpuhp_setup_state(enum cpuhp_state state,
36 const char *name,
37 int (*startup)(unsigned int cpu),
38 int (*teardown)(unsigned int cpu))
39{
40 return __cpuhp_setup_state(state, name, true, startup, teardown);
41}
42
43/**
44 * cpuhp_setup_state_nocalls - Setup hotplug state callbacks without calling the
45 * callbacks
46 * @state: The state for which the calls are installed
47 * @name: Name of the callback.
48 * @startup: startup callback function
49 * @teardown: teardown callback function
50 *
51 * Same as @cpuhp_setup_state except that no calls are executed are invoked
52 * during installation of this callback. NOP if SMP=n or HOTPLUG_CPU=n.
53 */
54static inline int cpuhp_setup_state_nocalls(enum cpuhp_state state,
55 const char *name,
56 int (*startup)(unsigned int cpu),
57 int (*teardown)(unsigned int cpu))
58{
59 return __cpuhp_setup_state(state, name, false, startup, teardown);
60}
61
62void __cpuhp_remove_state(enum cpuhp_state state, bool invoke);
63
64/**
65 * cpuhp_remove_state - Remove hotplug state callbacks and invoke the teardown
66 * @state: The state for which the calls are removed
67 *
68 * Removes the callback functions and invokes the teardown callback on
69 * the present cpus which have already reached the @state.
70 */
71static inline void cpuhp_remove_state(enum cpuhp_state state)
72{
73 __cpuhp_remove_state(state, true);
74}
75
76/**
77 * cpuhp_remove_state_nocalls - Remove hotplug state callbacks without invoking
78 * teardown
79 * @state: The state for which the calls are removed
80 */
81static inline void cpuhp_remove_state_nocalls(enum cpuhp_state state)
82{
83 __cpuhp_remove_state(state, false);
84}
85
Thomas Gleixner8df3e072016-02-26 18:43:41 +000086#ifdef CONFIG_SMP
87void cpuhp_online_idle(enum cpuhp_state state);
88#else
89static inline void cpuhp_online_idle(enum cpuhp_state state) { }
90#endif
91
Thomas Gleixnercff7d372016-02-26 18:43:28 +000092#endif