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