]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - arch/blackfin/kernel/irqchip.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
[mirror_ubuntu-zesty-kernel.git] / arch / blackfin / kernel / irqchip.c
CommitLineData
1394f032 1/*
96f1050d 2 * Copyright 2005-2009 Analog Devices Inc.
1394f032 3 *
96f1050d 4 * Licensed under the GPL-2 or later
1394f032
BW
5 */
6
7#include <linux/kernel_stat.h>
8#include <linux/module.h>
9#include <linux/random.h>
10#include <linux/seq_file.h>
11#include <linux/kallsyms.h>
12#include <linux/interrupt.h>
13#include <linux/irq.h>
518039bc 14#include <asm/trace.h>
3605fb09 15#include <asm/pda.h>
1394f032 16
8f65873e 17static atomic_t irq_err_count;
1394f032
BW
18void ack_bad_irq(unsigned int irq)
19{
8f65873e 20 atomic_inc(&irq_err_count);
1394f032
BW
21 printk(KERN_ERR "IRQ: spurious interrupt %d\n", irq);
22}
1394f032 23
1394f032 24static struct irq_desc bad_irq_desc = {
1394f032 25 .handle_irq = handle_bad_irq,
71a7d155 26 .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
1394f032
BW
27};
28
e65e49d0
MT
29#ifdef CONFIG_CPUMASK_OFFSTACK
30/* We are not allocating a variable-sized bad_irq_desc.affinity */
31#error "Blackfin architecture does not support CONFIG_CPUMASK_OFFSTACK."
32#endif
33
46f288a0 34#ifdef CONFIG_PROC_FS
1394f032
BW
35int show_interrupts(struct seq_file *p, void *v)
36{
8f65873e 37 int i = *(loff_t *) v, j;
1394f032
BW
38 struct irqaction *action;
39 unsigned long flags;
40
41 if (i < NR_IRQS) {
42 spin_lock_irqsave(&irq_desc[i].lock, flags);
43 action = irq_desc[i].action;
44 if (!action)
8f65873e
GY
45 goto skip;
46 seq_printf(p, "%3d: ", i);
47 for_each_online_cpu(j)
dee4102a 48 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
8f65873e 49 seq_printf(p, " %8s", irq_desc[i].chip->name);
1394f032
BW
50 seq_printf(p, " %s", action->name);
51 for (action = action->next; action; action = action->next)
8f65873e 52 seq_printf(p, " %s", action->name);
1394f032
BW
53
54 seq_putc(p, '\n');
8f65873e 55 skip:
1394f032 56 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
3605fb09
RG
57 } else if (i == NR_IRQS) {
58 seq_printf(p, "NMI: ");
59 for_each_online_cpu(j)
60 seq_printf(p, "%10u ", cpu_pda[j].__nmi_count);
61 seq_printf(p, " CORE Non Maskable Interrupt\n");
8f65873e 62 seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
3605fb09 63 }
1394f032
BW
64 return 0;
65}
46f288a0 66#endif
1394f032 67
6f10fdab
MF
68#ifdef CONFIG_DEBUG_STACKOVERFLOW
69static void check_stack_overflow(int irq)
70{
71 /* Debugging check for stack overflow: is there less than STACK_WARN free? */
72 long sp = __get_SP() & (THREAD_SIZE - 1);
73
74 if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
75 dump_stack();
76 pr_emerg("irq%i: possible stack overflow only %ld bytes free\n",
77 irq, sp - sizeof(struct thread_info));
78 }
79}
80#else
81static inline void check_stack_overflow(int irq) { }
82#endif
83
81b79c21
MF
84#ifndef CONFIG_IPIPE
85static void maybe_lower_to_irq14(void)
86{
87 unsigned short pending, other_ints;
88
89 /*
90 * If we're the only interrupt running (ignoring IRQ15 which
91 * is for syscalls), lower our priority to IRQ14 so that
92 * softirqs run at that level. If there's another,
93 * lower-level interrupt, irq_exit will defer softirqs to
94 * that. If the interrupt pipeline is enabled, we are already
95 * running at IRQ14 priority, so we don't need this code.
96 */
97 CSYNC();
98 pending = bfin_read_IPEND() & ~0x8000;
99 other_ints = pending & (pending - 1);
100 if (other_ints == 0)
101 lower_to_irq14();
102}
103#else
104static inline void maybe_lower_to_irq14(void) { }
105#endif
106
1394f032 107/*
d2d50aa9 108 * do_IRQ handles all hardware IRQs. Decoded IRQs should not
1394f032
BW
109 * come via this function. Instead, they should provide their
110 * own 'handler'
111 */
1394f032 112#ifdef CONFIG_DO_IRQ_L1
f0b5d12f 113__attribute__((l1_text))
1394f032 114#endif
1394f032
BW
115asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
116{
26579216 117 struct pt_regs *old_regs = set_irq_regs(regs);
1394f032
BW
118
119 irq_enter();
26579216 120
6f10fdab 121 check_stack_overflow(irq);
26579216
MF
122
123 /*
124 * Some hardware gives randomly wrong interrupts. Rather
125 * than crashing, do something sensible.
126 */
127 if (irq >= NR_IRQS)
128 handle_bad_irq(irq, &bad_irq_desc);
129 else
130 generic_handle_irq(irq);
1394f032 131
81b79c21
MF
132 maybe_lower_to_irq14();
133
1394f032
BW
134 irq_exit();
135
136 set_irq_regs(old_regs);
137}
138
139void __init init_IRQ(void)
140{
1394f032 141 init_arch_irq();
518039bc
RG
142
143#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
144 /* Now that evt_ivhw is set up, turn this on */
145 trace_buff_offset = 0;
146 bfin_write_TBUFCTL(BFIN_TRACE_ON);
147 printk(KERN_INFO "Hardware Trace expanded to %ik\n",
148 1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN);
149#endif
1394f032 150}