Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-microblaze.git] / arch / x86 / include / asm / ipi.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _ASM_X86_IPI_H
3 #define _ASM_X86_IPI_H
4
5 #ifdef CONFIG_X86_LOCAL_APIC
6
7 /*
8  * Copyright 2004 James Cleverdon, IBM.
9  *
10  * Generic APIC InterProcessor Interrupt code.
11  *
12  * Moved to include file by James Cleverdon from
13  * arch/x86-64/kernel/smp.c
14  *
15  * Copyrights from kernel/smp.c:
16  *
17  * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
18  * (c) 1998-99, 2000 Ingo Molnar <mingo@redhat.com>
19  * (c) 2002,2003 Andi Kleen, SuSE Labs.
20  */
21
22 #include <asm/hw_irq.h>
23 #include <asm/apic.h>
24 #include <asm/smp.h>
25
26 /*
27  * the following functions deal with sending IPIs between CPUs.
28  *
29  * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
30  */
31
32 static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
33                                          unsigned int dest)
34 {
35         unsigned int icr = shortcut | dest;
36
37         switch (vector) {
38         default:
39                 icr |= APIC_DM_FIXED | vector;
40                 break;
41         case NMI_VECTOR:
42                 icr |= APIC_DM_NMI;
43                 break;
44         }
45         return icr;
46 }
47
48 static inline int __prepare_ICR2(unsigned int mask)
49 {
50         return SET_APIC_DEST_FIELD(mask);
51 }
52
53 static inline void __xapic_wait_icr_idle(void)
54 {
55         while (native_apic_mem_read(APIC_ICR) & APIC_ICR_BUSY)
56                 cpu_relax();
57 }
58
59 void __default_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest);
60
61 /*
62  * This is used to send an IPI with no shorthand notation (the destination is
63  * specified in bits 56 to 63 of the ICR).
64  */
65 void __default_send_IPI_dest_field(unsigned int mask, int vector, unsigned int dest);
66
67 extern void default_send_IPI_single(int cpu, int vector);
68 extern void default_send_IPI_single_phys(int cpu, int vector);
69 extern void default_send_IPI_mask_sequence_phys(const struct cpumask *mask,
70                                                  int vector);
71 extern void default_send_IPI_mask_allbutself_phys(const struct cpumask *mask,
72                                                          int vector);
73
74 /* Avoid include hell */
75 #define NMI_VECTOR 0x02
76
77 extern int no_broadcast;
78
79 static inline void __default_local_send_IPI_allbutself(int vector)
80 {
81         if (no_broadcast || vector == NMI_VECTOR)
82                 apic->send_IPI_mask_allbutself(cpu_online_mask, vector);
83         else
84                 __default_send_IPI_shortcut(APIC_DEST_ALLBUT, vector, apic->dest_logical);
85 }
86
87 static inline void __default_local_send_IPI_all(int vector)
88 {
89         if (no_broadcast || vector == NMI_VECTOR)
90                 apic->send_IPI_mask(cpu_online_mask, vector);
91         else
92                 __default_send_IPI_shortcut(APIC_DEST_ALLINC, vector, apic->dest_logical);
93 }
94
95 #ifdef CONFIG_X86_32
96 extern void default_send_IPI_mask_sequence_logical(const struct cpumask *mask,
97                                                          int vector);
98 extern void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask,
99                                                          int vector);
100 extern void default_send_IPI_mask_logical(const struct cpumask *mask,
101                                                  int vector);
102 extern void default_send_IPI_allbutself(int vector);
103 extern void default_send_IPI_all(int vector);
104 extern void default_send_IPI_self(int vector);
105 #endif
106
107 #endif
108
109 #endif /* _ASM_X86_IPI_H */