diff options
Diffstat (limited to 'arch/x86/kernel/cpu/mcheck/mce.c')
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce.c | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 2af127d4c3d1..cbe82b5918ce 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
@@ -95,13 +95,6 @@ static DECLARE_WAIT_QUEUE_HEAD(mce_chrdev_wait); | |||
95 | static DEFINE_PER_CPU(struct mce, mces_seen); | 95 | static DEFINE_PER_CPU(struct mce, mces_seen); |
96 | static int cpu_missing; | 96 | static int cpu_missing; |
97 | 97 | ||
98 | /* | ||
99 | * CPU/chipset specific EDAC code can register a notifier call here to print | ||
100 | * MCE errors in a human-readable form. | ||
101 | */ | ||
102 | ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain); | ||
103 | EXPORT_SYMBOL_GPL(x86_mce_decoder_chain); | ||
104 | |||
105 | /* MCA banks polled by the period polling timer for corrected events */ | 98 | /* MCA banks polled by the period polling timer for corrected events */ |
106 | DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = { | 99 | DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = { |
107 | [0 ... BITS_TO_LONGS(MAX_NR_BANKS)-1] = ~0UL | 100 | [0 ... BITS_TO_LONGS(MAX_NR_BANKS)-1] = ~0UL |
@@ -109,6 +102,12 @@ DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = { | |||
109 | 102 | ||
110 | static DEFINE_PER_CPU(struct work_struct, mce_work); | 103 | static DEFINE_PER_CPU(struct work_struct, mce_work); |
111 | 104 | ||
105 | /* | ||
106 | * CPU/chipset specific EDAC code can register a notifier call here to print | ||
107 | * MCE errors in a human-readable form. | ||
108 | */ | ||
109 | ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain); | ||
110 | |||
112 | /* Do initial initialization of a struct mce */ | 111 | /* Do initial initialization of a struct mce */ |
113 | void mce_setup(struct mce *m) | 112 | void mce_setup(struct mce *m) |
114 | { | 113 | { |
@@ -119,9 +118,7 @@ void mce_setup(struct mce *m) | |||
119 | m->time = get_seconds(); | 118 | m->time = get_seconds(); |
120 | m->cpuvendor = boot_cpu_data.x86_vendor; | 119 | m->cpuvendor = boot_cpu_data.x86_vendor; |
121 | m->cpuid = cpuid_eax(1); | 120 | m->cpuid = cpuid_eax(1); |
122 | #ifdef CONFIG_SMP | ||
123 | m->socketid = cpu_data(m->extcpu).phys_proc_id; | 121 | m->socketid = cpu_data(m->extcpu).phys_proc_id; |
124 | #endif | ||
125 | m->apicid = cpu_data(m->extcpu).initial_apicid; | 122 | m->apicid = cpu_data(m->extcpu).initial_apicid; |
126 | rdmsrl(MSR_IA32_MCG_CAP, m->mcgcap); | 123 | rdmsrl(MSR_IA32_MCG_CAP, m->mcgcap); |
127 | } | 124 | } |
@@ -190,6 +187,57 @@ void mce_log(struct mce *mce) | |||
190 | set_bit(0, &mce_need_notify); | 187 | set_bit(0, &mce_need_notify); |
191 | } | 188 | } |
192 | 189 | ||
190 | static void drain_mcelog_buffer(void) | ||
191 | { | ||
192 | unsigned int next, i, prev = 0; | ||
193 | |||
194 | next = rcu_dereference_check_mce(mcelog.next); | ||
195 | |||
196 | do { | ||
197 | struct mce *m; | ||
198 | |||
199 | /* drain what was logged during boot */ | ||
200 | for (i = prev; i < next; i++) { | ||
201 | unsigned long start = jiffies; | ||
202 | unsigned retries = 1; | ||
203 | |||
204 | m = &mcelog.entry[i]; | ||
205 | |||
206 | while (!m->finished) { | ||
207 | if (time_after_eq(jiffies, start + 2*retries)) | ||
208 | retries++; | ||
209 | |||
210 | cpu_relax(); | ||
211 | |||
212 | if (!m->finished && retries >= 4) { | ||
213 | pr_err("MCE: skipping error being logged currently!\n"); | ||
214 | break; | ||
215 | } | ||
216 | } | ||
217 | smp_rmb(); | ||
218 | atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, m); | ||
219 | } | ||
220 | |||
221 | memset(mcelog.entry + prev, 0, (next - prev) * sizeof(*m)); | ||
222 | prev = next; | ||
223 | next = cmpxchg(&mcelog.next, prev, 0); | ||
224 | } while (next != prev); | ||
225 | } | ||
226 | |||
227 | |||
228 | void mce_register_decode_chain(struct notifier_block *nb) | ||
229 | { | ||
230 | atomic_notifier_chain_register(&x86_mce_decoder_chain, nb); | ||
231 | drain_mcelog_buffer(); | ||
232 | } | ||
233 | EXPORT_SYMBOL_GPL(mce_register_decode_chain); | ||
234 | |||
235 | void mce_unregister_decode_chain(struct notifier_block *nb) | ||
236 | { | ||
237 | atomic_notifier_chain_unregister(&x86_mce_decoder_chain, nb); | ||
238 | } | ||
239 | EXPORT_SYMBOL_GPL(mce_unregister_decode_chain); | ||
240 | |||
193 | static void print_mce(struct mce *m) | 241 | static void print_mce(struct mce *m) |
194 | { | 242 | { |
195 | int ret = 0; | 243 | int ret = 0; |