diff options
Diffstat (limited to 'arch/x86/kernel/nmi_selftest.c')
-rw-r--r-- | arch/x86/kernel/nmi_selftest.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c index 0d01a8ea4e11..2c39dcd510fa 100644 --- a/arch/x86/kernel/nmi_selftest.c +++ b/arch/x86/kernel/nmi_selftest.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/smp.h> | 12 | #include <linux/smp.h> |
13 | #include <linux/cpumask.h> | 13 | #include <linux/cpumask.h> |
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/init.h> | ||
15 | 16 | ||
16 | #include <asm/apic.h> | 17 | #include <asm/apic.h> |
17 | #include <asm/nmi.h> | 18 | #include <asm/nmi.h> |
@@ -20,35 +21,35 @@ | |||
20 | #define FAILURE 1 | 21 | #define FAILURE 1 |
21 | #define TIMEOUT 2 | 22 | #define TIMEOUT 2 |
22 | 23 | ||
23 | static int nmi_fail; | 24 | static int __initdata nmi_fail; |
24 | 25 | ||
25 | /* check to see if NMI IPIs work on this machine */ | 26 | /* check to see if NMI IPIs work on this machine */ |
26 | static DECLARE_BITMAP(nmi_ipi_mask, NR_CPUS) __read_mostly; | 27 | static DECLARE_BITMAP(nmi_ipi_mask, NR_CPUS) __initdata; |
27 | 28 | ||
28 | static int testcase_total; | 29 | static int __initdata testcase_total; |
29 | static int testcase_successes; | 30 | static int __initdata testcase_successes; |
30 | static int expected_testcase_failures; | 31 | static int __initdata expected_testcase_failures; |
31 | static int unexpected_testcase_failures; | 32 | static int __initdata unexpected_testcase_failures; |
32 | static int unexpected_testcase_unknowns; | 33 | static int __initdata unexpected_testcase_unknowns; |
33 | 34 | ||
34 | static int nmi_unk_cb(unsigned int val, struct pt_regs *regs) | 35 | static int __init nmi_unk_cb(unsigned int val, struct pt_regs *regs) |
35 | { | 36 | { |
36 | unexpected_testcase_unknowns++; | 37 | unexpected_testcase_unknowns++; |
37 | return NMI_HANDLED; | 38 | return NMI_HANDLED; |
38 | } | 39 | } |
39 | 40 | ||
40 | static void init_nmi_testsuite(void) | 41 | static void __init init_nmi_testsuite(void) |
41 | { | 42 | { |
42 | /* trap all the unknown NMIs we may generate */ | 43 | /* trap all the unknown NMIs we may generate */ |
43 | register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk"); | 44 | register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk"); |
44 | } | 45 | } |
45 | 46 | ||
46 | static void cleanup_nmi_testsuite(void) | 47 | static void __init cleanup_nmi_testsuite(void) |
47 | { | 48 | { |
48 | unregister_nmi_handler(NMI_UNKNOWN, "nmi_selftest_unk"); | 49 | unregister_nmi_handler(NMI_UNKNOWN, "nmi_selftest_unk"); |
49 | } | 50 | } |
50 | 51 | ||
51 | static int test_nmi_ipi_callback(unsigned int val, struct pt_regs *regs) | 52 | static int __init test_nmi_ipi_callback(unsigned int val, struct pt_regs *regs) |
52 | { | 53 | { |
53 | int cpu = raw_smp_processor_id(); | 54 | int cpu = raw_smp_processor_id(); |
54 | 55 | ||
@@ -58,7 +59,7 @@ static int test_nmi_ipi_callback(unsigned int val, struct pt_regs *regs) | |||
58 | return NMI_DONE; | 59 | return NMI_DONE; |
59 | } | 60 | } |
60 | 61 | ||
61 | static void test_nmi_ipi(struct cpumask *mask) | 62 | static void __init test_nmi_ipi(struct cpumask *mask) |
62 | { | 63 | { |
63 | unsigned long timeout; | 64 | unsigned long timeout; |
64 | 65 | ||
@@ -86,7 +87,7 @@ static void test_nmi_ipi(struct cpumask *mask) | |||
86 | return; | 87 | return; |
87 | } | 88 | } |
88 | 89 | ||
89 | static void remote_ipi(void) | 90 | static void __init remote_ipi(void) |
90 | { | 91 | { |
91 | cpumask_copy(to_cpumask(nmi_ipi_mask), cpu_online_mask); | 92 | cpumask_copy(to_cpumask(nmi_ipi_mask), cpu_online_mask); |
92 | cpumask_clear_cpu(smp_processor_id(), to_cpumask(nmi_ipi_mask)); | 93 | cpumask_clear_cpu(smp_processor_id(), to_cpumask(nmi_ipi_mask)); |
@@ -94,19 +95,19 @@ static void remote_ipi(void) | |||
94 | test_nmi_ipi(to_cpumask(nmi_ipi_mask)); | 95 | test_nmi_ipi(to_cpumask(nmi_ipi_mask)); |
95 | } | 96 | } |
96 | 97 | ||
97 | static void local_ipi(void) | 98 | static void __init local_ipi(void) |
98 | { | 99 | { |
99 | cpumask_clear(to_cpumask(nmi_ipi_mask)); | 100 | cpumask_clear(to_cpumask(nmi_ipi_mask)); |
100 | cpumask_set_cpu(smp_processor_id(), to_cpumask(nmi_ipi_mask)); | 101 | cpumask_set_cpu(smp_processor_id(), to_cpumask(nmi_ipi_mask)); |
101 | test_nmi_ipi(to_cpumask(nmi_ipi_mask)); | 102 | test_nmi_ipi(to_cpumask(nmi_ipi_mask)); |
102 | } | 103 | } |
103 | 104 | ||
104 | static void reset_nmi(void) | 105 | static void __init reset_nmi(void) |
105 | { | 106 | { |
106 | nmi_fail = 0; | 107 | nmi_fail = 0; |
107 | } | 108 | } |
108 | 109 | ||
109 | static void dotest(void (*testcase_fn)(void), int expected) | 110 | static void __init dotest(void (*testcase_fn)(void), int expected) |
110 | { | 111 | { |
111 | testcase_fn(); | 112 | testcase_fn(); |
112 | /* | 113 | /* |
@@ -131,12 +132,12 @@ static void dotest(void (*testcase_fn)(void), int expected) | |||
131 | reset_nmi(); | 132 | reset_nmi(); |
132 | } | 133 | } |
133 | 134 | ||
134 | static inline void print_testname(const char *testname) | 135 | static inline void __init print_testname(const char *testname) |
135 | { | 136 | { |
136 | printk("%12s:", testname); | 137 | printk("%12s:", testname); |
137 | } | 138 | } |
138 | 139 | ||
139 | void nmi_selftest(void) | 140 | void __init nmi_selftest(void) |
140 | { | 141 | { |
141 | init_nmi_testsuite(); | 142 | init_nmi_testsuite(); |
142 | 143 | ||