2 * Copyright IBM Corp. 1999,2010
3 * Author(s): Holger Smolinski <Holger.Smolinski@de.ibm.com>,
4 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 #include <linux/kernel_stat.h>
8 #include <linux/interrupt.h>
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/ftrace.h>
12 #include <linux/errno.h>
13 #include <linux/slab.h>
14 #include <asm/s390_ext.h>
15 #include <asm/irq_regs.h>
16 #include <asm/cputime.h>
17 #include <asm/lowcore.h>
22 struct ext_int_info
*next
;
23 ext_int_handler_t handler
;
28 * ext_int_hash[index] is the start of the list for all external interrupts
29 * that hash to this index. With the current set of external interrupts
30 * (0x1202 external call, 0x1004 cpu timer, 0x2401 hwc console, 0x4000
31 * iucv and 0x2603 pfault) this is always the first element.
33 static struct ext_int_info
*ext_int_hash
[256];
35 static inline int ext_hash(__u16 code
)
37 return (code
+ (code
>> 9)) & 0xff;
40 int register_external_interrupt(__u16 code
, ext_int_handler_t handler
)
42 struct ext_int_info
*p
;
45 p
= kmalloc(sizeof(*p
), GFP_ATOMIC
);
50 index
= ext_hash(code
);
51 p
->next
= ext_int_hash
[index
];
52 ext_int_hash
[index
] = p
;
55 EXPORT_SYMBOL(register_external_interrupt
);
57 int unregister_external_interrupt(__u16 code
, ext_int_handler_t handler
)
59 struct ext_int_info
*p
, *q
;
62 index
= ext_hash(code
);
64 p
= ext_int_hash
[index
];
66 if (p
->code
== code
&& p
->handler
== handler
)
76 ext_int_hash
[index
] = p
->next
;
80 EXPORT_SYMBOL(unregister_external_interrupt
);
82 void __irq_entry
do_extint(struct pt_regs
*regs
, unsigned int ext_int_code
,
83 unsigned int param32
, unsigned long param64
)
85 struct pt_regs
*old_regs
;
87 struct ext_int_info
*p
;
90 code
= (unsigned short) ext_int_code
;
91 old_regs
= set_irq_regs(regs
);
92 s390_idle_check(regs
, S390_lowcore
.int_clock
,
93 S390_lowcore
.async_enter_timer
);
95 if (S390_lowcore
.int_clock
>= S390_lowcore
.clock_comparator
)
96 /* Serve timer interrupts first. */
97 clock_comparator_work();
98 kstat_cpu(smp_processor_id()).irqs
[EXTERNAL_INTERRUPT
]++;
100 __get_cpu_var(s390_idle
).nohz_delay
= 1;
101 index
= ext_hash(code
);
102 for (p
= ext_int_hash
[index
]; p
; p
= p
->next
) {
103 if (likely(p
->code
== code
))
104 p
->handler(ext_int_code
, param32
, param64
);
107 set_irq_regs(old_regs
);