]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
MIPS: Add NMI notifier
authorKevin Cernekee <cernekee@gmail.com>
Wed, 16 Nov 2011 01:25:44 +0000 (01:25 +0000)
committerRalf Baechle <ralf@linux-mips.org>
Wed, 16 Nov 2011 01:25:44 +0000 (01:25 +0000)
Allow the board support code to register a raw notifier callback for
NMI, similar to what is done for CU2 exceptions.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2958/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/traps.h
arch/mips/kernel/traps.c

index 90ff2f497c500f84d925773584c4c148356dd793..4edab87eebd276e844d3a0e8bef6a05c3c18d2de 100644 (file)
@@ -25,4 +25,16 @@ extern void (*board_nmi_handler_setup)(void);
 extern void (*board_ejtag_handler_setup)(void);
 extern void (*board_bind_eic_interrupt)(int irq, int regset);
 
+extern int register_nmi_notifier(struct notifier_block *nb);
+
+#define nmi_notifier(fn, pri)                                          \
+({                                                                     \
+       static struct notifier_block fn##_nb = {                        \
+               .notifier_call = fn,                                    \
+               .priority = pri                                         \
+       };                                                              \
+                                                                       \
+       register_nmi_notifier(&fn##_nb);                                \
+})
+
 #endif /* _ASM_TRAPS_H */
index 261ccbc0774016aa6d055eb19dd82067f7ad65e8..46b8b7dd5ed831682ab435f5be01bdf5305140fb 100644 (file)
@@ -1339,9 +1339,18 @@ void ejtag_exception_handler(struct pt_regs *regs)
 
 /*
  * NMI exception handler.
+ * No lock; only written during early bootup by CPU 0.
  */
+static RAW_NOTIFIER_HEAD(nmi_chain);
+
+int register_nmi_notifier(struct notifier_block *nb)
+{
+       return raw_notifier_chain_register(&nmi_chain, nb);
+}
+
 NORET_TYPE void ATTRIB_NORET nmi_exception_handler(struct pt_regs *regs)
 {
+       raw_notifier_call_chain(&nmi_chain, 0, regs);
        bust_spinlocks(1);
        printk("NMI taken!!!!\n");
        die("NMI", regs);