Linux Audio

Check our new training course

Loading...
v4.10.11
 
  1#ifndef _ASM_X86_SMP_H
  2#define _ASM_X86_SMP_H
  3#ifndef __ASSEMBLY__
  4#include <linux/cpumask.h>
  5#include <asm/percpu.h>
  6
  7/*
  8 * We need the APIC definitions automatically as part of 'smp.h'
  9 */
 10#ifdef CONFIG_X86_LOCAL_APIC
 11# include <asm/mpspec.h>
 12# include <asm/apic.h>
 13# ifdef CONFIG_X86_IO_APIC
 14#  include <asm/io_apic.h>
 15# endif
 16#endif
 17#include <asm/thread_info.h>
 18#include <asm/cpumask.h>
 
 
 19
 20extern int smp_num_siblings;
 21extern unsigned int num_processors;
 22
 23DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map);
 24DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
 
 25/* cpus sharing the last level cache: */
 26DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
 
 27DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
 28DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
 29
 30static inline struct cpumask *cpu_llc_shared_mask(int cpu)
 31{
 32	return per_cpu(cpu_llc_shared_map, cpu);
 33}
 34
 35DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid);
 36DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid);
 37DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid);
 38#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
 39DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid);
 40#endif
 41
 42struct task_struct;
 43
 44struct smp_ops {
 45	void (*smp_prepare_boot_cpu)(void);
 46	void (*smp_prepare_cpus)(unsigned max_cpus);
 47	void (*smp_cpus_done)(unsigned max_cpus);
 48
 49	void (*stop_other_cpus)(int wait);
 50	void (*crash_stop_other_cpus)(void);
 51	void (*smp_send_reschedule)(int cpu);
 52
 53	int (*cpu_up)(unsigned cpu, struct task_struct *tidle);
 54	int (*cpu_disable)(void);
 55	void (*cpu_die)(unsigned int cpu);
 56	void (*play_dead)(void);
 57
 58	void (*send_call_func_ipi)(const struct cpumask *mask);
 59	void (*send_call_func_single_ipi)(int cpu);
 60};
 61
 62/* Globals due to paravirt */
 63extern void set_cpu_sibling_map(int cpu);
 64
 65#ifdef CONFIG_SMP
 66extern struct smp_ops smp_ops;
 67
 68static inline void smp_send_stop(void)
 69{
 70	smp_ops.stop_other_cpus(0);
 71}
 72
 73static inline void stop_other_cpus(void)
 74{
 75	smp_ops.stop_other_cpus(1);
 76}
 77
 78static inline void smp_prepare_boot_cpu(void)
 79{
 80	smp_ops.smp_prepare_boot_cpu();
 81}
 82
 83static inline void smp_prepare_cpus(unsigned int max_cpus)
 84{
 85	smp_ops.smp_prepare_cpus(max_cpus);
 86}
 87
 88static inline void smp_cpus_done(unsigned int max_cpus)
 89{
 90	smp_ops.smp_cpus_done(max_cpus);
 91}
 92
 93static inline int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 94{
 95	return smp_ops.cpu_up(cpu, tidle);
 96}
 97
 98static inline int __cpu_disable(void)
 99{
100	return smp_ops.cpu_disable();
101}
102
103static inline void __cpu_die(unsigned int cpu)
104{
105	smp_ops.cpu_die(cpu);
106}
107
108static inline void play_dead(void)
109{
110	smp_ops.play_dead();
111}
112
113static inline void smp_send_reschedule(int cpu)
114{
115	smp_ops.smp_send_reschedule(cpu);
116}
117
118static inline void arch_send_call_function_single_ipi(int cpu)
119{
120	smp_ops.send_call_func_single_ipi(cpu);
121}
122
123static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
124{
125	smp_ops.send_call_func_ipi(mask);
126}
127
128void cpu_disable_common(void);
129void native_smp_prepare_boot_cpu(void);
 
130void native_smp_prepare_cpus(unsigned int max_cpus);
 
131void native_smp_cpus_done(unsigned int max_cpus);
132void common_cpu_up(unsigned int cpunum, struct task_struct *tidle);
133int native_cpu_up(unsigned int cpunum, struct task_struct *tidle);
134int native_cpu_disable(void);
135int common_cpu_die(unsigned int cpu);
136void native_cpu_die(unsigned int cpu);
137void hlt_play_dead(void);
138void native_play_dead(void);
139void play_dead_common(void);
140void wbinvd_on_cpu(int cpu);
141int wbinvd_on_all_cpus(void);
 
142
 
