blob: 5d7b6fbb3c13f8398856237707f196c65dad6679 [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 Carstens3fe22f62011-01-05 12:47:32 +010039 {.name = "C70", .desc = "[I/O] 3270" },
Heiko Carstensb86651722011-01-05 12:47:33 +010040 {.name = "TAP", .desc = "[I/O] Tape" },
Heiko Carstens052ff462011-01-05 12:47:28 +010041 {.name = "NMI", .desc = "[NMI] Machine Check" },
42};
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044/*
45 * show_interrupts is needed by /proc/interrupts.
46 */
47int show_interrupts(struct seq_file *p, void *v)
48{
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 int i = *(loff_t *) v, j;
50
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020051 get_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 if (i == 0) {
53 seq_puts(p, " ");
54 for_each_online_cpu(j)
55 seq_printf(p, "CPU%d ",j);
56 seq_putc(p, '\n');
57 }
58
59 if (i < NR_IRQS) {
Heiko Carstens052ff462011-01-05 12:47:28 +010060 seq_printf(p, "%s: ", intrclass_names[i].name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#ifndef CONFIG_SMP
62 seq_printf(p, "%10u ", kstat_irqs(i));
63#else
64 for_each_online_cpu(j)
65 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
66#endif
Heiko Carstens052ff462011-01-05 12:47:28 +010067 if (intrclass_names[i].desc)
68 seq_printf(p, " %s", intrclass_names[i].desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 seq_putc(p, '\n');
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 }
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020071 put_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 return 0;
73}
74
75/*
76 * For compatibilty only. S/390 specific setup of interrupts et al. is done
77 * much later in init_channel_subsystem().
78 */
79void __init
80init_IRQ(void)
81{
82 /* nothing... */
83}
84
85/*
86 * Switch to the asynchronous interrupt stack for softirq execution.
87 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088asmlinkage void do_softirq(void)
89{
90 unsigned long flags, old, new;
91
92 if (in_interrupt())
93 return;
94
95 local_irq_save(flags);
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 if (local_softirq_pending()) {
98 /* Get current stack pointer. */
99 asm volatile("la %0,0(15)" : "=a" (old));
100 /* Check against async. stack address range. */
101 new = S390_lowcore.async_stack;
102 if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
103 /* Need to switch to the async. stack. */
104 new -= STACK_FRAME_OVERHEAD;
105 ((struct stack_frame *) new)->back_chain = old;
106
107 asm volatile(" la 15,0(%0)\n"
108 " basr 14,%2\n"
109 " la 15,0(%1)\n"
110 : : "a" (new), "a" (old),
111 "a" (__do_softirq)
112 : "0", "1", "2", "3", "4", "5", "14",
113 "cc", "memory" );
114 } else
115 /* We are already on the async stack. */
116 __do_softirq();
117 }
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 local_irq_restore(flags);
120}
Heiko Carstens55dff522007-02-05 21:16:44 +0100121
Sachin Sant0addff82009-02-11 10:37:29 +0100122#ifdef CONFIG_PROC_FS
Heiko Carstens55dff522007-02-05 21:16:44 +0100123void init_irq_proc(void)
124{
125 struct proc_dir_entry *root_irq_dir;
126
127 root_irq_dir = proc_mkdir("irq", NULL);
128 create_prof_cpu_mask(root_irq_dir);
129}
Sachin Sant0addff82009-02-11 10:37:29 +0100130#endif