blob: 5df26b11cf47c79ca360d5dbc0952399ba2dbe19 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02002 * Copyright IBM Corp. 1999, 2012
Heiko Carstensc20c89a2009-12-07 12:52:07 +01003 * 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 Carstense7c46c62014-04-04 11:23:03 +020010#include <asm/sigp.h>
11
Heiko Carstensc20c89a2009-12-07 12:52:07 +010012#ifdef CONFIG_SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
David Howellsa0616cd2012-03-28 18:30:02 +010014#include <asm/lowcore.h>
Heiko Carstens2b67fc42007-02-05 21:16:47 +010015
Martin Schwidefsky7b468482009-03-26 15:24:42 +010016#define raw_smp_processor_id() (S390_lowcore.cpu_nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Heiko Carstensdbd70fb2008-04-17 07:46:12 +020018extern struct mutex smp_cpu_state_mutex;
Martin Schwidefsky10ad34b2015-01-14 17:52:10 +010019extern unsigned int smp_cpu_mt_shift;
20extern unsigned int smp_cpu_mtid;
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040021
Thomas Gleixner8239c252012-04-20 13:05:42 +000022extern int __cpu_up(unsigned int cpu, struct task_struct *tidle);
Heiko Carstensdbd70fb2008-04-17 07:46:12 +020023
Heiko Carstensca9fc752008-12-25 13:38:39 +010024extern void arch_send_call_function_single_ipi(int cpu);
Rusty Russell630cd042009-09-24 09:34:45 -060025extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
Heiko Carstensca9fc752008-12-25 13:38:39 +010026
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040027extern void smp_call_online_cpu(void (*func)(void *), void *);
28extern void smp_call_ipl_cpu(void (*func)(void *), void *);
Heiko Carstensc20c89a2009-12-07 12:52:07 +010029
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040030extern int smp_find_processor_id(u16 address);
31extern int smp_store_status(int cpu);
Michael Holzheu1592a8e2015-05-26 19:05:23 +020032extern void smp_save_dump_cpus(void);
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040033extern int smp_vcpu_scheduled(int cpu);
34extern void smp_yield_cpu(int cpu);
Heiko Carstens50ab9a92012-09-04 17:36:16 +020035extern void smp_cpu_set_polarization(int cpu, int val);
36extern int smp_cpu_get_polarization(int cpu);
Heiko Carstensd80512f2013-12-16 14:31:26 +010037extern void smp_fill_possible_mask(void);
Gerald Schaefer59b69782010-02-26 22:37:40 +010038
Heiko Carstens2c2df112010-02-26 22:37:34 +010039#else /* CONFIG_SMP */
40
Martin Schwidefsky10ad34b2015-01-14 17:52:10 +010041#define smp_cpu_mtid 0
42
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040043static inline void smp_call_ipl_cpu(void (*func)(void *), void *data)
Heiko Carstens2c2df112010-02-26 22:37:34 +010044{
45 func(data);
46}
47
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040048static inline void smp_call_online_cpu(void (*func)(void *), void *data)
Michael Holzheu1943f532011-10-30 15:16:38 +010049{
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040050 func(data);
Michael Holzheu1943f532011-10-30 15:16:38 +010051}
52
Heiko Carstens0d0e4712012-08-27 15:38:19 +020053static inline int smp_find_processor_id(u16 address) { return 0; }
Heiko Carstens29a877f2012-08-27 15:18:45 +020054static inline int smp_store_status(int cpu) { return 0; }
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040055static inline int smp_vcpu_scheduled(int cpu) { return 1; }
56static inline void smp_yield_cpu(int cpu) { }
Heiko Carstensd80512f2013-12-16 14:31:26 +010057static inline void smp_fill_possible_mask(void) { }
Heiko Carstens1af135a2015-06-26 12:10:49 +020058static inline void smp_save_dump_cpus(void) { }
Gerald Schaefer59b69782010-02-26 22:37:40 +010059
Michael Holzheuf4192bf2014-04-15 11:25:28 +020060#endif /* CONFIG_SMP */
61
Heiko Carstense7c46c62014-04-04 11:23:03 +020062static inline void smp_stop_cpu(void)
63{
64 u16 pcpu = stap();
65
66 for (;;) {
67 __pcpu_sigp(pcpu, SIGP_STOP, 0, NULL);
68 cpu_relax();
69 }
70}
71
Heiko Carstens1e489512008-04-30 13:38:37 +020072#ifdef CONFIG_HOTPLUG_CPU
73extern int smp_rescan_cpus(void);
Heiko Carstensda7f51c2011-01-05 12:48:09 +010074extern void __noreturn cpu_die(void);
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -040075extern void __cpu_die(unsigned int cpu);
76extern int __cpu_disable(void);
Heiko Carstens1e489512008-04-30 13:38:37 +020077#else
78static inline int smp_rescan_cpus(void) { return 0; }
Heiko Carstensda7f51c2011-01-05 12:48:09 +010079static inline void cpu_die(void) { }
Heiko Carstens1e489512008-04-30 13:38:37 +020080#endif
81
Heiko Carstensc20c89a2009-12-07 12:52:07 +010082#endif /* __ASM_SMP_H */