blob: e7914e4adc48d4b043f19b2d5e5981ced114f9fe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Heiko Carstens052ff462011-01-05 12:47:28 +01002 * Copyright IBM Corp. 2004,2010
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
Heiko Carstens55dff522007-02-05 21:16:44 +01004 * Thomas Spatzier (tspat@de.ibm.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
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>
Heiko Carstens55dff522007-02-05 21:16:44 +010015#include <linux/proc_fs.h>
16#include <linux/profile.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Heiko Carstens052ff462011-01-05 12:47:28 +010018struct irq_class {
19 char *name;
20 char *desc;
21};
22
23static 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" },
Jan Glauber30d77c32011-01-05 12:47:29 +010035 {.name = "QAI", .desc = "[I/O] QDIO Adapter Interrupt" },
36 {.name = "QDI", .desc = "[I/O] QDIO Interrupt" },
Heiko Carstens32839422011-01-05 12:47:30 +010037 {.name = "DAS", .desc = "[I/O] DASD" },
Heiko Carstens12fae582011-01-05 12:47:31 +010038 {.name = "C15", .desc = "[I/O] 3215" },
Heiko Carstens052ff462011-01-05 12:47:28 +010039 {.name = "NMI", .desc = "[NMI] Machine Check" },
40};
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042/*
43 * show_interrupts is needed by /proc/interrupts.
44 */
45int show_interrupts(struct seq_file *p, void *v)
46{
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 int i = *(loff_t *) v, j;
48
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020049 get_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 if (i == 0) {
51 seq_puts(p, " ");
52 for_each_online_cpu(j)
53 seq_printf(p, "CPU%d ",j);
54 seq_putc(p, '\n');
55 }
56
57 if (i < NR_IRQS) {
Heiko Carstens052ff462011-01-05 12:47:28 +010058 seq_printf(p, "%s: ", intrclass_names[i].name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#ifndef CONFIG_SMP
60 seq_printf(p, "%10u ", kstat_irqs(i));
61#else
62 for_each_online_cpu(j)
63 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
64#endif
Heiko Carstens052ff462011-01-05 12:47:28 +010065 if (intrclass_names[i].desc)
66 seq_printf(p, " %s", intrclass_names[i].desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 seq_putc(p, '\n');
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 }
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020069 put_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 return 0;
71}
72
73/*
74 * For compatibilty only. S/390 specific setup of interrupts et al. is done
75 * much later in init_channel_subsystem().
76 */
77void __init
78init_IRQ(void)
79{
80 /* nothing... */
81}
82
83/*
84 * Switch to the asynchronous interrupt stack for softirq execution.
85 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086asmlinkage void do_softirq(void)
87{
88 unsigned long flags, old, new;
89
90 if (in_interrupt())
91 return;
92
93 local_irq_save(flags);
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 if (local_softirq_pending()) {
96 /* Get current stack pointer. */
97 asm volatile("la %0,0(15)" : "=a" (old));
98 /* Check against async. stack address range. */
99 new = S390_lowcore.async_stack;
100 if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
101 /* Need to switch to the async. stack. */
102 new -= STACK_FRAME_OVERHEAD;
103 ((struct stack_frame *) new)->back_chain = old;
104
105 asm volatile(" la 15,0(%0)\n"
106 " basr 14,%2\n"
107 " la 15,0(%1)\n"
108 : : "a" (new), "a" (old),
109 "a" (__do_softirq)
110 : "0", "1", "2", "3", "4", "5", "14",
111 "cc", "memory" );
112 } else
113 /* We are already on the async stack. */
114 __do_softirq();
115 }
116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 local_irq_restore(flags);
118}
Heiko Carstens55dff522007-02-05 21:16:44 +0100119
Sachin Sant0addff82009-02-11 10:37:29 +0100120#ifdef CONFIG_PROC_FS
Heiko Carstens55dff522007-02-05 21:16:44 +0100121void init_irq_proc(void)
122{
123 struct proc_dir_entry *root_irq_dir;
124
125 root_irq_dir = proc_mkdir("irq", NULL);
126 create_prof_cpu_mask(root_irq_dir);
127}
Sachin Sant0addff82009-02-11 10:37:29 +0100128#endif