143void native_send_call_func_ipi(const struct cpumask *mask);
144void native_send_call_func_single_ipi(int cpu);
145void x86_idle_thread_init(unsigned int cpu, struct task_struct *idle);
146
147void smp_store_boot_cpu_info(void);
148void smp_store_cpu_info(int id);
149#define cpu_physical_id(cpu)	per_cpu(x86_cpu_to_apicid, cpu)
150#define cpu_acpi_id(cpu)	per_cpu(x86_cpu_to_acpiid, cpu)
151
152#else /* !CONFIG_SMP */
153#define wbinvd_on_cpu(cpu)     wbinvd()
154static inline int wbinvd_on_all_cpus(void)
155{
156	wbinvd();
157	return 0;
158}
159#define smp_num_siblings	1
160#endif /* CONFIG_SMP */
161
162extern unsigned disabled_cpus;
 
163
164#ifdef CONFIG_X86_32_SMP
165/*
166 * This function is needed by all SMP systems. It must _always_ be valid
167 * from the initial startup. We map APIC_BASE very early in page_setup(),
168 * so this is correct in the x86 case.
169 */
170#define raw_smp_processor_id() (this_cpu_read(cpu_number))
171extern int safe_smp_processor_id(void);
172
173#elif defined(CONFIG_X86_64_SMP)
174#define raw_smp_processor_id() (this_cpu_read(cpu_number))
 
 
 
175
176#define safe_smp_processor_id()		smp_processor_id()
 
 
 
177
178#endif
 
 
 
179
180#ifdef CONFIG_X86_LOCAL_APIC
 
 
 
 
 
 
181
182#ifndef CONFIG_X86_64
183static inline int logical_smp_processor_id(void)
184{
185	/* we don't want to mark this access volatile - bad code generation */
186	return GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
187}
 
188
189#endif
190
 
191extern int hard_smp_processor_id(void);
192
193#else /* CONFIG_X86_LOCAL_APIC */
194
195# ifndef CONFIG_SMP
196#  define hard_smp_processor_id()	0
197# endif
198
199#endif /* CONFIG_X86_LOCAL_APIC */
200
201#ifdef CONFIG_DEBUG_NMI_SELFTEST
202extern void nmi_selftest(void);
203#else
204#define nmi_selftest() do { } while (0)
205#endif
206
207#endif /* __ASSEMBLY__ */
208#endif /* _ASM_X86_SMP_H */
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _ASM_X86_SMP_H
  3#define _ASM_X86_SMP_H
  4#ifndef __ASSEMBLY__
  5#include <linux/cpumask.h>
 
  6
 
 
 
 
 
 
 
 
 
 
 
  7#include <asm/cpumask.h>
  8#include <asm/current.h>
  9#include <asm/thread_info.h>
 10
 11extern int smp_num_siblings;
 12extern unsigned int num_processors;
 13
 14DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map);
 15DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
 16DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_die_map);
 17/* cpus sharing the last level cache: */
 18DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
 19DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_l2c_shared_map);
 20DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
 21DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_l2c_id);
 
 
 
 
 
 22
 23DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid);
 24DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid);
 25DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid);
 26#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
 27DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid);
 28#endif
 29
 30struct task_struct;
 31
 32struct smp_ops {
 33	void (*smp_prepare_boot_cpu)(void);
 34	void (*smp_prepare_cpus)(unsigned max_cpus);
 35	void (*smp_cpus_done)(unsigned max_cpus);
 36
 37	void (*stop_other_cpus)(int wait);
 38	void (*crash_stop_other_cpus)(void);
 39	void (*smp_send_reschedule)(int cpu);
 40
 41	int (*cpu_up)(unsigned cpu, struct task_struct *tidle);
 42	int (*cpu_disable)(void);
 43	void (*cpu_die)(unsigned int cpu);
 44	void (*play_dead)(void);
 45
 46	void (*send_call_func_ipi)(const struct cpumask *mask);
 47	void (*send_call_func_single_ipi)(int cpu);
 48};
 49
 50/* Globals due to paravirt */
 51extern void set_cpu_sibling_map(int cpu);
 52
 53#ifdef CONFIG_SMP
 54extern struct smp_ops smp_ops;
 55
 56static inline void smp_send_stop(void)
 57{
 58	smp_ops.stop_other_cpus(0);
 59}
 60
 61static inline void stop_other_cpus(void)
 62{
 63	smp_ops.stop_other_cpus(1);
 64}
 65
 66static inline void smp_prepare_boot_cpu(void)
 67{
 68	smp_ops.smp_prepare_boot_cpu();
 69}
 70
 71static inline void smp_prepare_cpus(unsigned int max_cpus)
 72{
 73	smp_ops.smp_prepare_cpus(max_cpus);
 74}
 75
 76static inline void smp_cpus_done(unsigned int max_cpus)
 77{
 78	smp_ops.smp_cpus_done(max_cpus);
 79}
 80
 81static inline int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 82{
 83	return smp_ops.cpu_up(cpu, tidle);
 84}
 85
 86static inline int __cpu_disable(void)
 87{
 88	return smp_ops.cpu_disable();
 89}
 90
 91static inline void __cpu_die(unsigned int cpu)
 92{
 93	smp_ops.cpu_die(cpu);
 94}
 95
 96static inline void play_dead(void)
 97{
 98	smp_ops.play_dead();
 99}
