blob: c32e9123b40c1e10a3346a5435469e1a6888c8c8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Heiko Carstensc20c89a2009-12-07 12:52:07 +01002 * Copyright IBM Corp. 1999,2009
3 * Author(s): Denis Joseph Barrow,
4 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
5 * Heiko Carstens <heiko.carstens@de.ibm.com>,
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7#ifndef __ASM_SMP_H
8#define __ASM_SMP_H
9
Heiko Carstensc20c89a2009-12-07 12:52:07 +010010#ifdef CONFIG_SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Heiko Carstens2e5061e2008-04-30 13:38:45 +020012#include <asm/system.h>
Heiko Carstensc20c89a2009-12-07 12:52:07 +010013#include <asm/sigp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Heiko Carstens2b67fc42007-02-05 21:16:47 +010015extern void machine_restart_smp(char *);
16extern void machine_halt_smp(void);
17extern void machine_power_off_smp(void);
18
Martin Schwidefsky7b468482009-03-26 15:24:42 +010019#define raw_smp_processor_id() (S390_lowcore.cpu_nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21extern int __cpu_disable (void);
22extern void __cpu_die (unsigned int cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -070023extern int __cpu_up (unsigned int cpu);
24
Heiko Carstensdbd70fb2008-04-17 07:46:12 +020025extern struct mutex smp_cpu_state_mutex;
26
Heiko Carstensca9fc752008-12-25 13:38:39 +010027extern void arch_send_call_function_single_ipi(int cpu);
Rusty Russell630cd042009-09-24 09:34:45 -060028extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
Heiko Carstensca9fc752008-12-25 13:38:39 +010029
Heiko Carstensf64ca212010-02-26 22:37:32 +010030extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
Heiko Carstensc20c89a2009-12-07 12:52:07 +010031
Heiko Carstens2c2df112010-02-26 22:37:34 +010032extern void smp_switch_to_ipl_cpu(void (*func)(void *), void *);
33extern void smp_switch_to_cpu(void (*)(void *), void *, unsigned long sp,
34 int from, int to);
Michael Holzheu1943f532011-10-30 15:16:38 +010035extern void smp_restart_with_online_cpu(void);
Heiko Carstens2c2df112010-02-26 22:37:34 +010036extern void smp_restart_cpu(void);
37
Gerald Schaefer59b69782010-02-26 22:37:40 +010038/*
39 * returns 1 if (virtual) cpu is scheduled
40 * returns 0 otherwise
41 */
42static inline int smp_vcpu_scheduled(int cpu)
43{
44 u32 status;
45
46 switch (sigp_ps(&status, 0, cpu, sigp_sense_running)) {
47 case sigp_status_stored:
48 /* Check for running status */
49 if (status & 0x400)
50 return 0;
51 break;
52 case sigp_not_operational:
53 return 0;
54 default:
55 break;
56 }
57 return 1;
58}
59
Heiko Carstens2c2df112010-02-26 22:37:34 +010060#else /* CONFIG_SMP */
61
62static inline void smp_switch_to_ipl_cpu(void (*func)(void *), void *data)
63{
64 func(data);
65}
66
Michael Holzheu1943f532011-10-30 15:16:38 +010067static inline void smp_restart_with_online_cpu(void)
68{
69}
70
Gerald Schaefer59b69782010-02-26 22:37:40 +010071#define smp_vcpu_scheduled (1)
72
Heiko Carstensc20c89a2009-12-07 12:52:07 +010073#endif /* CONFIG_SMP */
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Heiko Carstens1e489512008-04-30 13:38:37 +020075#ifdef CONFIG_HOTPLUG_CPU
76extern int smp_rescan_cpus(void);
Heiko Carstensda7f51c2011-01-05 12:48:09 +010077extern void __noreturn cpu_die(void);
Heiko Carstens1e489512008-04-30 13:38:37 +020078#else
79static inline int smp_rescan_cpus(void) { return 0; }
Heiko Carstensda7f51c2011-01-05 12:48:09 +010080static inline void cpu_die(void) { }
Heiko Carstens1e489512008-04-30 13:38:37 +020081#endif
82
Heiko Carstensc20c89a2009-12-07 12:52:07 +010083#endif /* __ASM_SMP_H */