Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/s390/kernel/smp.c |
| 3 | * |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 4 | * Copyright (C) IBM Corp. 1999,2006 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), |
| 6 | * Martin Schwidefsky (schwidefsky@de.ibm.com) |
| 7 | * Heiko Carstens (heiko.carstens@de.ibm.com) |
| 8 | * |
| 9 | * based on other smp stuff by |
| 10 | * (c) 1995 Alan Cox, CymruNET Ltd <alan@cymru.net> |
| 11 | * (c) 1998 Ingo Molnar |
| 12 | * |
| 13 | * We work with logical cpu numbering everywhere we can. The only |
| 14 | * functions using the real cpu address (got from STAP) are the sigp |
| 15 | * functions. For all other functions we use the identity mapping. |
| 16 | * That means that cpu_number_map[i] == i for every cpu. cpu_number_map is |
| 17 | * used e.g. to find the idle task belonging to a logical cpu. Every array |
| 18 | * in the kernel is sorted by the logical cpu number and not by the physical |
| 19 | * one which is causing all the confusion with __cpu_logical_map and |
| 20 | * cpu_number_map in other architectures. |
| 21 | */ |
| 22 | |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/mm.h> |
| 26 | #include <linux/spinlock.h> |
| 27 | #include <linux/kernel_stat.h> |
| 28 | #include <linux/smp_lock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/delay.h> |
| 30 | #include <linux/cache.h> |
| 31 | #include <linux/interrupt.h> |
| 32 | #include <linux/cpu.h> |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 33 | #include <linux/timex.h> |
| 34 | #include <asm/setup.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <asm/sigp.h> |
| 36 | #include <asm/pgalloc.h> |
| 37 | #include <asm/irq.h> |
| 38 | #include <asm/s390_ext.h> |
| 39 | #include <asm/cpcmd.h> |
| 40 | #include <asm/tlbflush.h> |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 41 | #include <asm/timer.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | extern volatile int __cpu_logical_map[]; |
| 44 | |
| 45 | /* |
| 46 | * An array with a pointer the lowcore of every CPU. |
| 47 | */ |
| 48 | |
| 49 | struct _lowcore *lowcore_ptr[NR_CPUS]; |
| 50 | |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 51 | cpumask_t cpu_online_map = CPU_MASK_NONE; |
| 52 | cpumask_t cpu_possible_map = CPU_MASK_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | static struct task_struct *current_set[NR_CPUS]; |
| 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | static void smp_ext_bitcall(int, ec_bit_sig); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | /* |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 59 | * Structure and data for __smp_call_function_map(). This is designed to |
| 60 | * minimise static memory requirements. It also looks cleaner. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | */ |
| 62 | static DEFINE_SPINLOCK(call_lock); |
| 63 | |
| 64 | struct call_data_struct { |
| 65 | void (*func) (void *info); |
| 66 | void *info; |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 67 | cpumask_t started; |
| 68 | cpumask_t finished; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | int wait; |
| 70 | }; |
| 71 | |
| 72 | static struct call_data_struct * call_data; |
| 73 | |
| 74 | /* |
| 75 | * 'Call function' interrupt callback |
| 76 | */ |
| 77 | static void do_call_function(void) |
| 78 | { |
| 79 | void (*func) (void *info) = call_data->func; |
| 80 | void *info = call_data->info; |
| 81 | int wait = call_data->wait; |
| 82 | |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 83 | cpu_set(smp_processor_id(), call_data->started); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | (*func)(info); |
| 85 | if (wait) |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 86 | cpu_set(smp_processor_id(), call_data->finished);; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 89 | static void __smp_call_function_map(void (*func) (void *info), void *info, |
| 90 | int nonatomic, int wait, cpumask_t map) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | { |
| 92 | struct call_data_struct data; |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 93 | int cpu, local = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 95 | /* |
| 96 | * Can deadlock when interrupts are disabled or if in wrong context, |
| 97 | * caller must disable preemption |
| 98 | */ |
| 99 | WARN_ON(irqs_disabled() || in_irq() || preemptible()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 101 | /* |
| 102 | * Check for local function call. We have to have the same call order |
| 103 | * as in on_each_cpu() because of machine_restart_smp(). |
| 104 | */ |
| 105 | if (cpu_isset(smp_processor_id(), map)) { |
| 106 | local = 1; |
| 107 | cpu_clear(smp_processor_id(), map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 110 | cpus_and(map, map, cpu_online_map); |
| 111 | if (cpus_empty(map)) |
| 112 | goto out; |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | data.func = func; |
| 115 | data.info = info; |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 116 | data.started = CPU_MASK_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | data.wait = wait; |
| 118 | if (wait) |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 119 | data.finished = CPU_MASK_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | spin_lock_bh(&call_lock); |
| 122 | call_data = &data; |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 123 | |
| 124 | for_each_cpu_mask(cpu, map) |
| 125 | smp_ext_bitcall(cpu, ec_call_function); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | /* Wait for response */ |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 128 | while (!cpus_equal(map, data.started)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | cpu_relax(); |
| 130 | |
| 131 | if (wait) |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 132 | while (!cpus_equal(map, data.finished)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | cpu_relax(); |
| 134 | |
| 135 | spin_unlock_bh(&call_lock); |
Jan Glauber | 63db6e8 | 2007-02-21 10:55:06 +0100 | [diff] [blame^] | 136 | |
| 137 | out: |
| 138 | local_irq_disable(); |
| 139 | if (local) |
| 140 | func(info); |
| 141 | local_irq_enable(); |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | * smp_call_function: |
| 146 | * @func: the function to run; this must be fast and non-blocking |
| 147 | * @info: an arbitrary pointer to pass to the function |
| 148 | * @nonatomic: unused |
| 149 | * @wait: if true, wait (atomically) until function has completed on other CPUs |
| 150 | * |
| 151 | * Run a function on all other CPUs. |
| 152 | * |
| 153 | * You must not call this function with disabled interrupts or from a |
| 154 | * hardware interrupt handler. Must be called with preemption disabled. |
| 155 | * You may call it from a bottom half. |
| 156 | */ |
| 157 | int smp_call_function(void (*func) (void *info), void *info, int nonatomic, |
| 158 | int wait) |
| 159 | { |
| 160 | cpumask_t map; |
| 161 | |
| 162 | map = cpu_online_map; |
| 163 | cpu_clear(smp_processor_id(), map); |
| 164 | __smp_call_function_map(func, info, nonatomic, wait, map); |
| 165 | return 0; |
| 166 | } |
| 167 | EXPORT_SYMBOL(smp_call_function); |
| 168 | |
| 169 | /* |
| 170 | * smp_call_function_on: |
| 171 | * @func: the function to run; this must be fast and non-blocking |
| 172 | * @info: an arbitrary pointer to pass to the function |
| 173 | * @nonatomic: unused |
| 174 | * @wait: if true, wait (atomically) until function has completed on other CPUs |
| 175 | * @cpu: the CPU where func should run |
| 176 | * |
| 177 | * Run a function on one processor. |
| 178 | * |
| 179 | * You must not call this function with disabled interrupts or from a |
| 180 | * hardware interrupt handler. Must be called with preemption disabled. |
| 181 | * You may call it from a bottom half. |
| 182 | */ |
| 183 | int smp_call_function_on(void (*func) (void *info), void *info, int nonatomic, |
| 184 | int wait, int cpu) |
| 185 | { |
| 186 | cpumask_t map = CPU_MASK_NONE; |
| 187 | |
| 188 | cpu_set(cpu, map); |
| 189 | __smp_call_function_map(func, info, nonatomic, wait, map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | return 0; |
| 191 | } |
| 192 | EXPORT_SYMBOL(smp_call_function_on); |
| 193 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 194 | static void do_send_stop(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | { |
| 196 | int cpu, rc; |
| 197 | |
| 198 | /* stop all processors */ |
| 199 | for_each_online_cpu(cpu) { |
| 200 | if (cpu == smp_processor_id()) |
| 201 | continue; |
| 202 | do { |
| 203 | rc = signal_processor(cpu, sigp_stop); |
| 204 | } while (rc == sigp_busy); |
| 205 | } |
| 206 | } |
| 207 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 208 | static void do_store_status(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | { |
| 210 | int cpu, rc; |
| 211 | |
| 212 | /* store status of all processors in their lowcores (real 0) */ |
| 213 | for_each_online_cpu(cpu) { |
| 214 | if (cpu == smp_processor_id()) |
| 215 | continue; |
| 216 | do { |
| 217 | rc = signal_processor_p( |
| 218 | (__u32)(unsigned long) lowcore_ptr[cpu], cpu, |
| 219 | sigp_store_status_at_address); |
| 220 | } while(rc == sigp_busy); |
| 221 | } |
| 222 | } |
| 223 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 224 | static void do_wait_for_stop(void) |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 225 | { |
| 226 | int cpu; |
| 227 | |
| 228 | /* Wait for all other cpus to enter stopped state */ |
| 229 | for_each_online_cpu(cpu) { |
| 230 | if (cpu == smp_processor_id()) |
| 231 | continue; |
| 232 | while(!smp_cpu_not_running(cpu)) |
| 233 | cpu_relax(); |
| 234 | } |
| 235 | } |
| 236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | /* |
| 238 | * this function sends a 'stop' sigp to all other CPUs in the system. |
| 239 | * it goes straight through. |
| 240 | */ |
| 241 | void smp_send_stop(void) |
| 242 | { |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 243 | /* Disable all interrupts/machine checks */ |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 244 | __load_psw_mask(psw_kernel_bits & ~PSW_MASK_MCHECK); |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 245 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | /* write magic number to zero page (absolute 0) */ |
| 247 | lowcore_ptr[smp_processor_id()]->panic_magic = __PANIC_MAGIC; |
| 248 | |
| 249 | /* stop other processors. */ |
| 250 | do_send_stop(); |
| 251 | |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 252 | /* wait until other processors are stopped */ |
| 253 | do_wait_for_stop(); |
| 254 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | /* store status of other processors. */ |
| 256 | do_store_status(); |
| 257 | } |
| 258 | |
| 259 | /* |
| 260 | * Reboot, halt and power_off routines for SMP. |
| 261 | */ |
| 262 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | void machine_restart_smp(char * __unused) |
| 264 | { |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 265 | smp_send_stop(); |
| 266 | do_reipl(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | void machine_halt_smp(void) |
| 270 | { |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 271 | smp_send_stop(); |
| 272 | if (MACHINE_IS_VM && strlen(vmhalt_cmd) > 0) |
| 273 | __cpcmd(vmhalt_cmd, NULL, 0, NULL); |
| 274 | signal_processor(smp_processor_id(), sigp_stop_and_store_status); |
| 275 | for (;;); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | void machine_power_off_smp(void) |
| 279 | { |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 280 | smp_send_stop(); |
| 281 | if (MACHINE_IS_VM && strlen(vmpoff_cmd) > 0) |
| 282 | __cpcmd(vmpoff_cmd, NULL, 0, NULL); |
| 283 | signal_processor(smp_processor_id(), sigp_stop_and_store_status); |
| 284 | for (;;); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | /* |
| 288 | * This is the main routine where commands issued by other |
| 289 | * cpus are handled. |
| 290 | */ |
| 291 | |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 292 | static void do_ext_call_interrupt(__u16 code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | { |
| 294 | unsigned long bits; |
| 295 | |
| 296 | /* |
| 297 | * handle bit signal external calls |
| 298 | * |
| 299 | * For the ec_schedule signal we have to do nothing. All the work |
| 300 | * is done automatically when we return from the interrupt. |
| 301 | */ |
| 302 | bits = xchg(&S390_lowcore.ext_call_fast, 0); |
| 303 | |
| 304 | if (test_bit(ec_call_function, &bits)) |
| 305 | do_call_function(); |
| 306 | } |
| 307 | |
| 308 | /* |
| 309 | * Send an external call sigp to another cpu and return without waiting |
| 310 | * for its completion. |
| 311 | */ |
| 312 | static void smp_ext_bitcall(int cpu, ec_bit_sig sig) |
| 313 | { |
| 314 | /* |
| 315 | * Set signaling bit in lowcore of target cpu and kick it |
| 316 | */ |
| 317 | set_bit(sig, (unsigned long *) &lowcore_ptr[cpu]->ext_call_fast); |
Heiko Carstens | 99b2d8d | 2005-07-27 11:45:00 -0700 | [diff] [blame] | 318 | while(signal_processor(cpu, sigp_emergency_signal) == sigp_busy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | udelay(10); |
| 320 | } |
| 321 | |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 322 | #ifndef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | /* |
| 324 | * this function sends a 'purge tlb' signal to another CPU. |
| 325 | */ |
| 326 | void smp_ptlb_callback(void *info) |
| 327 | { |
| 328 | local_flush_tlb(); |
| 329 | } |
| 330 | |
| 331 | void smp_ptlb_all(void) |
| 332 | { |
| 333 | on_each_cpu(smp_ptlb_callback, NULL, 0, 1); |
| 334 | } |
| 335 | EXPORT_SYMBOL(smp_ptlb_all); |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 336 | #endif /* ! CONFIG_64BIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
| 338 | /* |
| 339 | * this function sends a 'reschedule' IPI to another CPU. |
| 340 | * it goes straight through and wastes no time serializing |
| 341 | * anything. Worst case is that we lose a reschedule ... |
| 342 | */ |
| 343 | void smp_send_reschedule(int cpu) |
| 344 | { |
| 345 | smp_ext_bitcall(cpu, ec_schedule); |
| 346 | } |
| 347 | |
| 348 | /* |
| 349 | * parameter area for the set/clear control bit callbacks |
| 350 | */ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 351 | struct ec_creg_mask_parms { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | unsigned long orvals[16]; |
| 353 | unsigned long andvals[16]; |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 354 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * callback for setting/clearing control bits |
| 358 | */ |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 359 | static void smp_ctl_bit_callback(void *info) { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 360 | struct ec_creg_mask_parms *pp = info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | unsigned long cregs[16]; |
| 362 | int i; |
| 363 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 364 | __ctl_store(cregs, 0, 15); |
| 365 | for (i = 0; i <= 15; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | cregs[i] = (cregs[i] & pp->andvals[i]) | pp->orvals[i]; |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 367 | __ctl_load(cregs, 0, 15); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | /* |
| 371 | * Set a bit in a control register of all cpus |
| 372 | */ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 373 | void smp_ctl_set_bit(int cr, int bit) |
| 374 | { |
| 375 | struct ec_creg_mask_parms parms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 377 | memset(&parms.orvals, 0, sizeof(parms.orvals)); |
| 378 | memset(&parms.andvals, 0xff, sizeof(parms.andvals)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | parms.orvals[cr] = 1 << bit; |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 380 | on_each_cpu(smp_ctl_bit_callback, &parms, 0, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | /* |
| 384 | * Clear a bit in a control register of all cpus |
| 385 | */ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 386 | void smp_ctl_clear_bit(int cr, int bit) |
| 387 | { |
| 388 | struct ec_creg_mask_parms parms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 390 | memset(&parms.orvals, 0, sizeof(parms.orvals)); |
| 391 | memset(&parms.andvals, 0xff, sizeof(parms.andvals)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | parms.andvals[cr] = ~(1L << bit); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 393 | on_each_cpu(smp_ctl_bit_callback, &parms, 0, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | /* |
| 397 | * Lets check how many CPUs we have. |
| 398 | */ |
| 399 | |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 400 | static unsigned int |
| 401 | __init smp_count_cpus(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | { |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 403 | unsigned int cpu, num_cpus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | __u16 boot_cpu_addr; |
| 405 | |
| 406 | /* |
| 407 | * cpu 0 is the boot cpu. See smp_prepare_boot_cpu. |
| 408 | */ |
| 409 | |
| 410 | boot_cpu_addr = S390_lowcore.cpu_data.cpu_addr; |
| 411 | current_thread_info()->cpu = 0; |
| 412 | num_cpus = 1; |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 413 | for (cpu = 0; cpu <= 65535; cpu++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | if ((__u16) cpu == boot_cpu_addr) |
| 415 | continue; |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 416 | __cpu_logical_map[1] = (__u16) cpu; |
| 417 | if (signal_processor(1, sigp_sense) == |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | sigp_not_operational) |
| 419 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | num_cpus++; |
| 421 | } |
| 422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | printk("Detected %d CPU's\n",(int) num_cpus); |
| 424 | printk("Boot cpu address %2X\n", boot_cpu_addr); |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 425 | |
| 426 | return num_cpus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | /* |
| 430 | * Activate a secondary processor. |
| 431 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | int __devinit start_secondary(void *cpuvoid) |
| 433 | { |
| 434 | /* Setup the cpu */ |
| 435 | cpu_init(); |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 436 | preempt_disable(); |
Martin Schwidefsky | d54853e | 2007-02-05 21:18:19 +0100 | [diff] [blame] | 437 | /* Enable TOD clock interrupts on the secondary cpu. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | init_cpu_timer(); |
| 439 | #ifdef CONFIG_VIRT_TIMER |
Martin Schwidefsky | d54853e | 2007-02-05 21:18:19 +0100 | [diff] [blame] | 440 | /* Enable cpu timer interrupts on the secondary cpu. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | init_cpu_vtimer(); |
| 442 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | /* Enable pfault pseudo page faults on this cpu. */ |
Heiko Carstens | 29b08d2 | 2006-12-04 15:40:40 +0100 | [diff] [blame] | 444 | pfault_init(); |
| 445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | /* Mark this cpu as online */ |
| 447 | cpu_set(smp_processor_id(), cpu_online_map); |
| 448 | /* Switch on interrupts */ |
| 449 | local_irq_enable(); |
| 450 | /* Print info about this processor */ |
| 451 | print_cpu_info(&S390_lowcore.cpu_data); |
| 452 | /* cpu_idle will call schedule for us */ |
| 453 | cpu_idle(); |
| 454 | return 0; |
| 455 | } |
| 456 | |
| 457 | static void __init smp_create_idle(unsigned int cpu) |
| 458 | { |
| 459 | struct task_struct *p; |
| 460 | |
| 461 | /* |
| 462 | * don't care about the psw and regs settings since we'll never |
| 463 | * reschedule the forked task. |
| 464 | */ |
| 465 | p = fork_idle(cpu); |
| 466 | if (IS_ERR(p)) |
| 467 | panic("failed fork for CPU %u: %li", cpu, PTR_ERR(p)); |
| 468 | current_set[cpu] = p; |
| 469 | } |
| 470 | |
| 471 | /* Reserving and releasing of CPUs */ |
| 472 | |
| 473 | static DEFINE_SPINLOCK(smp_reserve_lock); |
| 474 | static int smp_cpu_reserved[NR_CPUS]; |
| 475 | |
| 476 | int |
| 477 | smp_get_cpu(cpumask_t cpu_mask) |
| 478 | { |
| 479 | unsigned long flags; |
| 480 | int cpu; |
| 481 | |
| 482 | spin_lock_irqsave(&smp_reserve_lock, flags); |
| 483 | /* Try to find an already reserved cpu. */ |
| 484 | for_each_cpu_mask(cpu, cpu_mask) { |
| 485 | if (smp_cpu_reserved[cpu] != 0) { |
| 486 | smp_cpu_reserved[cpu]++; |
| 487 | /* Found one. */ |
| 488 | goto out; |
| 489 | } |
| 490 | } |
| 491 | /* Reserve a new cpu from cpu_mask. */ |
| 492 | for_each_cpu_mask(cpu, cpu_mask) { |
| 493 | if (cpu_online(cpu)) { |
| 494 | smp_cpu_reserved[cpu]++; |
| 495 | goto out; |
| 496 | } |
| 497 | } |
| 498 | cpu = -ENODEV; |
| 499 | out: |
| 500 | spin_unlock_irqrestore(&smp_reserve_lock, flags); |
| 501 | return cpu; |
| 502 | } |
| 503 | |
| 504 | void |
| 505 | smp_put_cpu(int cpu) |
| 506 | { |
| 507 | unsigned long flags; |
| 508 | |
| 509 | spin_lock_irqsave(&smp_reserve_lock, flags); |
| 510 | smp_cpu_reserved[cpu]--; |
| 511 | spin_unlock_irqrestore(&smp_reserve_lock, flags); |
| 512 | } |
| 513 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 514 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | cpu_stopped(int cpu) |
| 516 | { |
| 517 | __u32 status; |
| 518 | |
| 519 | /* Check for stopped state */ |
| 520 | if (signal_processor_ps(&status, 0, cpu, sigp_sense) == sigp_status_stored) { |
| 521 | if (status & 0x40) |
| 522 | return 1; |
| 523 | } |
| 524 | return 0; |
| 525 | } |
| 526 | |
| 527 | /* Upping and downing of CPUs */ |
| 528 | |
| 529 | int |
| 530 | __cpu_up(unsigned int cpu) |
| 531 | { |
| 532 | struct task_struct *idle; |
| 533 | struct _lowcore *cpu_lowcore; |
| 534 | struct stack_frame *sf; |
| 535 | sigp_ccode ccode; |
| 536 | int curr_cpu; |
| 537 | |
| 538 | for (curr_cpu = 0; curr_cpu <= 65535; curr_cpu++) { |
| 539 | __cpu_logical_map[cpu] = (__u16) curr_cpu; |
| 540 | if (cpu_stopped(cpu)) |
| 541 | break; |
| 542 | } |
| 543 | |
| 544 | if (!cpu_stopped(cpu)) |
| 545 | return -ENODEV; |
| 546 | |
| 547 | ccode = signal_processor_p((__u32)(unsigned long)(lowcore_ptr[cpu]), |
| 548 | cpu, sigp_set_prefix); |
| 549 | if (ccode){ |
| 550 | printk("sigp_set_prefix failed for cpu %d " |
| 551 | "with condition code %d\n", |
| 552 | (int) cpu, (int) ccode); |
| 553 | return -EIO; |
| 554 | } |
| 555 | |
| 556 | idle = current_set[cpu]; |
| 557 | cpu_lowcore = lowcore_ptr[cpu]; |
| 558 | cpu_lowcore->kernel_stack = (unsigned long) |
Al Viro | 30af712 | 2006-01-12 01:05:50 -0800 | [diff] [blame] | 559 | task_stack_page(idle) + (THREAD_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | sf = (struct stack_frame *) (cpu_lowcore->kernel_stack |
| 561 | - sizeof(struct pt_regs) |
| 562 | - sizeof(struct stack_frame)); |
| 563 | memset(sf, 0, sizeof(struct stack_frame)); |
| 564 | sf->gprs[9] = (unsigned long) sf; |
| 565 | cpu_lowcore->save_area[15] = (unsigned long) sf; |
| 566 | __ctl_store(cpu_lowcore->cregs_save_area[0], 0, 15); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 567 | asm volatile( |
| 568 | " stam 0,15,0(%0)" |
| 569 | : : "a" (&cpu_lowcore->access_regs_save_area) : "memory"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | cpu_lowcore->percpu_offset = __per_cpu_offset[cpu]; |
| 571 | cpu_lowcore->current_task = (unsigned long) idle; |
| 572 | cpu_lowcore->cpu_data.cpu_nr = cpu; |
| 573 | eieio(); |
Michael Ryan | 699ff13 | 2006-03-24 03:15:17 -0800 | [diff] [blame] | 574 | |
| 575 | while (signal_processor(cpu,sigp_restart) == sigp_busy) |
| 576 | udelay(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
| 578 | while (!cpu_online(cpu)) |
| 579 | cpu_relax(); |
| 580 | return 0; |
| 581 | } |
| 582 | |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 583 | static unsigned int __initdata additional_cpus; |
Heiko Carstens | 37a3302 | 2006-02-17 13:52:47 -0800 | [diff] [blame] | 584 | static unsigned int __initdata possible_cpus; |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 585 | |
| 586 | void __init smp_setup_cpu_possible_map(void) |
| 587 | { |
Heiko Carstens | 5433045 | 2006-02-17 13:52:48 -0800 | [diff] [blame] | 588 | unsigned int phy_cpus, pos_cpus, cpu; |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 589 | |
Heiko Carstens | 5433045 | 2006-02-17 13:52:48 -0800 | [diff] [blame] | 590 | phy_cpus = smp_count_cpus(); |
| 591 | pos_cpus = min(phy_cpus + additional_cpus, (unsigned int) NR_CPUS); |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 592 | |
Heiko Carstens | 37a3302 | 2006-02-17 13:52:47 -0800 | [diff] [blame] | 593 | if (possible_cpus) |
Heiko Carstens | 5433045 | 2006-02-17 13:52:48 -0800 | [diff] [blame] | 594 | pos_cpus = min(possible_cpus, (unsigned int) NR_CPUS); |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 595 | |
Heiko Carstens | 5433045 | 2006-02-17 13:52:48 -0800 | [diff] [blame] | 596 | for (cpu = 0; cpu < pos_cpus; cpu++) |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 597 | cpu_set(cpu, cpu_possible_map); |
| 598 | |
Heiko Carstens | 5433045 | 2006-02-17 13:52:48 -0800 | [diff] [blame] | 599 | phy_cpus = min(phy_cpus, pos_cpus); |
| 600 | |
| 601 | for (cpu = 0; cpu < phy_cpus; cpu++) |
| 602 | cpu_set(cpu, cpu_present_map); |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | #ifdef CONFIG_HOTPLUG_CPU |
| 606 | |
| 607 | static int __init setup_additional_cpus(char *s) |
| 608 | { |
| 609 | additional_cpus = simple_strtoul(s, NULL, 0); |
| 610 | return 0; |
| 611 | } |
| 612 | early_param("additional_cpus", setup_additional_cpus); |
| 613 | |
Heiko Carstens | 37a3302 | 2006-02-17 13:52:47 -0800 | [diff] [blame] | 614 | static int __init setup_possible_cpus(char *s) |
| 615 | { |
| 616 | possible_cpus = simple_strtoul(s, NULL, 0); |
| 617 | return 0; |
| 618 | } |
| 619 | early_param("possible_cpus", setup_possible_cpus); |
| 620 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | int |
| 622 | __cpu_disable(void) |
| 623 | { |
| 624 | unsigned long flags; |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 625 | struct ec_creg_mask_parms cr_parms; |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 626 | int cpu = smp_processor_id(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
| 628 | spin_lock_irqsave(&smp_reserve_lock, flags); |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 629 | if (smp_cpu_reserved[cpu] != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | spin_unlock_irqrestore(&smp_reserve_lock, flags); |
| 631 | return -EBUSY; |
| 632 | } |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 633 | cpu_clear(cpu, cpu_online_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | /* Disable pfault pseudo page faults on this cpu. */ |
Heiko Carstens | 29b08d2 | 2006-12-04 15:40:40 +0100 | [diff] [blame] | 636 | pfault_fini(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 638 | memset(&cr_parms.orvals, 0, sizeof(cr_parms.orvals)); |
| 639 | memset(&cr_parms.andvals, 0xff, sizeof(cr_parms.andvals)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 641 | /* disable all external interrupts */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | cr_parms.orvals[0] = 0; |
| 643 | cr_parms.andvals[0] = ~(1<<15 | 1<<14 | 1<<13 | 1<<12 | |
| 644 | 1<<11 | 1<<10 | 1<< 6 | 1<< 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | /* disable all I/O interrupts */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | cr_parms.orvals[6] = 0; |
| 647 | cr_parms.andvals[6] = ~(1<<31 | 1<<30 | 1<<29 | 1<<28 | |
| 648 | 1<<27 | 1<<26 | 1<<25 | 1<<24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | /* disable most machine checks */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | cr_parms.orvals[14] = 0; |
| 651 | cr_parms.andvals[14] = ~(1<<28 | 1<<27 | 1<<26 | 1<<25 | 1<<24); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 652 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | smp_ctl_bit_callback(&cr_parms); |
| 654 | |
| 655 | spin_unlock_irqrestore(&smp_reserve_lock, flags); |
| 656 | return 0; |
| 657 | } |
| 658 | |
| 659 | void |
| 660 | __cpu_die(unsigned int cpu) |
| 661 | { |
| 662 | /* Wait until target cpu is down */ |
| 663 | while (!smp_cpu_not_running(cpu)) |
| 664 | cpu_relax(); |
| 665 | printk("Processor %d spun down\n", cpu); |
| 666 | } |
| 667 | |
| 668 | void |
| 669 | cpu_die(void) |
| 670 | { |
| 671 | idle_task_exit(); |
| 672 | signal_processor(smp_processor_id(), sigp_stop); |
| 673 | BUG(); |
| 674 | for(;;); |
| 675 | } |
| 676 | |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 677 | #endif /* CONFIG_HOTPLUG_CPU */ |
| 678 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | /* |
| 680 | * Cycle through the processors and setup structures. |
| 681 | */ |
| 682 | |
| 683 | void __init smp_prepare_cpus(unsigned int max_cpus) |
| 684 | { |
| 685 | unsigned long stack; |
| 686 | unsigned int cpu; |
| 687 | int i; |
| 688 | |
Heiko Carstens | 99b2d8d | 2005-07-27 11:45:00 -0700 | [diff] [blame] | 689 | /* request the 0x1201 emergency signal external interrupt */ |
| 690 | if (register_external_interrupt(0x1201, do_ext_call_interrupt) != 0) |
| 691 | panic("Couldn't request external interrupt 0x1201"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | memset(lowcore_ptr,0,sizeof(lowcore_ptr)); |
| 693 | /* |
| 694 | * Initialize prefix pages and stacks for all possible cpus |
| 695 | */ |
| 696 | print_cpu_info(&S390_lowcore.cpu_data); |
| 697 | |
KAMEZAWA Hiroyuki | 97db7fb | 2006-03-31 02:30:26 -0800 | [diff] [blame] | 698 | for_each_possible_cpu(i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | lowcore_ptr[i] = (struct _lowcore *) |
| 700 | __get_free_pages(GFP_KERNEL|GFP_DMA, |
| 701 | sizeof(void*) == 8 ? 1 : 0); |
| 702 | stack = __get_free_pages(GFP_KERNEL,ASYNC_ORDER); |
| 703 | if (lowcore_ptr[i] == NULL || stack == 0ULL) |
| 704 | panic("smp_boot_cpus failed to allocate memory\n"); |
| 705 | |
| 706 | *(lowcore_ptr[i]) = S390_lowcore; |
| 707 | lowcore_ptr[i]->async_stack = stack + (ASYNC_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | stack = __get_free_pages(GFP_KERNEL,0); |
| 709 | if (stack == 0ULL) |
| 710 | panic("smp_boot_cpus failed to allocate memory\n"); |
| 711 | lowcore_ptr[i]->panic_stack = stack + (PAGE_SIZE); |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 712 | #ifndef CONFIG_64BIT |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 713 | if (MACHINE_HAS_IEEE) { |
| 714 | lowcore_ptr[i]->extended_save_area_addr = |
| 715 | (__u32) __get_free_pages(GFP_KERNEL,0); |
| 716 | if (lowcore_ptr[i]->extended_save_area_addr == 0) |
| 717 | panic("smp_boot_cpus failed to " |
| 718 | "allocate memory\n"); |
| 719 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | #endif |
| 721 | } |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 722 | #ifndef CONFIG_64BIT |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 723 | if (MACHINE_HAS_IEEE) |
| 724 | ctl_set_bit(14, 29); /* enable extended save area */ |
| 725 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | set_prefix((u32)(unsigned long) lowcore_ptr[smp_processor_id()]); |
| 727 | |
KAMEZAWA Hiroyuki | 97db7fb | 2006-03-31 02:30:26 -0800 | [diff] [blame] | 728 | for_each_possible_cpu(cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | if (cpu != smp_processor_id()) |
| 730 | smp_create_idle(cpu); |
| 731 | } |
| 732 | |
| 733 | void __devinit smp_prepare_boot_cpu(void) |
| 734 | { |
| 735 | BUG_ON(smp_processor_id() != 0); |
| 736 | |
| 737 | cpu_set(0, cpu_online_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | S390_lowcore.percpu_offset = __per_cpu_offset[0]; |
| 739 | current_set[0] = current; |
| 740 | } |
| 741 | |
| 742 | void smp_cpus_done(unsigned int max_cpus) |
| 743 | { |
Heiko Carstens | 5433045 | 2006-02-17 13:52:48 -0800 | [diff] [blame] | 744 | cpu_present_map = cpu_possible_map; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | /* |
| 748 | * the frequency of the profiling timer can be changed |
| 749 | * by writing a multiplier value into /proc/profile. |
| 750 | * |
| 751 | * usually you want to run this on all CPUs ;) |
| 752 | */ |
| 753 | int setup_profiling_timer(unsigned int multiplier) |
| 754 | { |
| 755 | return 0; |
| 756 | } |
| 757 | |
| 758 | static DEFINE_PER_CPU(struct cpu, cpu_devices); |
| 759 | |
| 760 | static int __init topology_init(void) |
| 761 | { |
| 762 | int cpu; |
| 763 | int ret; |
| 764 | |
KAMEZAWA Hiroyuki | 97db7fb | 2006-03-31 02:30:26 -0800 | [diff] [blame] | 765 | for_each_possible_cpu(cpu) { |
Heiko Carstens | 6721f77 | 2007-01-09 10:18:44 +0100 | [diff] [blame] | 766 | struct cpu *c = &per_cpu(cpu_devices, cpu); |
| 767 | |
| 768 | c->hotpluggable = 1; |
| 769 | ret = register_cpu(c, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | if (ret) |
| 771 | printk(KERN_WARNING "topology_init: register_cpu %d " |
| 772 | "failed (%d)\n", cpu, ret); |
| 773 | } |
| 774 | return 0; |
| 775 | } |
| 776 | |
| 777 | subsys_initcall(topology_init); |
| 778 | |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 779 | EXPORT_SYMBOL(cpu_online_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | EXPORT_SYMBOL(cpu_possible_map); |
| 781 | EXPORT_SYMBOL(lowcore_ptr); |
| 782 | EXPORT_SYMBOL(smp_ctl_set_bit); |
| 783 | EXPORT_SYMBOL(smp_ctl_clear_bit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | EXPORT_SYMBOL(smp_get_cpu); |
| 785 | EXPORT_SYMBOL(smp_put_cpu); |