100
101static inline void smp_send_reschedule(int cpu)
102{
103	smp_ops.smp_send_reschedule(cpu);
104}
105
106static inline void arch_send_call_function_single_ipi(int cpu)
107{
108	smp_ops.send_call_func_single_ipi(cpu);
109}
110
111static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
112{
113	smp_ops.send_call_func_ipi(mask);
114}
115
116void cpu_disable_common(void);
117void native_smp_prepare_boot_cpu(void);
118void smp_prepare_cpus_common(void);
119void native_smp_prepare_cpus(unsigned int max_cpus);
120void calculate_max_logical_packages(void);
121void native_smp_cpus_done(unsigned int max_cpus);
122int common_cpu_up(unsigned int cpunum, struct task_struct *tidle);
123int native_cpu_up(unsigned int cpunum, struct task_struct *tidle);
124int native_cpu_disable(void);
125int common_cpu_die(unsigned int cpu);
126void native_cpu_die(unsigned int cpu);
127void hlt_play_dead(void);
128void native_play_dead(void);
129void play_dead_common(void);
130void wbinvd_on_cpu(int cpu);
131int wbinvd_on_all_cpus(void);
132void cond_wakeup_cpu0(void);
133
134void native_smp_send_reschedule(int cpu);
135void native_send_call_func_ipi(const struct cpumask *mask);
136void native_send_call_func_single_ipi(int cpu);
137void x86_idle_thread_init(unsigned int cpu, struct task_struct *idle);
138
139void smp_store_boot_cpu_info(void);
140void smp_store_cpu_info(int id);
 
 
141
142asmlinkage __visible void smp_reboot_interrupt(void);
143__visible void smp_reschedule_interrupt(struct pt_regs *regs);
144__visible void smp_call_function_interrupt(struct pt_regs *regs);
145__visible void smp_call_function_single_interrupt(struct pt_regs *r);
 
 
 
 
 
146
147#define cpu_physical_id(cpu)	per_cpu(x86_cpu_to_apicid, cpu)
148#define cpu_acpi_id(cpu)	per_cpu(x86_cpu_to_acpiid, cpu)
149
 
150/*
151 * This function is needed by all SMP systems. It must _always_ be valid
152 * from the initial startup.
 
153 */
154#define raw_smp_processor_id()  this_cpu_read(pcpu_hot.cpu_number)
155#define __smp_processor_id() __this_cpu_read(pcpu_hot.cpu_number)
156
157#ifdef CONFIG_X86_32
158extern int safe_smp_processor_id(void);
159#else
160# define safe_smp_processor_id()	smp_processor_id()
161#endif
162
163static inline struct cpumask *cpu_llc_shared_mask(int cpu)
164{
165	return per_cpu(cpu_llc_shared_map, cpu);
166}
167
168static inline struct cpumask *cpu_l2c_shared_mask(int cpu)
169{
170	return per_cpu(cpu_l2c_shared_map, cpu);
171}
172
173#else /* !CONFIG_SMP */
174#define wbinvd_on_cpu(cpu)     wbinvd()
175static inline int wbinvd_on_all_cpus(void)
176{
177	wbinvd();
178	return 0;
179}
180
181static inline struct cpumask *cpu_llc_shared_mask(int cpu)
 
182{
183	return (struct cpumask *)cpumask_of(0);
 
184}
185#endif /* CONFIG_SMP */
186
187extern unsigned disabled_cpus;
188
189#ifdef CONFIG_X86_LOCAL_APIC
190extern int hard_smp_processor_id(void);
191
192#else /* CONFIG_X86_LOCAL_APIC */
193#define hard_smp_processor_id()	0
 
 
 
 
194#endif /* CONFIG_X86_LOCAL_APIC */
195
196#ifdef CONFIG_DEBUG_NMI_SELFTEST
197extern void nmi_selftest(void);
198#else
199#define nmi_selftest() do { } while (0)
200#endif
201
202#endif /* __ASSEMBLY__ */
203#endif /* _ASM_X86_SMP_H */