ACPI: thinkpad-acpi: preserve radio state across shutdown
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-x86 / ipi.h
blobbb1c09f7a76ced4cd028d631d79a13d0171e8c2c
1 #ifndef __ASM_IPI_H
2 #define __ASM_IPI_H
4 /*
5 * Copyright 2004 James Cleverdon, IBM.
6 * Subject to the GNU Public License, v.2
8 * Generic APIC InterProcessor Interrupt code.
10 * Moved to include file by James Cleverdon from
11 * arch/x86-64/kernel/smp.c
13 * Copyrights from kernel/smp.c:
15 * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
16 * (c) 1998-99, 2000 Ingo Molnar <mingo@redhat.com>
17 * (c) 2002,2003 Andi Kleen, SuSE Labs.
18 * Subject to the GNU Public License, v.2
21 #include <asm/hw_irq.h>
22 #include <asm/apic.h>
23 #include <asm/smp.h>
26 * the following functions deal with sending IPIs between CPUs.
28 * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
31 static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
32 unsigned int dest)
34 unsigned int icr = shortcut | dest;
36 switch (vector) {
37 default:
38 icr |= APIC_DM_FIXED | vector;
39 break;
40 case NMI_VECTOR:
41 icr |= APIC_DM_NMI;
42 break;
44 return icr;
47 static inline int __prepare_ICR2(unsigned int mask)
49 return SET_APIC_DEST_FIELD(mask);
52 static inline void __send_IPI_shortcut(unsigned int shortcut, int vector,
53 unsigned int dest)
56 * Subtle. In the case of the 'never do double writes' workaround
57 * we have to lock out interrupts to be safe. As we don't care
58 * of the value read we use an atomic rmw access to avoid costly
59 * cli/sti. Otherwise we use an even cheaper single atomic write
60 * to the APIC.
62 unsigned int cfg;
65 * Wait for idle.
67 apic_wait_icr_idle();
70 * No need to touch the target chip field
72 cfg = __prepare_ICR(shortcut, vector, dest);
75 * Send the IPI. The write to APIC_ICR fires this off.
77 apic_write(APIC_ICR, cfg);
81 * This is used to send an IPI with no shorthand notation (the destination is
82 * specified in bits 56 to 63 of the ICR).
84 static inline void __send_IPI_dest_field(unsigned int mask, int vector,
85 unsigned int dest)
87 unsigned long cfg;
90 * Wait for idle.
92 if (unlikely(vector == NMI_VECTOR))
93 safe_apic_wait_icr_idle();
94 else
95 apic_wait_icr_idle();
98 * prepare target chip field
100 cfg = __prepare_ICR2(mask);
101 apic_write(APIC_ICR2, cfg);
104 * program the ICR
106 cfg = __prepare_ICR(0, vector, dest);
109 * Send the IPI. The write to APIC_ICR fires this off.
111 apic_write(APIC_ICR, cfg);
114 static inline void send_IPI_mask_sequence(cpumask_t mask, int vector)
116 unsigned long flags;
117 unsigned long query_cpu;
120 * Hack. The clustered APIC addressing mode doesn't allow us to send
121 * to an arbitrary mask, so I do a unicast to each CPU instead.
122 * - mbligh
124 local_irq_save(flags);
125 for_each_cpu_mask_nr(query_cpu, mask) {
126 __send_IPI_dest_field(per_cpu(x86_cpu_to_apicid, query_cpu),
127 vector, APIC_DEST_PHYSICAL);
129 local_irq_restore(flags);
132 #endif /* __ASM_IPI_H */