blob: 313fe83a443a49ef832143de2931c658c8fdf021 [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 Carstens052ff462011-01-05 12:47:28 +010038 {.name = "NMI", .desc = "[NMI] Machine Check" },
39};
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/*
42 * show_interrupts is needed by /proc/interrupts.
43 */
44int show_interrupts(struct seq_file *p, void *v)
45{
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 int i = *(loff_t *) v, j;
47
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020048 get_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 if (i == 0) {
50 seq_puts(p, " ");
51 for_each_online_cpu(j)
52 seq_printf(p, "CPU%d ",j);
53 seq_putc(p, '\n');
54 }
55
56 if (i < NR_IRQS) {
Heiko Carstens052ff462011-01-05 12:47:28 +010057 seq_printf(p, "%s: ", intrclass_names[i].name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#ifndef CONFIG_SMP
59 seq_printf(p, "%10u ", kstat_irqs(i));
60#else
61 for_each_online_cpu(j)
62 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
63#endif
Heiko Carstens052ff462011-01-05 12:47:28 +010064 if (intrclass_names[i].desc)
65 seq_printf(p, " %s", intrclass_names[i].desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 seq_putc(p, '\n');
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 }
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020068 put_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 return 0;
70}
71
72/*
73 * For compatibilty only. S/390 specific setup of interrupts et al. is done
74 * much later in init_channel_subsystem().
75 */
76void __init
77init_IRQ(void)
78{
79 /* nothing... */
80}
81
82/*
83 * Switch to the asynchronous interrupt stack for softirq execution.
84 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085asmlinkage void do_softirq(void)
86{
87 unsigned long flags, old, new;
88
89 if (in_interrupt())
90 return;
91
92 local_irq_save(flags);
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 if (local_softirq_pending()) {
95 /* Get current stack pointer. */
96 asm volatile("la %0,0(15)" : "=a" (old));
97 /* Check against async. stack address range. */
98 new = S390_lowcore.async_stack;
99 if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
100 /* Need to switch to the async. stack. */
101 new -= STACK_FRAME_OVERHEAD;
102 ((struct stack_frame *) new)->back_chain = old;
103
104 asm volatile(" la 15,0(%0)\n"
105 " basr 14,%2\n"
106 " la 15,0(%1)\n"
107 : : "a" (new), "a" (old),
108 "a" (__do_softirq)
109 : "0", "1", "2", "3", "4", "5", "14",
110 "cc", "memory" );
111 } else
112 /* We are already on the async stack. */
113 __do_softirq();
114 }
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 local_irq_restore(flags);
117}
Heiko Carstens55dff522007-02-05 21:16:44 +0100118
Sachin Sant0addff82009-02-11 10:37:29 +0100119#ifdef CONFIG_PROC_FS
Heiko Carstens55dff522007-02-05 21:16:44 +0100120void init_irq_proc(void)
121{
122 struct proc_dir_entry *root_irq_dir;
123
124 root_irq_dir = proc_mkdir("irq", NULL);
125 create_prof_cpu_mask(root_irq_dir);
126}
Sachin Sant0addff82009-02-11 10:37:29 +0100127#endif