blob: a4fe16e42b7b268a736431cccccd5b73ac632fa1 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_IPI_H
2#define _ASM_X86_IPI_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
Ingo Molnard53e2f22009-01-28 19:14:52 +01004#ifdef CONFIG_X86_LOCAL_APIC
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*
7 * Copyright 2004 James Cleverdon, IBM.
8 * Subject to the GNU Public License, v.2
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 * Subject to the GNU Public License, v.2
21 */
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <asm/hw_irq.h>
Jan Beulich00f1ea62007-05-02 19:27:04 +020024#include <asm/apic.h>
Paul Jacksone3f8ba82008-05-14 08:15:04 -070025#include <asm/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27/*
28 * the following functions deal with sending IPIs between CPUs.
29 *
30 * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
31 */
32
Joe Perches061b3d92008-03-23 01:02:27 -070033static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
34 unsigned int dest)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
Jan Beulich1a426cb2005-09-12 18:49:24 +020036 unsigned int icr = shortcut | dest;
37
38 switch (vector) {
39 default:
40 icr |= APIC_DM_FIXED | vector;
41 break;
42 case NMI_VECTOR:
Jan Beulich1a426cb2005-09-12 18:49:24 +020043 icr |= APIC_DM_NMI;
44 break;
45 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 return icr;
47}
48
Joe Perches061b3d92008-03-23 01:02:27 -070049static inline int __prepare_ICR2(unsigned int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 return SET_APIC_DEST_FIELD(mask);
52}
53
Suresh Siddha1b374e42008-07-10 11:16:49 -070054static inline void __xapic_wait_icr_idle(void)
55{
56 while (native_apic_mem_read(APIC_ICR) & APIC_ICR_BUSY)
57 cpu_relax();
58}
59
Denys Vlasenko1a8aa8a2016-03-06 19:11:15 +010060void __default_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Fernando Luis [** ISO-8859-1 charset **] VázquezCao9062d882007-05-02 19:27:18 +020062/*
63 * This is used to send an IPI with no shorthand notation (the destination is
64 * specified in bits 56 to 63 of the ICR).
65 */
Denys Vlasenko1a8aa8a2016-03-06 19:11:15 +010066void __default_send_IPI_dest_field(unsigned int mask, int vector, unsigned int dest);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Thomas Gleixner7e293932015-11-04 22:57:07 +000068extern void default_send_IPI_single(int cpu, int vector);
Thomas Gleixner53be0fa2015-11-04 22:57:01 +000069extern void default_send_IPI_single_phys(int cpu, int vector);
Yinghai Luc5e95482009-01-30 17:29:27 -080070extern void default_send_IPI_mask_sequence_phys(const struct cpumask *mask,
71 int vector);
72extern void default_send_IPI_mask_allbutself_phys(const struct cpumask *mask,
73 int vector);
Ingo Molnard53e2f22009-01-28 19:14:52 +010074
75/* Avoid include hell */
76#define NMI_VECTOR 0x02
77
Ingo Molnard53e2f22009-01-28 19:14:52 +010078extern int no_broadcast;
79
Ingo Molnard53e2f22009-01-28 19:14:52 +010080static inline void __default_local_send_IPI_allbutself(int vector)
81{
82 if (no_broadcast || vector == NMI_VECTOR)
83 apic->send_IPI_mask_allbutself(cpu_online_mask, vector);
84 else
85 __default_send_IPI_shortcut(APIC_DEST_ALLBUT, vector, apic->dest_logical);
86}
87
88static inline void __default_local_send_IPI_all(int vector)
89{
90 if (no_broadcast || vector == NMI_VECTOR)
91 apic->send_IPI_mask(cpu_online_mask, vector);
92 else
93 __default_send_IPI_shortcut(APIC_DEST_ALLINC, vector, apic->dest_logical);
94}
95
96#ifdef CONFIG_X86_32
Tejun Heo1245e162011-01-23 14:37:29 +010097extern void default_send_IPI_mask_sequence_logical(const struct cpumask *mask,
98 int vector);
99extern void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask,
100 int vector);
Yinghai Luc5e95482009-01-30 17:29:27 -0800101extern void default_send_IPI_mask_logical(const struct cpumask *mask,
102 int vector);
103extern void default_send_IPI_allbutself(int vector);
104extern void default_send_IPI_all(int vector);
105extern void default_send_IPI_self(int vector);
Ingo Molnard53e2f22009-01-28 19:14:52 +0100106#endif
107
108#endif
109
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700110#endif /* _ASM_X86_IPI_H */