ae726d1ae4304f213a70df735f6ed9efb0eb38a7
[linux-2.6.git] / arch / s390 / kernel / irq.c
1 /*
2  *    Copyright IBM Corp. 2004,2010
3  *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
4  *               Thomas Spatzier (tspat@de.ibm.com)
5  *
6  * This file contains interrupt related functions.
7  */
8
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/kernel_stat.h>
12 #include <linux/interrupt.h>
13 #include <linux/seq_file.h>
14 #include <linux/cpu.h>
15 #include <linux/proc_fs.h>
16 #include <linux/profile.h>
17
18 struct irq_class {
19         char *name;
20         char *desc;
21 };
22
23 static const struct irq_class intrclass_names[] = {
24         {.name = "EXT" },
25         {.name = "I/O" },
26         {.name = "CLK", .desc = "[EXT] Clock Comparator" },
27         {.name = "IPI", .desc = "[EXT] Signal Processor" },
28         {.name = "TMR", .desc = "[EXT] CPU Timer" },
29         {.name = "TAL", .desc = "[EXT] Timing Alert" },
30         {.name = "PFL", .desc = "[EXT] Pseudo Page Fault" },
31         {.name = "DSD", .desc = "[EXT] DASD Diag" },
32         {.name = "VRT", .desc = "[EXT] Virtio" },
33         {.name = "SCP", .desc = "[EXT] Service Call" },
34         {.name = "IUC", .desc = "[EXT] IUCV" },
35         {.name = "QAI", .desc = "[I/O] QDIO Adapter Interrupt" },
36         {.name = "QDI", .desc = "[I/O] QDIO Interrupt" },
37         {.name = "DAS", .desc = "[I/O] DASD" },
38         {.name = "C15", .desc = "[I/O] 3215" },
39         {.name = "C70", .desc = "[I/O] 3270" },
40         {.name = "TAP", .desc = "[I/O] Tape" },
41         {.name = "VMR", .desc = "[I/O] Unit Record Devices" },
42         {.name = "NMI", .desc = "[NMI] Machine Check" },
43 };
44
45 /*
46  * show_interrupts is needed by /proc/interrupts.
47  */
48 int show_interrupts(struct seq_file *p, void *v)
49 {
50         int i = *(loff_t *) v, j;
51
52         get_online_cpus();
53         if (i == 0) {
54                 seq_puts(p, "           ");
55                 for_each_online_cpu(j)
56                         seq_printf(p, "CPU%d       ",j);
57                 seq_putc(p, '\n');
58         }
59
60         if (i < NR_IRQS) {
61                 seq_printf(p, "%s: ", intrclass_names[i].name);
62 #ifndef CONFIG_SMP
63                 seq_printf(p, "%10u ", kstat_irqs(i));
64 #else
65                 for_each_online_cpu(j)
66                         seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
67 #endif
68                 if (intrclass_names[i].desc)
69                         seq_printf(p, "  %s", intrclass_names[i].desc);
70                 seq_putc(p, '\n');
71         }
72         put_online_cpus();
73         return 0;
74 }
75
76 /*
77  * For compatibilty only. S/390 specific setup of interrupts et al. is done
78  * much later in init_channel_subsystem().
79  */
80 void __init
81 init_IRQ(void)
82 {
83         /* nothing... */
84 }
85
86 /*
87  * Switch to the asynchronous interrupt stack for softirq execution.
88  */
89 asmlinkage void do_softirq(void)
90 {
91         unsigned long flags, old, new;
92
93         if (in_interrupt())
94                 return;
95
96         local_irq_save(flags);
97
98         if (local_softirq_pending()) {
99                 /* Get current stack pointer. */
100                 asm volatile("la %0,0(15)" : "=a" (old));
101                 /* Check against async. stack address range. */
102                 new = S390_lowcore.async_stack;
103                 if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
104                         /* Need to switch to the async. stack. */
105                         new -= STACK_FRAME_OVERHEAD;
106                         ((struct stack_frame *) new)->back_chain = old;
107
108                         asm volatile("   la    15,0(%0)\n"
109                                      "   basr  14,%2\n"
110                                      "   la    15,0(%1)\n"
111                                      : : "a" (new), "a" (old),
112                                          "a" (__do_softirq)
113                                      : "0", "1", "2", "3", "4", "5", "14",
114                                        "cc", "memory" );
115                 } else
116                         /* We are already on the async stack. */
117                         __do_softirq();
118         }
119
120         local_irq_restore(flags);
121 }
122
123 #ifdef CONFIG_PROC_FS
124 void init_irq_proc(void)
125 {
126         struct proc_dir_entry *root_irq_dir;
127
128         root_irq_dir = proc_mkdir("irq", NULL);
129         create_prof_cpu_mask(root_irq_dir);
130 }
131 #endif