blob: edc03cb9cd79d2c9771419092d6192b56137aecc [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);
23extern void cpu_die (void) __attribute__ ((noreturn));
24extern int __cpu_up (unsigned int cpu);
25
Heiko Carstensdbd70fb2008-04-17 07:46:12 +020026extern struct mutex smp_cpu_state_mutex;
Heiko Carstensc10fde02008-04-17 07:46:13 +020027extern int smp_cpu_polarization[];
Heiko Carstensdbd70fb2008-04-17 07:46:12 +020028
Heiko Carstensca9fc752008-12-25 13:38:39 +010029extern void arch_send_call_function_single_ipi(int cpu);
Rusty Russell630cd042009-09-24 09:34:45 -060030extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
Heiko Carstensca9fc752008-12-25 13:38:39 +010031
Heiko Carstensf64ca212010-02-26 22:37:32 +010032extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
Heiko Carstensc20c89a2009-12-07 12:52:07 +010033
Heiko Carstens2c2df112010-02-26 22:37:34 +010034extern void smp_switch_to_ipl_cpu(void (*func)(void *), void *);
35extern void smp_switch_to_cpu(void (*)(void *), void *, unsigned long sp,
36 int from, int to);
37extern void smp_restart_cpu(void);
38
Gerald Schaefer59b69782010-02-26 22:37:40 +010039/*
40 * returns 1 if (virtual) cpu is scheduled
41 * returns 0 otherwise
42 */
43static inline int smp_vcpu_scheduled(int cpu)
44{
45 u32 status;
46
47 switch (sigp_ps(&status, 0, cpu, sigp_sense_running)) {
48 case sigp_status_stored:
49 /* Check for running status */
50 if (status & 0x400)
51 return 0;
52 break;
53 case sigp_not_operational:
54 return 0;
55 default:
56 break;
57 }
58 return 1;
59}
60
Heiko Carstens2c2df112010-02-26 22:37:34 +010061#else /* CONFIG_SMP */
62
63static inline void smp_switch_to_ipl_cpu(void (*func)(void *), void *data)
64{
65 func(data);
66}
67
Gerald Schaefer59b69782010-02-26 22:37:40 +010068#define smp_vcpu_scheduled (1)
69
Heiko Carstensc20c89a2009-12-07 12:52:07 +010070#endif /* CONFIG_SMP */
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Heiko Carstens1e489512008-04-30 13:38:37 +020072#ifdef CONFIG_HOTPLUG_CPU
73extern int smp_rescan_cpus(void);
74#else
75static inline int smp_rescan_cpus(void) { return 0; }
76#endif
77
Heiko Carstensc20c89a2009-12-07 12:52:07 +010078#endif /* __ASM_SMP_H */