sparse irq_desc[] array: core kernel and x86 changes
[deliverable/linux.git] / arch / x86 / kernel / irq.c
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>
7 #include <linux/seq_file.h>
8
9 #include <asm/apic.h>
10 #include <asm/io_apic.h>
11 #include <asm/smp.h>
12
13 atomic_t irq_err_count;
14
15 /*
16 * 'what should we do if we get a hw irq event on an illegal vector'.
17 * each architecture has to answer this themselves.
18 */
19 void ack_bad_irq(unsigned int irq)
20 {
21 printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq);
22
23 #ifdef CONFIG_X86_LOCAL_APIC
24 /*
25 * Currently unexpected vectors happen only on SMP and APIC.
26 * We _must_ ack these because every local APIC has only N
27 * irq slots per priority level, and a 'hanging, unacked' IRQ
28 * holds up an irq slot - in excessive cases (when multiple
29 * unexpected vectors occur) that might lock up the APIC
30 * completely.
31 * But only ack when the APIC is enabled -AK
32 */
33 if (cpu_has_apic)
34 ack_APIC_irq();
35 #endif
36 }
37
38 #ifdef CONFIG_X86_32
39 # define irq_stats(x) (&per_cpu(irq_stat, x))
40 #else
41 # define irq_stats(x) cpu_pda(x)
42 #endif
43 /*
44 * /proc/interrupts printing:
45 */
46 static int show_other_interrupts(struct seq_file *p)
47 {
48 int j;
49
50 seq_printf(p, "NMI: ");
51 for_each_online_cpu(j)
52 seq_printf(p, "%10u ", irq_stats(j)->__nmi_count);
53 seq_printf(p, " Non-maskable interrupts\n");
54 #ifdef CONFIG_X86_LOCAL_APIC
55 seq_printf(p, "LOC: ");
56 for_each_online_cpu(j)
57 seq_printf(p, "%10u ", irq_stats(j)->apic_timer_irqs);
58 seq_printf(p, " Local timer interrupts\n");
59 #endif
60 #ifdef CONFIG_SMP
61 seq_printf(p, "RES: ");
62 for_each_online_cpu(j)
63 seq_printf(p, "%10u ", irq_stats(j)->irq_resched_count);
64 seq_printf(p, " Rescheduling interrupts\n");
65 seq_printf(p, "CAL: ");
66 for_each_online_cpu(j)
67 seq_printf(p, "%10u ", irq_stats(j)->irq_call_count);
68 seq_printf(p, " Function call interrupts\n");
69 seq_printf(p, "TLB: ");
70 for_each_online_cpu(j)
71 seq_printf(p, "%10u ", irq_stats(j)->irq_tlb_count);
72 seq_printf(p, " TLB shootdowns\n");
73 #endif
74 #ifdef CONFIG_X86_MCE
75 seq_printf(p, "TRM: ");
76 for_each_online_cpu(j)
77 seq_printf(p, "%10u ", irq_stats(j)->irq_thermal_count);
78 seq_printf(p, " Thermal event interrupts\n");
79 # ifdef CONFIG_X86_64
80 seq_printf(p, "THR: ");
81 for_each_online_cpu(j)
82 seq_printf(p, "%10u ", irq_stats(j)->irq_threshold_count);
83 seq_printf(p, " Threshold APIC interrupts\n");
84 # endif
85 #endif
86 #ifdef CONFIG_X86_LOCAL_APIC
87 seq_printf(p, "SPU: ");
88 for_each_online_cpu(j)
89 seq_printf(p, "%10u ", irq_stats(j)->irq_spurious_count);
90 seq_printf(p, " Spurious interrupts\n");
91 #endif
92 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
93 #if defined(CONFIG_X86_IO_APIC)
94 seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
95 #endif
96 return 0;
97 }
98
99 int show_interrupts(struct seq_file *p, void *v)
100 {
101 unsigned long flags, any_count = 0;
102 int i = *(loff_t *) v, j;
103 struct irqaction *action;
104 struct irq_desc *desc;
105
106 if (i > nr_irqs)
107 return 0;
108
109 if (i == nr_irqs)
110 return show_other_interrupts(p);
111
112 /* print header */
113 if (i == 0) {
114 seq_printf(p, " ");
115 for_each_online_cpu(j)
116 seq_printf(p, "CPU%-8d", j);
117 seq_putc(p, '\n');
118 }
119
120 desc = irq_to_desc(i);
121 if (!desc)
122 return 0;
123
124 spin_lock_irqsave(&desc->lock, flags);
125 #ifndef CONFIG_SMP
126 any_count = kstat_irqs(i);
127 #else
128 for_each_online_cpu(j)
129 any_count |= kstat_irqs_cpu(i, j);
130 #endif
131 action = desc->action;
132 if (!action && !any_count)
133 goto out;
134
135 seq_printf(p, "%3d: ", i);
136 #ifndef CONFIG_SMP
137 seq_printf(p, "%10u ", kstat_irqs(i));
138 #else
139 for_each_online_cpu(j)
140 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
141 #endif
142 seq_printf(p, " %8s", desc->chip->name);
143 seq_printf(p, "-%-8s", desc->name);
144
145 if (action) {
146 seq_printf(p, " %s", action->name);
147 while ((action = action->next) != NULL)
148 seq_printf(p, ", %s", action->name);
149 }
150
151 seq_putc(p, '\n');
152 out:
153 spin_unlock_irqrestore(&desc->lock, flags);
154 return 0;
155 }
156
157 /*
158 * /proc/stat helpers
159 */
160 u64 arch_irq_stat_cpu(unsigned int cpu)
161 {
162 u64 sum = irq_stats(cpu)->__nmi_count;
163
164 #ifdef CONFIG_X86_LOCAL_APIC
165 sum += irq_stats(cpu)->apic_timer_irqs;
166 #endif
167 #ifdef CONFIG_SMP
168 sum += irq_stats(cpu)->irq_resched_count;
169 sum += irq_stats(cpu)->irq_call_count;
170 sum += irq_stats(cpu)->irq_tlb_count;
171 #endif
172 #ifdef CONFIG_X86_MCE
173 sum += irq_stats(cpu)->irq_thermal_count;
174 # ifdef CONFIG_X86_64
175 sum += irq_stats(cpu)->irq_threshold_count;
176 #endif
177 #endif
178 #ifdef CONFIG_X86_LOCAL_APIC
179 sum += irq_stats(cpu)->irq_spurious_count;
180 #endif
181 return sum;
182 }
183
184 u64 arch_irq_stat(void)
185 {
186 u64 sum = atomic_read(&irq_err_count);
187
188 #ifdef CONFIG_X86_IO_APIC
189 sum += atomic_read(&irq_mis_count);
190 #endif
191 return sum;
192 }
This page took 0.036487 seconds and 5 git commands to generate.