1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/kernel_stat.h>
25#include <linux/irq.h>
26#include <linux/smp.h>
27#include <linux/init.h>
28#include <linux/irqchip.h>
29#include <linux/seq_file.h>
30#include <linux/ratelimit.h>
31
32unsigned long irq_err_count;
33
34int arch_show_interrupts(struct seq_file *p, int prec)
35{
36 show_ipi_list(p, prec);
37 seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count);
38 return 0;
39}
40
41void (*handle_arch_irq)(struct pt_regs *) = NULL;
42
43void __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
44{
45 if (handle_arch_irq)
46 return;
47
48 handle_arch_irq = handle_irq;
49}
50
51void __init init_IRQ(void)
52{
53 irqchip_init();
54 if (!handle_arch_irq)
55 panic("No interrupt controller found.");
56}
57
58#ifdef CONFIG_HOTPLUG_CPU
59static bool migrate_one_irq(struct irq_desc *desc)
60{
61 struct irq_data *d = irq_desc_get_irq_data(desc);
62 const struct cpumask *affinity = irq_data_get_affinity_mask(d);
63 struct irq_chip *c;
64 bool ret = false;
65
66
67
68
69
70 if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity))
71 return false;
72
73 if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
74 affinity = cpu_online_mask;
75 ret = true;
76 }
77
78 c = irq_data_get_irq_chip(d);
79 if (!c->irq_set_affinity)
80 pr_debug("IRQ%u: unable to set affinity\n", d->irq);
81 else if (c->irq_set_affinity(d, affinity, false) == IRQ_SET_MASK_OK && ret)
82 cpumask_copy(irq_data_get_affinity_mask(d), affinity);
83
84 return ret;
85}
86
87
88
89
90
91
92
93
94
95void migrate_irqs(void)
96{
97 unsigned int i;
98 struct irq_desc *desc;
99 unsigned long flags;
100
101 local_irq_save(flags);
102
103 for_each_irq_desc(i, desc) {
104 bool affinity_broken;
105
106 raw_spin_lock(&desc->lock);
107 affinity_broken = migrate_one_irq(desc);
108 raw_spin_unlock(&desc->lock);
109
110 if (affinity_broken)
111 pr_warn_ratelimited("IRQ%u no longer affine to CPU%u\n",
112 i, smp_processor_id());
113 }
114
115 local_irq_restore(flags);
116}
117#endif
118