blob: 9bd049b8f99714ff84d7e9eda0d87f74101d395d [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" },
35 {.name = "NMI", .desc = "[NMI] Machine Check" },
36};
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038/*
39 * show_interrupts is needed by /proc/interrupts.
40 */
41int show_interrupts(struct seq_file *p, void *v)
42{
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 int i = *(loff_t *) v, j;
44
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020045 get_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 if (i == 0) {
47 seq_puts(p, " ");
48 for_each_online_cpu(j)
49 seq_printf(p, "CPU%d ",j);
50 seq_putc(p, '\n');
51 }
52
53 if (i < NR_IRQS) {
Heiko Carstens052ff462011-01-05 12:47:28 +010054 seq_printf(p, "%s: ", intrclass_names[i].name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#ifndef CONFIG_SMP
56 seq_printf(p, "%10u ", kstat_irqs(i));
57#else
58 for_each_online_cpu(j)
59 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
60#endif
Heiko Carstens052ff462011-01-05 12:47:28 +010061 if (intrclass_names[i].desc)
62 seq_printf(p, " %s", intrclass_names[i].desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 seq_putc(p, '\n');
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 }
Heiko Carstens8dd79cb2008-05-15 16:52:39 +020065 put_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 return 0;
67}
68
69/*
70 * For compatibilty only. S/390 specific setup of interrupts et al. is done
71 * much later in init_channel_subsystem().
72 */
73void __init
74init_IRQ(void)
75{
76 /* nothing... */
77}
78
79/*
80 * Switch to the asynchronous interrupt stack for softirq execution.
81 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070082asmlinkage void do_softirq(void)
83{
84 unsigned long flags, old, new;
85
86 if (in_interrupt())
87 return;
88
89 local_irq_save(flags);
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 if (local_softirq_pending()) {
92 /* Get current stack pointer. */
93 asm volatile("la %0,0(15)" : "=a" (old));
94 /* Check against async. stack address range. */
95 new = S390_lowcore.async_stack;
96 if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
97 /* Need to switch to the async. stack. */
98 new -= STACK_FRAME_OVERHEAD;
99 ((struct stack_frame *) new)->back_chain = old;
100
101 asm volatile(" la 15,0(%0)\n"
102 " basr 14,%2\n"
103 " la 15,0(%1)\n"
104 : : "a" (new), "a" (old),
105 "a" (__do_softirq)
106 : "0", "1", "2", "3", "4", "5", "14",
107 "cc", "memory" );
108 } else
109 /* We are already on the async stack. */
110 __do_softirq();
111 }
112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 local_irq_restore(flags);
114}
Heiko Carstens55dff522007-02-05 21:16:44 +0100115
Sachin Sant0addff82009-02-11 10:37:29 +0100116#ifdef CONFIG_PROC_FS
Heiko Carstens55dff522007-02-05 21:16:44 +0100117void init_irq_proc(void)
118{
119 struct proc_dir_entry *root_irq_dir;
120
121 root_irq_dir = proc_mkdir("irq", NULL);
122 create_prof_cpu_mask(root_irq_dir);
123}
Sachin Sant0addff82009-02-11 10:37:29 +0100124#endif