Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/cpu.h - generic cpu definition |
| 3 | * |
| 4 | * This is mainly for topological representation. We define the |
| 5 | * basic 'struct cpu' here, which can be embedded in per-arch |
| 6 | * definitions of processors. |
| 7 | * |
| 8 | * Basic handling of the devices is done in drivers/base/cpu.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
Robert P. J. Day | 611a75e1 | 2013-05-03 06:45:48 -0400 | [diff] [blame] | 10 | * CPUs are exported via sysfs in the devices/system/cpu |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * directory. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | */ |
| 13 | #ifndef _LINUX_CPU_H_ |
| 14 | #define _LINUX_CPU_H_ |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/node.h> |
| 17 | #include <linux/compiler.h> |
| 18 | #include <linux/cpumask.h> |
Thomas Gleixner | cff7d37 | 2016-02-26 18:43:28 +0000 | [diff] [blame] | 19 | #include <linux/cpuhotplug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Paul Gortmaker | 313162d | 2012-01-30 11:46:54 -0500 | [diff] [blame] | 21 | struct device; |
David Miller | d1cb9d1 | 2013-10-03 17:24:51 -0400 | [diff] [blame] | 22 | struct device_node; |
Sudeep Holla | 3d52943 | 2014-09-30 14:48:24 +0100 | [diff] [blame] | 23 | struct attribute_group; |
Paul Gortmaker | 313162d | 2012-01-30 11:46:54 -0500 | [diff] [blame] | 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | struct cpu { |
| 26 | int node_id; /* The node which contains the CPU */ |
Siddha, Suresh B | 72486f1 | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 27 | int hotpluggable; /* creates sysfs control file if hotpluggable */ |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 28 | struct device dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
Thomas Gleixner | cff7d37 | 2016-02-26 18:43:28 +0000 | [diff] [blame] | 31 | extern void boot_cpu_init(void); |
Linus Torvalds | 6bb53ee | 2018-08-12 12:19:42 -0700 | [diff] [blame] | 32 | extern void boot_cpu_hotplug_init(void); |
Thomas Gleixner | cff7d37 | 2016-02-26 18:43:28 +0000 | [diff] [blame] | 33 | |
KAMEZAWA Hiroyuki | 76b67ed9 | 2006-06-27 02:53:41 -0700 | [diff] [blame] | 34 | extern int register_cpu(struct cpu *cpu, int num); |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 35 | extern struct device *get_cpu_device(unsigned cpu); |
Josh Triplett | 2987557 | 2011-12-03 13:06:50 -0800 | [diff] [blame] | 36 | extern bool cpu_is_hotpluggable(unsigned cpu); |
Sudeep KarkadaNagesha | 183912d | 2013-08-15 14:01:40 +0100 | [diff] [blame] | 37 | extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id); |
David Miller | d1cb9d1 | 2013-10-03 17:24:51 -0400 | [diff] [blame] | 38 | extern bool arch_find_n_match_cpu_physical_id(struct device_node *cpun, |
| 39 | int cpu, unsigned int *thread); |
Christian Krafft | 0344c6c | 2006-10-24 18:31:24 +0200 | [diff] [blame] | 40 | |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 41 | extern int cpu_add_dev_attr(struct device_attribute *attr); |
| 42 | extern void cpu_remove_dev_attr(struct device_attribute *attr); |
Christian Krafft | 0344c6c | 2006-10-24 18:31:24 +0200 | [diff] [blame] | 43 | |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 44 | extern int cpu_add_dev_attr_group(struct attribute_group *attrs); |
| 45 | extern void cpu_remove_dev_attr_group(struct attribute_group *attrs); |
Christian Krafft | 0344c6c | 2006-10-24 18:31:24 +0200 | [diff] [blame] | 46 | |
Thomas Gleixner | 11ec2df | 2018-01-07 22:48:00 +0100 | [diff] [blame] | 47 | extern ssize_t cpu_show_meltdown(struct device *dev, |
| 48 | struct device_attribute *attr, char *buf); |
| 49 | extern ssize_t cpu_show_spectre_v1(struct device *dev, |
| 50 | struct device_attribute *attr, char *buf); |
| 51 | extern ssize_t cpu_show_spectre_v2(struct device *dev, |
| 52 | struct device_attribute *attr, char *buf); |
Konrad Rzeszutek Wilk | 24e4dd9 | 2018-04-25 22:04:20 -0400 | [diff] [blame] | 53 | extern ssize_t cpu_show_spec_store_bypass(struct device *dev, |
| 54 | struct device_attribute *attr, char *buf); |
Andi Kleen | 432e99b | 2018-06-13 15:48:26 -0700 | [diff] [blame] | 55 | extern ssize_t cpu_show_l1tf(struct device *dev, |
| 56 | struct device_attribute *attr, char *buf); |
Thomas Gleixner | ba08d56 | 2019-02-18 22:51:43 +0100 | [diff] [blame] | 57 | extern ssize_t cpu_show_mds(struct device *dev, |
| 58 | struct device_attribute *attr, char *buf); |
Pawan Gupta | 9392b2d | 2019-10-23 12:19:51 +0200 | [diff] [blame] | 59 | extern ssize_t cpu_show_tsx_async_abort(struct device *dev, |
| 60 | struct device_attribute *attr, |
| 61 | char *buf); |
Vineela Tummalapalli | 12ceedb | 2019-11-04 12:22:01 +0100 | [diff] [blame] | 62 | extern ssize_t cpu_show_itlb_multihit(struct device *dev, |
| 63 | struct device_attribute *attr, char *buf); |
Thomas Gleixner | 11ec2df | 2018-01-07 22:48:00 +0100 | [diff] [blame] | 64 | |
Nicolas Iooss | 8db1486 | 2015-07-17 16:23:42 -0700 | [diff] [blame] | 65 | extern __printf(4, 5) |
| 66 | struct device *cpu_device_create(struct device *parent, void *drvdata, |
| 67 | const struct attribute_group **groups, |
| 68 | const char *fmt, ...); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #ifdef CONFIG_HOTPLUG_CPU |
KAMEZAWA Hiroyuki | 76b67ed9 | 2006-06-27 02:53:41 -0700 | [diff] [blame] | 70 | extern void unregister_cpu(struct cpu *cpu); |
Nathan Fontenot | 12633e8 | 2009-11-25 17:23:25 +0000 | [diff] [blame] | 71 | extern ssize_t arch_cpu_probe(const char *, size_t); |
| 72 | extern ssize_t arch_cpu_release(const char *, size_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #endif |
| 74 | struct notifier_block; |
| 75 | |
Amerigo Wang | 80f1ff9 | 2011-07-25 17:13:08 -0700 | [diff] [blame] | 76 | #define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ |
| 77 | #define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ |
| 78 | #define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ |
| 79 | #define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ |
| 80 | #define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ |
| 81 | #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ |
Amerigo Wang | 80f1ff9 | 2011-07-25 17:13:08 -0700 | [diff] [blame] | 82 | #define CPU_POST_DEAD 0x0009 /* CPU (unsigned)v dead, cpu_hotplug |
| 83 | * lock is dropped */ |
Thomas Gleixner | 27d50c7 | 2016-02-26 18:43:44 +0000 | [diff] [blame] | 84 | #define CPU_BROKEN 0x000B /* CPU (unsigned)v did not die properly, |
Paul E. McKenney | 8038dad | 2015-02-25 10:34:39 -0800 | [diff] [blame] | 85 | * perhaps due to preemption. */ |
Amerigo Wang | 80f1ff9 | 2011-07-25 17:13:08 -0700 | [diff] [blame] | 86 | |
| 87 | /* Used for CPU hotplug events occurring while tasks are frozen due to a suspend |
| 88 | * operation in progress |
| 89 | */ |
| 90 | #define CPU_TASKS_FROZEN 0x0010 |
| 91 | |
| 92 | #define CPU_ONLINE_FROZEN (CPU_ONLINE | CPU_TASKS_FROZEN) |
| 93 | #define CPU_UP_PREPARE_FROZEN (CPU_UP_PREPARE | CPU_TASKS_FROZEN) |
| 94 | #define CPU_UP_CANCELED_FROZEN (CPU_UP_CANCELED | CPU_TASKS_FROZEN) |
| 95 | #define CPU_DOWN_PREPARE_FROZEN (CPU_DOWN_PREPARE | CPU_TASKS_FROZEN) |
| 96 | #define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN) |
| 97 | #define CPU_DEAD_FROZEN (CPU_DEAD | CPU_TASKS_FROZEN) |
Amerigo Wang | 80f1ff9 | 2011-07-25 17:13:08 -0700 | [diff] [blame] | 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | #ifdef CONFIG_SMP |
Thomas Gleixner | 090e77c | 2016-02-26 18:43:23 +0000 | [diff] [blame] | 100 | extern bool cpuhp_tasks_frozen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | /* Need to know about CPUs going up/down? */ |
Paul E. McKenney | 799e64f | 2009-08-15 09:53:47 -0700 | [diff] [blame] | 102 | #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) |
| 103 | #define cpu_notifier(fn, pri) { \ |
Paul Gortmaker | 0db0628 | 2013-06-19 14:53:51 -0400 | [diff] [blame] | 104 | static struct notifier_block fn##_nb = \ |
Paul E. McKenney | 799e64f | 2009-08-15 09:53:47 -0700 | [diff] [blame] | 105 | { .notifier_call = fn, .priority = pri }; \ |
| 106 | register_cpu_notifier(&fn##_nb); \ |
| 107 | } |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 108 | |
| 109 | #define __cpu_notifier(fn, pri) { \ |
| 110 | static struct notifier_block fn##_nb = \ |
| 111 | { .notifier_call = fn, .priority = pri }; \ |
| 112 | __register_cpu_notifier(&fn##_nb); \ |
| 113 | } |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 114 | |
Avi Kivity | 47e627b | 2007-02-12 00:54:43 -0800 | [diff] [blame] | 115 | extern int register_cpu_notifier(struct notifier_block *nb); |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 116 | extern int __register_cpu_notifier(struct notifier_block *nb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | extern void unregister_cpu_notifier(struct notifier_block *nb); |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 118 | extern void __unregister_cpu_notifier(struct notifier_block *nb); |
Avi Kivity | 47e627b | 2007-02-12 00:54:43 -0800 | [diff] [blame] | 119 | |
Michal Hocko | 56eaecc | 2016-12-07 14:54:38 +0100 | [diff] [blame] | 120 | #else /* #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */ |
| 121 | #define cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
| 122 | #define __cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
| 123 | |
Avi Kivity | 47e627b | 2007-02-12 00:54:43 -0800 | [diff] [blame] | 124 | static inline int register_cpu_notifier(struct notifier_block *nb) |
| 125 | { |
| 126 | return 0; |
| 127 | } |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 128 | |
| 129 | static inline int __register_cpu_notifier(struct notifier_block *nb) |
| 130 | { |
| 131 | return 0; |
| 132 | } |
Avi Kivity | 47e627b | 2007-02-12 00:54:43 -0800 | [diff] [blame] | 133 | |
Chandra Seetharaman | 65edc68 | 2006-06-27 02:54:08 -0700 | [diff] [blame] | 134 | static inline void unregister_cpu_notifier(struct notifier_block *nb) |
| 135 | { |
| 136 | } |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 137 | |
| 138 | static inline void __unregister_cpu_notifier(struct notifier_block *nb) |
| 139 | { |
| 140 | } |
Chandra Seetharaman | 65edc68 | 2006-06-27 02:54:08 -0700 | [diff] [blame] | 141 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | int cpu_up(unsigned int cpu); |
Manfred Spraul | e545a61 | 2008-09-07 16:57:22 +0200 | [diff] [blame] | 144 | void notify_cpu_starting(unsigned int cpu); |
Oleg Nesterov | 3da1c84 | 2008-07-25 01:47:50 -0700 | [diff] [blame] | 145 | extern void cpu_maps_update_begin(void); |
| 146 | extern void cpu_maps_update_done(void); |
Ingo Molnar | d0d23b5 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 147 | |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 148 | #define cpu_notifier_register_begin cpu_maps_update_begin |
| 149 | #define cpu_notifier_register_done cpu_maps_update_done |
| 150 | |
Oleg Nesterov | 3da1c84 | 2008-07-25 01:47:50 -0700 | [diff] [blame] | 151 | #else /* CONFIG_SMP */ |
Thomas Gleixner | 090e77c | 2016-02-26 18:43:23 +0000 | [diff] [blame] | 152 | #define cpuhp_tasks_frozen 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Paul E. McKenney | 799e64f | 2009-08-15 09:53:47 -0700 | [diff] [blame] | 154 | #define cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 155 | #define __cpu_notifier(fn, pri) do { (void)(fn); } while (0) |
Paul E. McKenney | 799e64f | 2009-08-15 09:53:47 -0700 | [diff] [blame] | 156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | static inline int register_cpu_notifier(struct notifier_block *nb) |
| 158 | { |
| 159 | return 0; |
| 160 | } |
Ingo Molnar | d0d23b5 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 161 | |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 162 | static inline int __register_cpu_notifier(struct notifier_block *nb) |
| 163 | { |
| 164 | return 0; |
| 165 | } |
| 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | static inline void unregister_cpu_notifier(struct notifier_block *nb) |
| 168 | { |
| 169 | } |
| 170 | |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 171 | static inline void __unregister_cpu_notifier(struct notifier_block *nb) |
| 172 | { |
| 173 | } |
| 174 | |
Oleg Nesterov | 3da1c84 | 2008-07-25 01:47:50 -0700 | [diff] [blame] | 175 | static inline void cpu_maps_update_begin(void) |
| 176 | { |
| 177 | } |
| 178 | |
| 179 | static inline void cpu_maps_update_done(void) |
| 180 | { |
| 181 | } |
| 182 | |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 183 | static inline void cpu_notifier_register_begin(void) |
| 184 | { |
| 185 | } |
| 186 | |
| 187 | static inline void cpu_notifier_register_done(void) |
| 188 | { |
| 189 | } |
| 190 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | #endif /* CONFIG_SMP */ |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 192 | extern struct bus_type cpu_subsys; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
| 194 | #ifdef CONFIG_HOTPLUG_CPU |
| 195 | /* Stop CPUs going up and down. */ |
Gautham R Shenoy | f7dff2b | 2006-12-06 20:38:58 -0800 | [diff] [blame] | 196 | |
Toshi Kani | b9d10be | 2013-08-12 09:45:53 -0600 | [diff] [blame] | 197 | extern void cpu_hotplug_begin(void); |
| 198 | extern void cpu_hotplug_done(void); |
Gautham R Shenoy | 86ef5c9 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 199 | extern void get_online_cpus(void); |
Prateek Sood | e9e7b75 | 2017-09-08 13:10:55 +0530 | [diff] [blame] | 200 | extern void cpu_hotplug_mutex_held(void); |
Gautham R Shenoy | 86ef5c9 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 201 | extern void put_online_cpus(void); |
Srivatsa S. Bhat | 16e53db | 2013-06-12 14:04:36 -0700 | [diff] [blame] | 202 | extern void cpu_hotplug_disable(void); |
| 203 | extern void cpu_hotplug_enable(void); |
Paul E. McKenney | 799e64f | 2009-08-15 09:53:47 -0700 | [diff] [blame] | 204 | #define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri) |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 205 | #define __hotcpu_notifier(fn, pri) __cpu_notifier(fn, pri) |
Chandra Seetharaman | 39f4885 | 2006-06-27 02:54:10 -0700 | [diff] [blame] | 206 | #define register_hotcpu_notifier(nb) register_cpu_notifier(nb) |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 207 | #define __register_hotcpu_notifier(nb) __register_cpu_notifier(nb) |
Chandra Seetharaman | 39f4885 | 2006-06-27 02:54:10 -0700 | [diff] [blame] | 208 | #define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 209 | #define __unregister_hotcpu_notifier(nb) __unregister_cpu_notifier(nb) |
Anton Vorontsov | cb79295 | 2012-05-31 16:26:22 -0700 | [diff] [blame] | 210 | void clear_tasks_mm_cpumask(int cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | int cpu_down(unsigned int cpu); |
Gautham R Shenoy | f7dff2b | 2006-12-06 20:38:58 -0800 | [diff] [blame] | 212 | |
| 213 | #else /* CONFIG_HOTPLUG_CPU */ |
| 214 | |
Toshi Kani | b9d10be | 2013-08-12 09:45:53 -0600 | [diff] [blame] | 215 | static inline void cpu_hotplug_begin(void) {} |
| 216 | static inline void cpu_hotplug_done(void) {} |
Gautham R Shenoy | 86ef5c9 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 217 | #define get_online_cpus() do { } while (0) |
| 218 | #define put_online_cpus() do { } while (0) |
Srivatsa S. Bhat | 16e53db | 2013-06-12 14:04:36 -0700 | [diff] [blame] | 219 | #define cpu_hotplug_disable() do { } while (0) |
| 220 | #define cpu_hotplug_enable() do { } while (0) |
Ingo Molnar | 02316067 | 2006-12-06 20:38:17 -0800 | [diff] [blame] | 221 | #define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 222 | #define __hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) |
Prateek Sood | e9e7b75 | 2017-09-08 13:10:55 +0530 | [diff] [blame] | 223 | #define cpu_hotplug_mutex_held() do { } while (0) |
Satyam Sharma | 761bb43 | 2007-10-18 03:06:38 -0700 | [diff] [blame] | 224 | /* These aren't inline functions due to a GCC bug. */ |
| 225 | #define register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 226 | #define __register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) |
Satyam Sharma | 761bb43 | 2007-10-18 03:06:38 -0700 | [diff] [blame] | 227 | #define unregister_hotcpu_notifier(nb) ({ (void)(nb); }) |
Srivatsa S. Bhat | 93ae4f9 | 2014-03-11 02:04:14 +0530 | [diff] [blame] | 228 | #define __unregister_hotcpu_notifier(nb) ({ (void)(nb); }) |
Gautham R Shenoy | f7dff2b | 2006-12-06 20:38:58 -0800 | [diff] [blame] | 229 | #endif /* CONFIG_HOTPLUG_CPU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
Rafael J. Wysocki | f3de4be | 2007-08-30 23:56:29 -0700 | [diff] [blame] | 231 | #ifdef CONFIG_PM_SLEEP_SMP |
James Morse | d391e55 | 2016-08-17 13:50:25 +0100 | [diff] [blame] | 232 | extern int freeze_secondary_cpus(int primary); |
| 233 | static inline int disable_nonboot_cpus(void) |
| 234 | { |
| 235 | return freeze_secondary_cpus(0); |
| 236 | } |
Rafael J. Wysocki | e3920fb | 2006-09-25 23:32:48 -0700 | [diff] [blame] | 237 | extern void enable_nonboot_cpus(void); |
Rafael J. Wysocki | f3de4be | 2007-08-30 23:56:29 -0700 | [diff] [blame] | 238 | #else /* !CONFIG_PM_SLEEP_SMP */ |
Rafael J. Wysocki | e3920fb | 2006-09-25 23:32:48 -0700 | [diff] [blame] | 239 | static inline int disable_nonboot_cpus(void) { return 0; } |
| 240 | static inline void enable_nonboot_cpus(void) {} |
Rafael J. Wysocki | f3de4be | 2007-08-30 23:56:29 -0700 | [diff] [blame] | 241 | #endif /* !CONFIG_PM_SLEEP_SMP */ |
Rafael J. Wysocki | e3920fb | 2006-09-25 23:32:48 -0700 | [diff] [blame] | 242 | |
Thomas Gleixner | a1a04ec | 2013-03-21 22:49:34 +0100 | [diff] [blame] | 243 | void cpu_startup_entry(enum cpuhp_state state); |
Thomas Gleixner | a1a04ec | 2013-03-21 22:49:34 +0100 | [diff] [blame] | 244 | |
Thomas Gleixner | d166991 | 2013-03-21 22:49:35 +0100 | [diff] [blame] | 245 | void cpu_idle_poll_ctrl(bool enable); |
| 246 | |
Chris Metcalf | 6727ad9 | 2016-10-07 17:02:55 -0700 | [diff] [blame] | 247 | /* Attach to any functions which should be considered cpuidle. */ |
| 248 | #define __cpuidle __attribute__((__section__(".cpuidle.text"))) |
| 249 | |
| 250 | bool cpu_in_idle(unsigned long pc); |
| 251 | |
Thomas Gleixner | d166991 | 2013-03-21 22:49:35 +0100 | [diff] [blame] | 252 | void arch_cpu_idle(void); |
| 253 | void arch_cpu_idle_prepare(void); |
| 254 | void arch_cpu_idle_enter(void); |
| 255 | void arch_cpu_idle_exit(void); |
| 256 | void arch_cpu_idle_dead(void); |
| 257 | |
Paul E. McKenney | 8038dad | 2015-02-25 10:34:39 -0800 | [diff] [blame] | 258 | int cpu_report_state(int cpu); |
| 259 | int cpu_check_up_prepare(int cpu); |
| 260 | void cpu_set_state_online(int cpu); |
| 261 | #ifdef CONFIG_HOTPLUG_CPU |
| 262 | bool cpu_wait_death(unsigned int cpu, int seconds); |
| 263 | bool cpu_report_death(void); |
Thomas Gleixner | e69aab1 | 2016-02-26 18:43:43 +0000 | [diff] [blame] | 264 | void cpuhp_report_idle_dead(void); |
| 265 | #else |
| 266 | static inline void cpuhp_report_idle_dead(void) { } |
Paul E. McKenney | 8038dad | 2015-02-25 10:34:39 -0800 | [diff] [blame] | 267 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
| 268 | |
Thomas Gleixner | f37486c | 2018-05-29 17:48:27 +0200 | [diff] [blame] | 269 | enum cpuhp_smt_control { |
| 270 | CPU_SMT_ENABLED, |
| 271 | CPU_SMT_DISABLED, |
| 272 | CPU_SMT_FORCE_DISABLED, |
| 273 | CPU_SMT_NOT_SUPPORTED, |
| 274 | }; |
| 275 | |
| 276 | #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT) |
| 277 | extern enum cpuhp_smt_control cpu_smt_control; |
Jiri Kosina | a69c5e0 | 2018-07-13 16:23:23 +0200 | [diff] [blame] | 278 | extern void cpu_smt_disable(bool force); |
Thomas Gleixner | c504b9f | 2018-08-07 08:19:57 +0200 | [diff] [blame] | 279 | extern void cpu_smt_check_topology_early(void); |
Thomas Gleixner | 929d3b2 | 2018-07-13 16:23:24 +0200 | [diff] [blame] | 280 | extern void cpu_smt_check_topology(void); |
Jiri Kosina | 5bdc536 | 2019-05-30 00:09:39 +0200 | [diff] [blame] | 281 | extern int cpuhp_smt_enable(void); |
| 282 | extern int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval); |
Thomas Gleixner | f37486c | 2018-05-29 17:48:27 +0200 | [diff] [blame] | 283 | #else |
| 284 | # define cpu_smt_control (CPU_SMT_ENABLED) |
Jiri Kosina | a69c5e0 | 2018-07-13 16:23:23 +0200 | [diff] [blame] | 285 | static inline void cpu_smt_disable(bool force) { } |
Thomas Gleixner | c504b9f | 2018-08-07 08:19:57 +0200 | [diff] [blame] | 286 | static inline void cpu_smt_check_topology_early(void) { } |
Thomas Gleixner | 929d3b2 | 2018-07-13 16:23:24 +0200 | [diff] [blame] | 287 | static inline void cpu_smt_check_topology(void) { } |
Jiri Kosina | 5bdc536 | 2019-05-30 00:09:39 +0200 | [diff] [blame] | 288 | static inline int cpuhp_smt_enable(void) { return 0; } |
| 289 | static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; } |
Thomas Gleixner | f37486c | 2018-05-29 17:48:27 +0200 | [diff] [blame] | 290 | #endif |
| 291 | |
Tyler Hicks | e2bd077 | 2019-11-04 12:22:02 +0100 | [diff] [blame] | 292 | extern bool cpu_mitigations_off(void); |
| 293 | extern bool cpu_mitigations_auto_nosmt(void); |
Josh Poimboeuf | edda9c3 | 2019-04-12 15:39:28 -0500 | [diff] [blame] | 294 | |
Todd Poynor | ef07e9e4 | 2011-06-15 17:21:57 -0700 | [diff] [blame] | 295 | #define IDLE_START 1 |
| 296 | #define IDLE_END 2 |
| 297 | |
| 298 | void idle_notifier_register(struct notifier_block *n); |
| 299 | void idle_notifier_unregister(struct notifier_block *n); |
| 300 | void idle_notifier_call_chain(unsigned long val); |
| 301 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | #endif /* _LINUX_CPU_H_ */ |