Thomas Gleixner | cff7d37 | 2016-02-26 18:43:28 +0000 | [diff] [blame] | 1 | #ifndef __CPUHOTPLUG_H |
| 2 | #define __CPUHOTPLUG_H |
| 3 | |
| 4 | enum cpuhp_state { |
| 5 | CPUHP_OFFLINE, |
| 6 | CPUHP_CREATE_THREADS, |
| 7 | CPUHP_NOTIFY_PREPARE, |
| 8 | CPUHP_BRINGUP_CPU, |
Thomas Gleixner | e69aab1 | 2016-02-26 18:43:43 +0000 | [diff] [blame] | 9 | CPUHP_AP_IDLE_DEAD, |
Thomas Gleixner | 4baa0af | 2016-02-26 18:43:29 +0000 | [diff] [blame] | 10 | CPUHP_AP_OFFLINE, |
Thomas Gleixner | 9cf7243 | 2016-03-10 12:54:09 +0100 | [diff] [blame] | 11 | CPUHP_AP_SCHED_STARTING, |
Thomas Gleixner | 4baa0af | 2016-02-26 18:43:29 +0000 | [diff] [blame] | 12 | CPUHP_AP_NOTIFY_STARTING, |
| 13 | CPUHP_AP_ONLINE, |
| 14 | CPUHP_TEARDOWN_CPU, |
Thomas Gleixner | fc6d73d | 2016-02-26 18:43:40 +0000 | [diff] [blame] | 15 | CPUHP_AP_ONLINE_IDLE, |
Thomas Gleixner | 1cf4f62 | 2016-02-26 18:43:39 +0000 | [diff] [blame] | 16 | 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 Gleixner | aaddd7d | 2016-03-10 12:54:19 +0100 | [diff] [blame] | 20 | CPUHP_AP_ACTIVE, |
Thomas Gleixner | cff7d37 | 2016-02-26 18:43:28 +0000 | [diff] [blame] | 21 | CPUHP_ONLINE, |
| 22 | }; |
| 23 | |
Thomas Gleixner | 5b7aa87 | 2016-02-26 18:43:33 +0000 | [diff] [blame] | 24 | int __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 | */ |
| 38 | static 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 | */ |
| 57 | static 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 | |
| 65 | void __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 | */ |
| 74 | static 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 | */ |
| 84 | static inline void cpuhp_remove_state_nocalls(enum cpuhp_state state) |
| 85 | { |
| 86 | __cpuhp_remove_state(state, false); |
| 87 | } |
| 88 | |
Thomas Gleixner | 8df3e07 | 2016-02-26 18:43:41 +0000 | [diff] [blame] | 89 | #ifdef CONFIG_SMP |
| 90 | void cpuhp_online_idle(enum cpuhp_state state); |
| 91 | #else |
| 92 | static inline void cpuhp_online_idle(enum cpuhp_state state) { } |
| 93 | #endif |
| 94 | |
Thomas Gleixner | cff7d37 | 2016-02-26 18:43:28 +0000 | [diff] [blame] | 95 | #endif |