2 * Common interrupt code for 32 and 64 bit
5 #include <linux/interrupt.h>
6 #include <linux/kernel_stat.h>
7 #include <linux/seq_file.h>
9 #include <linux/ftrace.h>
12 #include <asm/io_apic.h>
16 atomic_t irq_err_count;
18 /* Function pointer for generic interrupt vector handling */
19 void (*generic_interrupt_extension)(void) = NULL;
22 * 'what should we do if we get a hw irq event on an illegal vector'.
23 * each architecture has to answer this themselves.
25 void ack_bad_irq(unsigned int irq)
27 printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq);
29 #ifdef CONFIG_X86_LOCAL_APIC
31 * Currently unexpected vectors happen only on SMP and APIC.
32 * We _must_ ack these because every local APIC has only N
33 * irq slots per priority level, and a 'hanging, unacked' IRQ
34 * holds up an irq slot - in excessive cases (when multiple
35 * unexpected vectors occur) that might lock up the APIC
37 * But only ack when the APIC is enabled -AK
44 #define irq_stats(x) (&per_cpu(irq_stat, x))
46 * /proc/interrupts printing:
48 static int show_other_interrupts(struct seq_file *p, int prec)
52 seq_printf(p, "%*s: ", prec, "NMI");
53 for_each_online_cpu(j)
54 seq_printf(p, "%10u ", irq_stats(j)->__nmi_count);
55 seq_printf(p, " Non-maskable interrupts\n");
56 #ifdef CONFIG_X86_LOCAL_APIC
57 seq_printf(p, "%*s: ", prec, "LOC");
58 for_each_online_cpu(j)
59 seq_printf(p, "%10u ", irq_stats(j)->apic_timer_irqs);
60 seq_printf(p, " Local timer interrupts\n");
62 if (generic_interrupt_extension) {
63 seq_printf(p, "PLT: ");
64 for_each_online_cpu(j)
65 seq_printf(p, "%10u ", irq_stats(j)->generic_irqs);
66 seq_printf(p, " Platform interrupts\n");
69 seq_printf(p, "%*s: ", prec, "RES");
70 for_each_online_cpu(j)
71 seq_printf(p, "%10u ", irq_stats(j)->irq_resched_count);
72 seq_printf(p, " Rescheduling interrupts\n");
73 seq_printf(p, "%*s: ", prec, "CAL");
74 for_each_online_cpu(j)
75 seq_printf(p, "%10u ", irq_stats(j)->irq_call_count);
76 seq_printf(p, " Function call interrupts\n");
77 seq_printf(p, "%*s: ", prec, "TLB");
78 for_each_online_cpu(j)
79 seq_printf(p, "%10u ", irq_stats(j)->irq_tlb_count);
80 seq_printf(p, " TLB shootdowns\n");
83 seq_printf(p, "%*s: ", prec, "TRM");
84 for_each_online_cpu(j)
85 seq_printf(p, "%10u ", irq_stats(j)->irq_thermal_count);
86 seq_printf(p, " Thermal event interrupts\n");
88 seq_printf(p, "%*s: ", prec, "THR");
89 for_each_online_cpu(j)
90 seq_printf(p, "%10u ", irq_stats(j)->irq_threshold_count);
91 seq_printf(p, " Threshold APIC interrupts\n");
94 #ifdef CONFIG_X86_LOCAL_APIC
95 seq_printf(p, "%*s: ", prec, "SPU");
96 for_each_online_cpu(j)
97 seq_printf(p, "%10u ", irq_stats(j)->irq_spurious_count);
98 seq_printf(p, " Spurious interrupts\n");
100 seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
101 #if defined(CONFIG_X86_IO_APIC)
102 seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
107 int show_interrupts(struct seq_file *p, void *v)
109 unsigned long flags, any_count = 0;
110 int i = *(loff_t *) v, j, prec;
111 struct irqaction *action;
112 struct irq_desc *desc;
117 for (prec = 3, j = 1000; prec < 10 && j <= nr_irqs; ++prec)
121 return show_other_interrupts(p, prec);
125 seq_printf(p, "%*s", prec + 8, "");
126 for_each_online_cpu(j)
127 seq_printf(p, "CPU%-8d", j);
131 desc = irq_to_desc(i);
135 spin_lock_irqsave(&desc->lock, flags);
137 any_count = kstat_irqs(i);
139 for_each_online_cpu(j)
140 any_count |= kstat_irqs_cpu(i, j);
142 action = desc->action;
143 if (!action && !any_count)
146 seq_printf(p, "%*d: ", prec, i);
148 seq_printf(p, "%10u ", kstat_irqs(i));
150 for_each_online_cpu(j)
151 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
153 seq_printf(p, " %8s", desc->chip->name);
154 seq_printf(p, "-%-8s", desc->name);
157 seq_printf(p, " %s", action->name);
158 while ((action = action->next) != NULL)
159 seq_printf(p, ", %s", action->name);
164 spin_unlock_irqrestore(&desc->lock, flags);
171 u64 arch_irq_stat_cpu(unsigned int cpu)
173 u64 sum = irq_stats(cpu)->__nmi_count;
175 #ifdef CONFIG_X86_LOCAL_APIC
176 sum += irq_stats(cpu)->apic_timer_irqs;
178 if (generic_interrupt_extension)
179 sum += irq_stats(cpu)->generic_irqs;
181 sum += irq_stats(cpu)->irq_resched_count;
182 sum += irq_stats(cpu)->irq_call_count;
183 sum += irq_stats(cpu)->irq_tlb_count;
185 #ifdef CONFIG_X86_MCE
186 sum += irq_stats(cpu)->irq_thermal_count;
187 # ifdef CONFIG_X86_64
188 sum += irq_stats(cpu)->irq_threshold_count;
191 #ifdef CONFIG_X86_LOCAL_APIC
192 sum += irq_stats(cpu)->irq_spurious_count;
197 u64 arch_irq_stat(void)
199 u64 sum = atomic_read(&irq_err_count);
201 #ifdef CONFIG_X86_IO_APIC
202 sum += atomic_read(&irq_mis_count);
209 * do_IRQ handles all normal device IRQ's (the special
210 * SMP cross-CPU interrupts have their own specific
213 unsigned int __irq_entry do_IRQ(struct pt_regs *regs)
215 struct pt_regs *old_regs = set_irq_regs(regs);
217 /* high bit used in ret_from_ code */
218 unsigned vector = ~regs->orig_ax;
224 irq = __get_cpu_var(vector_irq)[vector];
226 if (!handle_irq(irq, regs)) {
232 if (printk_ratelimit())
233 printk(KERN_EMERG "%s: %d.%d No irq handler for vector (irq %d)\n",
234 __func__, smp_processor_id(), vector, irq);
239 set_irq_regs(old_regs);
244 * Handler for GENERIC_INTERRUPT_VECTOR.
246 void smp_generic_interrupt(struct pt_regs *regs)
248 struct pt_regs *old_regs = set_irq_regs(regs);
256 inc_irq_stat(generic_irqs);
258 if (generic_interrupt_extension)
259 generic_interrupt_extension();
263 set_irq_regs(old_regs);
266 EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq);