Commit | Line | Data |
---|---|---|
6b39ba77 TG |
1 | /* |
2 | * Common interrupt code for 32 and 64 bit | |
3 | */ | |
4 | #include <linux/cpu.h> | |
5 | #include <linux/interrupt.h> | |
6 | #include <linux/kernel_stat.h> | |
4722d194 | 7 | #include <linux/of.h> |
6b39ba77 | 8 | #include <linux/seq_file.h> |
6a02e710 | 9 | #include <linux/smp.h> |
7c1d7cdc | 10 | #include <linux/ftrace.h> |
ca444564 | 11 | #include <linux/delay.h> |
69c60c88 | 12 | #include <linux/export.h> |
6b39ba77 | 13 | |
7b6aa335 | 14 | #include <asm/apic.h> |
6b39ba77 | 15 | #include <asm/io_apic.h> |
c3d80000 | 16 | #include <asm/irq.h> |
7c1d7cdc | 17 | #include <asm/idle.h> |
01ca79f1 | 18 | #include <asm/mce.h> |
2c1b284e | 19 | #include <asm/hw_irq.h> |
ac2a5539 | 20 | #include <asm/desc.h> |
83ab8514 SRRH |
21 | |
22 | #define CREATE_TRACE_POINTS | |
cf910e83 | 23 | #include <asm/trace/irq_vectors.h> |
6b39ba77 | 24 | |
c5bde906 BG |
25 | DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); |
26 | EXPORT_PER_CPU_SYMBOL(irq_stat); | |
27 | ||
28 | DEFINE_PER_CPU(struct pt_regs *, irq_regs); | |
29 | EXPORT_PER_CPU_SYMBOL(irq_regs); | |
30 | ||
6b39ba77 TG |
31 | atomic_t irq_err_count; |
32 | ||
acaabe79 | 33 | /* Function pointer for generic interrupt vector handling */ |
4a4de9c7 | 34 | void (*x86_platform_ipi_callback)(void) = NULL; |
acaabe79 | 35 | |
249f6d9e TG |
36 | /* |
37 | * 'what should we do if we get a hw irq event on an illegal vector'. | |
38 | * each architecture has to answer this themselves. | |
39 | */ | |
40 | void ack_bad_irq(unsigned int irq) | |
41 | { | |
edea7148 CG |
42 | if (printk_ratelimit()) |
43 | pr_err("unexpected IRQ trap at vector %02x\n", irq); | |
249f6d9e | 44 | |
249f6d9e TG |
45 | /* |
46 | * Currently unexpected vectors happen only on SMP and APIC. | |
47 | * We _must_ ack these because every local APIC has only N | |
48 | * irq slots per priority level, and a 'hanging, unacked' IRQ | |
49 | * holds up an irq slot - in excessive cases (when multiple | |
50 | * unexpected vectors occur) that might lock up the APIC | |
51 | * completely. | |
52 | * But only ack when the APIC is enabled -AK | |
53 | */ | |
08306ce6 | 54 | ack_APIC_irq(); |
249f6d9e TG |
55 | } |
56 | ||
1b437c8c | 57 | #define irq_stats(x) (&per_cpu(irq_stat, x)) |
6b39ba77 | 58 | /* |
517e4981 | 59 | * /proc/interrupts printing for arch specific interrupts |
6b39ba77 | 60 | */ |
517e4981 | 61 | int arch_show_interrupts(struct seq_file *p, int prec) |
6b39ba77 TG |
62 | { |
63 | int j; | |
64 | ||
7a81d9a7 | 65 | seq_printf(p, "%*s: ", prec, "NMI"); |
6b39ba77 TG |
66 | for_each_online_cpu(j) |
67 | seq_printf(p, "%10u ", irq_stats(j)->__nmi_count); | |
3736708f | 68 | seq_puts(p, " Non-maskable interrupts\n"); |
6b39ba77 | 69 | #ifdef CONFIG_X86_LOCAL_APIC |
7a81d9a7 | 70 | seq_printf(p, "%*s: ", prec, "LOC"); |
6b39ba77 TG |
71 | for_each_online_cpu(j) |
72 | seq_printf(p, "%10u ", irq_stats(j)->apic_timer_irqs); | |
3736708f | 73 | seq_puts(p, " Local timer interrupts\n"); |
474e56b8 JSR |
74 | |
75 | seq_printf(p, "%*s: ", prec, "SPU"); | |
76 | for_each_online_cpu(j) | |
77 | seq_printf(p, "%10u ", irq_stats(j)->irq_spurious_count); | |
3736708f | 78 | seq_puts(p, " Spurious interrupts\n"); |
89ccf465 | 79 | seq_printf(p, "%*s: ", prec, "PMI"); |
241771ef IM |
80 | for_each_online_cpu(j) |
81 | seq_printf(p, "%10u ", irq_stats(j)->apic_perf_irqs); | |
3736708f | 82 | seq_puts(p, " Performance monitoring interrupts\n"); |
e360adbe | 83 | seq_printf(p, "%*s: ", prec, "IWI"); |
b6276f35 | 84 | for_each_online_cpu(j) |
e360adbe | 85 | seq_printf(p, "%10u ", irq_stats(j)->apic_irq_work_irqs); |
3736708f | 86 | seq_puts(p, " IRQ work interrupts\n"); |
346b46be FLVC |
87 | seq_printf(p, "%*s: ", prec, "RTR"); |
88 | for_each_online_cpu(j) | |
b49d7d87 | 89 | seq_printf(p, "%10u ", irq_stats(j)->icr_read_retry_count); |
3736708f | 90 | seq_puts(p, " APIC ICR read retries\n"); |
6b39ba77 | 91 | #endif |
4a4de9c7 | 92 | if (x86_platform_ipi_callback) { |
59d13812 | 93 | seq_printf(p, "%*s: ", prec, "PLT"); |
acaabe79 | 94 | for_each_online_cpu(j) |
4a4de9c7 | 95 | seq_printf(p, "%10u ", irq_stats(j)->x86_platform_ipis); |
3736708f | 96 | seq_puts(p, " Platform interrupts\n"); |
acaabe79 | 97 | } |
6b39ba77 | 98 | #ifdef CONFIG_SMP |
7a81d9a7 | 99 | seq_printf(p, "%*s: ", prec, "RES"); |
6b39ba77 TG |
100 | for_each_online_cpu(j) |
101 | seq_printf(p, "%10u ", irq_stats(j)->irq_resched_count); | |
3736708f | 102 | seq_puts(p, " Rescheduling interrupts\n"); |
7a81d9a7 | 103 | seq_printf(p, "%*s: ", prec, "CAL"); |
6b39ba77 | 104 | for_each_online_cpu(j) |
fd0f5869 TS |
105 | seq_printf(p, "%10u ", irq_stats(j)->irq_call_count - |
106 | irq_stats(j)->irq_tlb_count); | |
3736708f | 107 | seq_puts(p, " Function call interrupts\n"); |
7a81d9a7 | 108 | seq_printf(p, "%*s: ", prec, "TLB"); |
6b39ba77 TG |
109 | for_each_online_cpu(j) |
110 | seq_printf(p, "%10u ", irq_stats(j)->irq_tlb_count); | |
3736708f | 111 | seq_puts(p, " TLB shootdowns\n"); |
6b39ba77 | 112 | #endif |
0444c9bd | 113 | #ifdef CONFIG_X86_THERMAL_VECTOR |
7a81d9a7 | 114 | seq_printf(p, "%*s: ", prec, "TRM"); |
6b39ba77 TG |
115 | for_each_online_cpu(j) |
116 | seq_printf(p, "%10u ", irq_stats(j)->irq_thermal_count); | |
3736708f | 117 | seq_puts(p, " Thermal event interrupts\n"); |
0444c9bd JB |
118 | #endif |
119 | #ifdef CONFIG_X86_MCE_THRESHOLD | |
7a81d9a7 | 120 | seq_printf(p, "%*s: ", prec, "THR"); |
6b39ba77 TG |
121 | for_each_online_cpu(j) |
122 | seq_printf(p, "%10u ", irq_stats(j)->irq_threshold_count); | |
3736708f | 123 | seq_puts(p, " Threshold APIC interrupts\n"); |
01ca79f1 | 124 | #endif |
24fd78a8 AG |
125 | #ifdef CONFIG_X86_MCE_AMD |
126 | seq_printf(p, "%*s: ", prec, "DFR"); | |
127 | for_each_online_cpu(j) | |
128 | seq_printf(p, "%10u ", irq_stats(j)->irq_deferred_error_count); | |
129 | seq_puts(p, " Deferred Error APIC interrupts\n"); | |
130 | #endif | |
c1ebf835 | 131 | #ifdef CONFIG_X86_MCE |
01ca79f1 AK |
132 | seq_printf(p, "%*s: ", prec, "MCE"); |
133 | for_each_online_cpu(j) | |
134 | seq_printf(p, "%10u ", per_cpu(mce_exception_count, j)); | |
3736708f | 135 | seq_puts(p, " Machine check exceptions\n"); |
ca84f696 AK |
136 | seq_printf(p, "%*s: ", prec, "MCP"); |
137 | for_each_online_cpu(j) | |
138 | seq_printf(p, "%10u ", per_cpu(mce_poll_count, j)); | |
3736708f | 139 | seq_puts(p, " Machine check polls\n"); |
6b39ba77 | 140 | #endif |
f704a7d7 | 141 | #if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN) |
4a0d3107 | 142 | seq_printf(p, "%*s: ", prec, "HYP"); |
929320e4 TG |
143 | for_each_online_cpu(j) |
144 | seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count); | |
3736708f | 145 | seq_puts(p, " Hypervisor callback interrupts\n"); |
929320e4 | 146 | #endif |
7a81d9a7 | 147 | seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count)); |
6b39ba77 | 148 | #if defined(CONFIG_X86_IO_APIC) |
7a81d9a7 | 149 | seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count)); |
501b3265 FW |
150 | #endif |
151 | #ifdef CONFIG_HAVE_KVM | |
152 | seq_printf(p, "%*s: ", prec, "PIN"); | |
153 | for_each_online_cpu(j) | |
154 | seq_printf(p, "%10u ", irq_stats(j)->kvm_posted_intr_ipis); | |
155 | seq_puts(p, " Posted-interrupt notification event\n"); | |
156 | ||
157 | seq_printf(p, "%*s: ", prec, "PIW"); | |
158 | for_each_online_cpu(j) | |
159 | seq_printf(p, "%10u ", | |
160 | irq_stats(j)->kvm_posted_intr_wakeup_ipis); | |
161 | seq_puts(p, " Posted-interrupt wakeup event\n"); | |
6b39ba77 TG |
162 | #endif |
163 | return 0; | |
164 | } | |
165 | ||
6b39ba77 TG |
166 | /* |
167 | * /proc/stat helpers | |
168 | */ | |
169 | u64 arch_irq_stat_cpu(unsigned int cpu) | |
170 | { | |
171 | u64 sum = irq_stats(cpu)->__nmi_count; | |
172 | ||
173 | #ifdef CONFIG_X86_LOCAL_APIC | |
174 | sum += irq_stats(cpu)->apic_timer_irqs; | |
474e56b8 | 175 | sum += irq_stats(cpu)->irq_spurious_count; |
241771ef | 176 | sum += irq_stats(cpu)->apic_perf_irqs; |
e360adbe | 177 | sum += irq_stats(cpu)->apic_irq_work_irqs; |
b49d7d87 | 178 | sum += irq_stats(cpu)->icr_read_retry_count; |
6b39ba77 | 179 | #endif |
4a4de9c7 DS |
180 | if (x86_platform_ipi_callback) |
181 | sum += irq_stats(cpu)->x86_platform_ipis; | |
6b39ba77 TG |
182 | #ifdef CONFIG_SMP |
183 | sum += irq_stats(cpu)->irq_resched_count; | |
184 | sum += irq_stats(cpu)->irq_call_count; | |
6b39ba77 | 185 | #endif |
0444c9bd | 186 | #ifdef CONFIG_X86_THERMAL_VECTOR |
6b39ba77 | 187 | sum += irq_stats(cpu)->irq_thermal_count; |
0444c9bd JB |
188 | #endif |
189 | #ifdef CONFIG_X86_MCE_THRESHOLD | |
6b39ba77 | 190 | sum += irq_stats(cpu)->irq_threshold_count; |
8051dbd2 | 191 | #endif |
c1ebf835 | 192 | #ifdef CONFIG_X86_MCE |
8051dbd2 HS |
193 | sum += per_cpu(mce_exception_count, cpu); |
194 | sum += per_cpu(mce_poll_count, cpu); | |
6b39ba77 TG |
195 | #endif |
196 | return sum; | |
197 | } | |
198 | ||
199 | u64 arch_irq_stat(void) | |
200 | { | |
201 | u64 sum = atomic_read(&irq_err_count); | |
6b39ba77 TG |
202 | return sum; |
203 | } | |
c3d80000 | 204 | |
7c1d7cdc JF |
205 | |
206 | /* | |
207 | * do_IRQ handles all normal device IRQ's (the special | |
208 | * SMP cross-CPU interrupts have their own specific | |
209 | * handlers). | |
210 | */ | |
1d9090e2 | 211 | __visible unsigned int __irq_entry do_IRQ(struct pt_regs *regs) |
7c1d7cdc JF |
212 | { |
213 | struct pt_regs *old_regs = set_irq_regs(regs); | |
a782a7e4 | 214 | struct irq_desc * desc; |
7c1d7cdc JF |
215 | /* high bit used in ret_from_ code */ |
216 | unsigned vector = ~regs->orig_ax; | |
7c1d7cdc | 217 | |
6af7faf6 | 218 | entering_irq(); |
7c1d7cdc | 219 | |
a782a7e4 | 220 | desc = __this_cpu_read(vector_irq[vector]); |
7c1d7cdc | 221 | |
a782a7e4 | 222 | if (!handle_irq(desc, regs)) { |
08306ce6 | 223 | ack_APIC_irq(); |
7c1d7cdc | 224 | |
a782a7e4 TG |
225 | if (desc != VECTOR_RETRIGGERED) { |
226 | pr_emerg_ratelimited("%s: %d.%d No irq handler for vector\n", | |
9345005f | 227 | __func__, smp_processor_id(), |
a782a7e4 | 228 | vector); |
9345005f | 229 | } else { |
7276c6a2 | 230 | __this_cpu_write(vector_irq[vector], VECTOR_UNUSED); |
9345005f | 231 | } |
7c1d7cdc JF |
232 | } |
233 | ||
6af7faf6 | 234 | exiting_irq(); |
7c1d7cdc JF |
235 | |
236 | set_irq_regs(old_regs); | |
237 | return 1; | |
238 | } | |
239 | ||
acaabe79 | 240 | /* |
4a4de9c7 | 241 | * Handler for X86_PLATFORM_IPI_VECTOR. |
acaabe79 | 242 | */ |
eddc0e92 | 243 | void __smp_x86_platform_ipi(void) |
acaabe79 | 244 | { |
4a4de9c7 | 245 | inc_irq_stat(x86_platform_ipis); |
acaabe79 | 246 | |
4a4de9c7 DS |
247 | if (x86_platform_ipi_callback) |
248 | x86_platform_ipi_callback(); | |
eddc0e92 | 249 | } |
acaabe79 | 250 | |
1d9090e2 | 251 | __visible void smp_x86_platform_ipi(struct pt_regs *regs) |
eddc0e92 SA |
252 | { |
253 | struct pt_regs *old_regs = set_irq_regs(regs); | |
acaabe79 | 254 | |
eddc0e92 SA |
255 | entering_ack_irq(); |
256 | __smp_x86_platform_ipi(); | |
257 | exiting_irq(); | |
acaabe79 DS |
258 | set_irq_regs(old_regs); |
259 | } | |
260 | ||
d78f2664 | 261 | #ifdef CONFIG_HAVE_KVM |
f6b3c72c FW |
262 | static void dummy_handler(void) {} |
263 | static void (*kvm_posted_intr_wakeup_handler)(void) = dummy_handler; | |
264 | ||
265 | void kvm_set_posted_intr_wakeup_handler(void (*handler)(void)) | |
266 | { | |
267 | if (handler) | |
268 | kvm_posted_intr_wakeup_handler = handler; | |
269 | else | |
270 | kvm_posted_intr_wakeup_handler = dummy_handler; | |
271 | } | |
272 | EXPORT_SYMBOL_GPL(kvm_set_posted_intr_wakeup_handler); | |
273 | ||
d78f2664 YZ |
274 | /* |
275 | * Handler for POSTED_INTERRUPT_VECTOR. | |
276 | */ | |
1d9090e2 | 277 | __visible void smp_kvm_posted_intr_ipi(struct pt_regs *regs) |
d78f2664 YZ |
278 | { |
279 | struct pt_regs *old_regs = set_irq_regs(regs); | |
280 | ||
6af7faf6 | 281 | entering_ack_irq(); |
d78f2664 | 282 | inc_irq_stat(kvm_posted_intr_ipis); |
f6b3c72c FW |
283 | exiting_irq(); |
284 | set_irq_regs(old_regs); | |
285 | } | |
286 | ||
287 | /* | |
288 | * Handler for POSTED_INTERRUPT_WAKEUP_VECTOR. | |
289 | */ | |
290 | __visible void smp_kvm_posted_intr_wakeup_ipi(struct pt_regs *regs) | |
291 | { | |
292 | struct pt_regs *old_regs = set_irq_regs(regs); | |
293 | ||
294 | entering_ack_irq(); | |
295 | inc_irq_stat(kvm_posted_intr_wakeup_ipis); | |
296 | kvm_posted_intr_wakeup_handler(); | |
6af7faf6 | 297 | exiting_irq(); |
d78f2664 YZ |
298 | set_irq_regs(old_regs); |
299 | } | |
300 | #endif | |
301 | ||
1d9090e2 | 302 | __visible void smp_trace_x86_platform_ipi(struct pt_regs *regs) |
cf910e83 SA |
303 | { |
304 | struct pt_regs *old_regs = set_irq_regs(regs); | |
305 | ||
306 | entering_ack_irq(); | |
307 | trace_x86_platform_ipi_entry(X86_PLATFORM_IPI_VECTOR); | |
308 | __smp_x86_platform_ipi(); | |
309 | trace_x86_platform_ipi_exit(X86_PLATFORM_IPI_VECTOR); | |
310 | exiting_irq(); | |
311 | set_irq_regs(old_regs); | |
312 | } | |
313 | ||
c3d80000 | 314 | EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq); |
7a7732bc SS |
315 | |
316 | #ifdef CONFIG_HOTPLUG_CPU | |
39424e89 PB |
317 | |
318 | /* These two declarations are only used in check_irq_vectors_for_cpu_disable() | |
319 | * below, which is protected by stop_machine(). Putting them on the stack | |
320 | * results in a stack frame overflow. Dynamically allocating could result in a | |
321 | * failure so declare these two cpumasks as global. | |
322 | */ | |
323 | static struct cpumask affinity_new, online_new; | |
324 | ||
da6139e4 PB |
325 | /* |
326 | * This cpu is going to be removed and its vectors migrated to the remaining | |
327 | * online cpus. Check to see if there are enough vectors in the remaining cpus. | |
328 | * This function is protected by stop_machine(). | |
329 | */ | |
330 | int check_irq_vectors_for_cpu_disable(void) | |
331 | { | |
da6139e4 PB |
332 | unsigned int this_cpu, vector, this_count, count; |
333 | struct irq_desc *desc; | |
334 | struct irq_data *data; | |
a782a7e4 | 335 | int cpu; |
da6139e4 PB |
336 | |
337 | this_cpu = smp_processor_id(); | |
338 | cpumask_copy(&online_new, cpu_online_mask); | |
020b37ac | 339 | cpumask_clear_cpu(this_cpu, &online_new); |
da6139e4 PB |
340 | |
341 | this_count = 0; | |
342 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { | |
a782a7e4 TG |
343 | desc = __this_cpu_read(vector_irq[vector]); |
344 | if (IS_ERR_OR_NULL(desc)) | |
44825757 | 345 | continue; |
44825757 TG |
346 | /* |
347 | * Protect against concurrent action removal, affinity | |
348 | * changes etc. | |
349 | */ | |
350 | raw_spin_lock(&desc->lock); | |
351 | data = irq_desc_get_irq_data(desc); | |
a782a7e4 TG |
352 | cpumask_copy(&affinity_new, |
353 | irq_data_get_affinity_mask(data)); | |
44825757 | 354 | cpumask_clear_cpu(this_cpu, &affinity_new); |
da6139e4 | 355 | |
44825757 | 356 | /* Do not count inactive or per-cpu irqs. */ |
a782a7e4 | 357 | if (!irq_desc_has_action(desc) || irqd_is_per_cpu(data)) { |
cbb24dc7 | 358 | raw_spin_unlock(&desc->lock); |
44825757 | 359 | continue; |
da6139e4 | 360 | } |
44825757 TG |
361 | |
362 | raw_spin_unlock(&desc->lock); | |
363 | /* | |
364 | * A single irq may be mapped to multiple cpu's | |
365 | * vector_irq[] (for example IOAPIC cluster mode). In | |
366 | * this case we have two possibilities: | |
367 | * | |
368 | * 1) the resulting affinity mask is empty; that is | |
369 | * this the down'd cpu is the last cpu in the irq's | |
370 | * affinity mask, or | |
371 | * | |
372 | * 2) the resulting affinity mask is no longer a | |
373 | * subset of the online cpus but the affinity mask is | |
374 | * not zero; that is the down'd cpu is the last online | |
375 | * cpu in a user set affinity mask. | |
376 | */ | |
377 | if (cpumask_empty(&affinity_new) || | |
378 | !cpumask_subset(&affinity_new, &online_new)) | |
379 | this_count++; | |
da6139e4 PB |
380 | } |
381 | ||
382 | count = 0; | |
383 | for_each_online_cpu(cpu) { | |
384 | if (cpu == this_cpu) | |
385 | continue; | |
ac2a5539 YL |
386 | /* |
387 | * We scan from FIRST_EXTERNAL_VECTOR to first system | |
388 | * vector. If the vector is marked in the used vectors | |
389 | * bitmap or an irq is assigned to it, we don't count | |
390 | * it as available. | |
cbb24dc7 TG |
391 | * |
392 | * As this is an inaccurate snapshot anyway, we can do | |
393 | * this w/o holding vector_lock. | |
ac2a5539 YL |
394 | */ |
395 | for (vector = FIRST_EXTERNAL_VECTOR; | |
396 | vector < first_system_vector; vector++) { | |
397 | if (!test_bit(vector, used_vectors) && | |
a782a7e4 TG |
398 | IS_ERR_OR_NULL(per_cpu(vector_irq, cpu)[vector])) |
399 | count++; | |
da6139e4 PB |
400 | } |
401 | } | |
402 | ||
403 | if (count < this_count) { | |
404 | pr_warn("CPU %d disable failed: CPU has %u vectors assigned and there are only %u available.\n", | |
405 | this_cpu, this_count, count); | |
406 | return -ERANGE; | |
407 | } | |
408 | return 0; | |
409 | } | |
410 | ||
7a7732bc SS |
411 | /* A cpu has been removed from cpu_online_mask. Reset irq affinities. */ |
412 | void fixup_irqs(void) | |
413 | { | |
5231a686 | 414 | unsigned int irq, vector; |
7a7732bc SS |
415 | static int warned; |
416 | struct irq_desc *desc; | |
a3c08e5d | 417 | struct irq_data *data; |
51c43ac6 | 418 | struct irq_chip *chip; |
fb24da80 | 419 | int ret; |
7a7732bc SS |
420 | |
421 | for_each_irq_desc(irq, desc) { | |
422 | int break_affinity = 0; | |
423 | int set_affinity = 1; | |
424 | const struct cpumask *affinity; | |
425 | ||
426 | if (!desc) | |
427 | continue; | |
428 | if (irq == 2) | |
429 | continue; | |
430 | ||
431 | /* interrupt's are disabled at this point */ | |
239007b8 | 432 | raw_spin_lock(&desc->lock); |
7a7732bc | 433 | |
51c43ac6 | 434 | data = irq_desc_get_irq_data(desc); |
c149e4cd | 435 | affinity = irq_data_get_affinity_mask(data); |
b87ba87c | 436 | if (!irq_has_action(irq) || irqd_is_per_cpu(data) || |
58bff947 | 437 | cpumask_subset(affinity, cpu_online_mask)) { |
239007b8 | 438 | raw_spin_unlock(&desc->lock); |
7a7732bc SS |
439 | continue; |
440 | } | |
441 | ||
a5e74b84 SS |
442 | /* |
443 | * Complete the irq move. This cpu is going down and for | |
444 | * non intr-remapping case, we can't wait till this interrupt | |
445 | * arrives at this cpu before completing the irq move. | |
446 | */ | |
447 | irq_force_complete_move(irq); | |
448 | ||
7a7732bc SS |
449 | if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) { |
450 | break_affinity = 1; | |
2530cd4f | 451 | affinity = cpu_online_mask; |
7a7732bc SS |
452 | } |
453 | ||
51c43ac6 TG |
454 | chip = irq_data_get_irq_chip(data); |
455 | if (!irqd_can_move_in_process_context(data) && chip->irq_mask) | |
456 | chip->irq_mask(data); | |
7a7732bc | 457 | |
fb24da80 PB |
458 | if (chip->irq_set_affinity) { |
459 | ret = chip->irq_set_affinity(data, affinity, true); | |
460 | if (ret == -ENOSPC) | |
461 | pr_crit("IRQ %d set affinity failed because there are no available vectors. The device assigned to this IRQ is unstable.\n", irq); | |
462 | } else { | |
463 | if (!(warned++)) | |
464 | set_affinity = 0; | |
465 | } | |
7a7732bc | 466 | |
99dd5497 LC |
467 | /* |
468 | * We unmask if the irq was not marked masked by the | |
469 | * core code. That respects the lazy irq disable | |
470 | * behaviour. | |
471 | */ | |
983bbf1a | 472 | if (!irqd_can_move_in_process_context(data) && |
99dd5497 | 473 | !irqd_irq_masked(data) && chip->irq_unmask) |
51c43ac6 | 474 | chip->irq_unmask(data); |
7a7732bc | 475 | |
239007b8 | 476 | raw_spin_unlock(&desc->lock); |
7a7732bc SS |
477 | |
478 | if (break_affinity && set_affinity) | |
c767a54b | 479 | pr_notice("Broke affinity for irq %i\n", irq); |
7a7732bc | 480 | else if (!set_affinity) |
c767a54b | 481 | pr_notice("Cannot set affinity for irq %i\n", irq); |
7a7732bc SS |
482 | } |
483 | ||
5231a686 SS |
484 | /* |
485 | * We can remove mdelay() and then send spuriuous interrupts to | |
486 | * new cpu targets for all the irqs that were handled previously by | |
487 | * this cpu. While it works, I have seen spurious interrupt messages | |
488 | * (nothing wrong but still...). | |
489 | * | |
490 | * So for now, retain mdelay(1) and check the IRR and then send those | |
491 | * interrupts to new targets as this cpu is already offlined... | |
492 | */ | |
7a7732bc | 493 | mdelay(1); |
5231a686 | 494 | |
09cf92b7 TG |
495 | /* |
496 | * We can walk the vector array of this cpu without holding | |
497 | * vector_lock because the cpu is already marked !online, so | |
498 | * nothing else will touch it. | |
499 | */ | |
5231a686 SS |
500 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { |
501 | unsigned int irr; | |
502 | ||
a782a7e4 | 503 | if (IS_ERR_OR_NULL(__this_cpu_read(vector_irq[vector]))) |
5231a686 SS |
504 | continue; |
505 | ||
506 | irr = apic_read(APIC_IRR + (vector / 32 * 0x10)); | |
507 | if (irr & (1 << (vector % 32))) { | |
a782a7e4 | 508 | desc = __this_cpu_read(vector_irq[vector]); |
5231a686 | 509 | |
09cf92b7 | 510 | raw_spin_lock(&desc->lock); |
51c43ac6 TG |
511 | data = irq_desc_get_irq_data(desc); |
512 | chip = irq_data_get_irq_chip(data); | |
9345005f | 513 | if (chip->irq_retrigger) { |
51c43ac6 | 514 | chip->irq_retrigger(data); |
9345005f PB |
515 | __this_cpu_write(vector_irq[vector], VECTOR_RETRIGGERED); |
516 | } | |
239007b8 | 517 | raw_spin_unlock(&desc->lock); |
5231a686 | 518 | } |
9345005f | 519 | if (__this_cpu_read(vector_irq[vector]) != VECTOR_RETRIGGERED) |
7276c6a2 | 520 | __this_cpu_write(vector_irq[vector], VECTOR_UNUSED); |
5231a686 | 521 | } |
7a7732bc SS |
522 | } |
523 | #endif |