blob: 8c241416576f3506c38a3a46dc6d63903a974a9a [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 Carstens052ff462011-01-05 12:47:28 +010040 {.name = "NMI", .desc = "[NMI] Machine Check" },
41};
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043/*
44 * show_interrupts is needed by /proc/interrupts.
45 */
46int show_interrupts(struct seq_file *p, void *v)
47{
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 int i = *(loff_t *) v, j;
49
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020050 get_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 if (i == 0) {
52 seq_puts(p, " ");
53 for_each_online_cpu(j)
54 seq_printf(p, "CPU%d ",j);
55 seq_putc(p, '\n');
56 }
57
58 if (i < NR_IRQS) {
Heiko Carstens052ff462011-01-05 12:47:28 +010059 seq_printf(p, "%s: ", intrclass_names[i].name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#ifndef CONFIG_SMP
61 seq_printf(p, "%10u ", kstat_irqs(i));
62#else
63 for_each_online_cpu(j)
64 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
65#endif
Heiko Carstens052ff462011-01-05 12:47:28 +010066 if (intrclass_names[i].desc)
67 seq_printf(p, " %s", intrclass_names[i].desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 seq_putc(p, '\n');
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 }
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020070 put_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 return 0;
72}
73
74/*
75 * For compatibilty only. S/390 specific setup of interrupts et al. is done
76 * much later in init_channel_subsystem().
77 */
78void __init
79init_IRQ(void)
80{
81 /* nothing... */
82}
83
84/*
85 * Switch to the asynchronous interrupt stack for softirq execution.
86 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087asmlinkage void do_softirq(void)
88{
89 unsigned long flags, old, new;
90
91 if (in_interrupt())
92 return;
93
94 local_irq_save(flags);
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 if (local_softirq_pending()) {
97 /* Get current stack pointer. */
98 asm volatile("la %0,0(15)" : "=a" (old));
99 /* Check against async. stack address range. */
100 new = S390_lowcore.async_stack;
101 if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
102 /* Need to switch to the async. stack. */
103 new -= STACK_FRAME_OVERHEAD;
104 ((struct stack_frame *) new)->back_chain = old;
105
106 asm volatile(" la 15,0(%0)\n"
107 " basr 14,%2\n"
108 " la 15,0(%1)\n"
109 : : "a" (new), "a" (old),
110 "a" (__do_softirq)
111 : "0", "1", "2", "3", "4", "5", "14",
112 "cc", "memory" );
113 } else
114 /* We are already on the async stack. */
115 __do_softirq();
116 }
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 local_irq_restore(flags);
119}
Heiko Carstens55dff522007-02-05 21:16:44 +0100120
Sachin Sant0addff82009-02-11 10:37:29 +0100121#ifdef CONFIG_PROC_FS
Heiko Carstens55dff522007-02-05 21:16:44 +0100122void init_irq_proc(void)
123{
124 struct proc_dir_entry *root_irq_dir;
125
126 root_irq_dir = proc_mkdir("irq", NULL);
127 create_prof_cpu_mask(root_irq_dir);
128}
Sachin Sant0addff82009-02-11 10:37:29 +0100129#endif