Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / ia64 / kernel / mca_drv.c
CommitLineData
1da177e4
LT
1/*
2 * File: mca_drv.c
3 * Purpose: Generic MCA handling layer
4 *
5 * Copyright (C) 2004 FUJITSU LIMITED
6 * Copyright (C) Hidetoshi Seto (seto.hidetoshi@jp.fujitsu.com)
7f613c7d
KO
7 * Copyright (C) 2005 Silicon Graphics, Inc
8 * Copyright (C) 2005 Keith Owens <kaos@sgi.com>
1da177e4
LT
9 */
10#include <linux/config.h>
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/sched.h>
14#include <linux/interrupt.h>
15#include <linux/irq.h>
16#include <linux/kallsyms.h>
17#include <linux/smp_lock.h>
18#include <linux/bootmem.h>
19#include <linux/acpi.h>
20#include <linux/timer.h>
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/smp.h>
24#include <linux/workqueue.h>
25#include <linux/mm.h>
26
27#include <asm/delay.h>
28#include <asm/machvec.h>
29#include <asm/page.h>
30#include <asm/ptrace.h>
31#include <asm/system.h>
32#include <asm/sal.h>
33#include <asm/mca.h>
34
35#include <asm/irq.h>
36#include <asm/hw_irq.h>
37
38#include "mca_drv.h"
39
40/* max size of SAL error record (default) */
41static int sal_rec_max = 10000;
42
1da177e4
LT
43/* from mca_drv_asm.S */
44extern void *mca_handler_bhhook(void);
45
46static DEFINE_SPINLOCK(mca_bh_lock);
47
48typedef enum {
49 MCA_IS_LOCAL = 0,
50 MCA_IS_GLOBAL = 1
51} mca_type_t;
52
53#define MAX_PAGE_ISOLATE 1024
54
55static struct page *page_isolate[MAX_PAGE_ISOLATE];
56static int num_page_isolate = 0;
57
58typedef enum {
4881e2cd
HS
59 ISOLATE_NG,
60 ISOLATE_OK,
61 ISOLATE_NONE
1da177e4
LT
62} isolate_status_t;
63
64/*
65 * This pool keeps pointers to the section part of SAL error record
66 */
67static struct {
68 slidx_list_t *buffer; /* section pointer list pool */
69 int cur_idx; /* Current index of section pointer list pool */
70 int max_idx; /* Maximum index of section pointer list pool */
71} slidx_pool;
72
73/**
74 * mca_page_isolate - isolate a poisoned page in order not to use it later
75 * @paddr: poisoned memory location
76 *
77 * Return value:
4881e2cd 78 * one of isolate_status_t, ISOLATE_OK/NG/NONE.
1da177e4
LT
79 */
80
81static isolate_status_t
82mca_page_isolate(unsigned long paddr)
83{
84 int i;
85 struct page *p;
86
87 /* whether physical address is valid or not */
20305e59 88 if (!ia64_phys_addr_valid(paddr))
4881e2cd
HS
89 return ISOLATE_NONE;
90
91 if (!pfn_valid(paddr))
92 return ISOLATE_NONE;
1da177e4
LT
93
94 /* convert physical address to physical page number */
95 p = pfn_to_page(paddr>>PAGE_SHIFT);
96
97 /* check whether a page number have been already registered or not */
20305e59
HS
98 for (i = 0; i < num_page_isolate; i++)
99 if (page_isolate[i] == p)
1da177e4
LT
100 return ISOLATE_OK; /* already listed */
101
102 /* limitation check */
20305e59 103 if (num_page_isolate == MAX_PAGE_ISOLATE)
1da177e4
LT
104 return ISOLATE_NG;
105
106 /* kick pages having attribute 'SLAB' or 'Reserved' */
20305e59 107 if (PageSlab(p) || PageReserved(p))
1da177e4
LT
108 return ISOLATE_NG;
109
110 /* add attribute 'Reserved' and register the page */
111 SetPageReserved(p);
112 page_isolate[num_page_isolate++] = p;
113
114 return ISOLATE_OK;
115}
116
117/**
118 * mca_hanlder_bh - Kill the process which occurred memory read error
119 * @paddr: poisoned address received from MCA Handler
120 */
121
122void
123mca_handler_bh(unsigned long paddr)
124{
125 printk(KERN_DEBUG "OS_MCA: process [pid: %d](%s) encounters MCA.\n",
126 current->pid, current->comm);
127
128 spin_lock(&mca_bh_lock);
4881e2cd
HS
129 switch (mca_page_isolate(paddr)) {
130 case ISOLATE_OK:
1da177e4 131 printk(KERN_DEBUG "Page isolation: ( %lx ) success.\n", paddr);
4881e2cd
HS
132 break;
133 case ISOLATE_NG:
1da177e4 134 printk(KERN_DEBUG "Page isolation: ( %lx ) failure.\n", paddr);
4881e2cd
HS
135 break;
136 default:
137 break;
1da177e4
LT
138 }
139 spin_unlock(&mca_bh_lock);
140
141 /* This process is about to be killed itself */
b1b901c2 142 do_exit(SIGKILL);
1da177e4
LT
143}
144
145/**
146 * mca_make_peidx - Make index of processor error section
147 * @slpi: pointer to record of processor error section
148 * @peidx: pointer to index of processor error section
149 */
150
20305e59 151static void
1da177e4
LT
152mca_make_peidx(sal_log_processor_info_t *slpi, peidx_table_t *peidx)
153{
20305e59 154 /*
1da177e4
LT
155 * calculate the start address of
156 * "struct cpuid_info" and "sal_processor_static_info_t".
157 */
158 u64 total_check_num = slpi->valid.num_cache_check
159 + slpi->valid.num_tlb_check
160 + slpi->valid.num_bus_check
161 + slpi->valid.num_reg_file_check
162 + slpi->valid.num_ms_check;
163 u64 head_size = sizeof(sal_log_mod_error_info_t) * total_check_num
164 + sizeof(sal_log_processor_info_t);
165 u64 mid_size = slpi->valid.cpuid_info * sizeof(struct sal_cpuid_info);
166
167 peidx_head(peidx) = slpi;
168 peidx_mid(peidx) = (struct sal_cpuid_info *)
169 (slpi->valid.cpuid_info ? ((char*)slpi + head_size) : NULL);
170 peidx_bottom(peidx) = (sal_processor_static_info_t *)
171 (slpi->valid.psi_static_struct ?
172 ((char*)slpi + head_size + mid_size) : NULL);
173}
174
175/**
20305e59 176 * mca_make_slidx - Make index of SAL error record
1da177e4
LT
177 * @buffer: pointer to SAL error record
178 * @slidx: pointer to index of SAL error record
179 *
180 * Return value:
181 * 1 if record has platform error / 0 if not
182 */
183#define LOG_INDEX_ADD_SECT_PTR(sect, ptr) \
20305e59
HS
184 {slidx_list_t *hl = &slidx_pool.buffer[slidx_pool.cur_idx]; \
185 hl->hdr = ptr; \
186 list_add(&hl->list, &(sect)); \
187 slidx_pool.cur_idx = (slidx_pool.cur_idx + 1)%slidx_pool.max_idx; }
1da177e4 188
20305e59 189static int
1da177e4
LT
190mca_make_slidx(void *buffer, slidx_table_t *slidx)
191{
192 int platform_err = 0;
193 int record_len = ((sal_log_record_header_t*)buffer)->len;
194 u32 ercd_pos;
195 int sects;
196 sal_log_section_hdr_t *sp;
197
198 /*
199 * Initialize index referring current record
200 */
201 INIT_LIST_HEAD(&(slidx->proc_err));
202 INIT_LIST_HEAD(&(slidx->mem_dev_err));
203 INIT_LIST_HEAD(&(slidx->sel_dev_err));
204 INIT_LIST_HEAD(&(slidx->pci_bus_err));
205 INIT_LIST_HEAD(&(slidx->smbios_dev_err));
206 INIT_LIST_HEAD(&(slidx->pci_comp_err));
207 INIT_LIST_HEAD(&(slidx->plat_specific_err));
208 INIT_LIST_HEAD(&(slidx->host_ctlr_err));
209 INIT_LIST_HEAD(&(slidx->plat_bus_err));
210 INIT_LIST_HEAD(&(slidx->unsupported));
211
212 /*
213 * Extract a Record Header
214 */
215 slidx->header = buffer;
216
217 /*
218 * Extract each section records
219 * (arranged from "int ia64_log_platform_info_print()")
220 */
221 for (ercd_pos = sizeof(sal_log_record_header_t), sects = 0;
222 ercd_pos < record_len; ercd_pos += sp->len, sects++) {
223 sp = (sal_log_section_hdr_t *)((char*)buffer + ercd_pos);
224 if (!efi_guidcmp(sp->guid, SAL_PROC_DEV_ERR_SECT_GUID)) {
225 LOG_INDEX_ADD_SECT_PTR(slidx->proc_err, sp);
20305e59
HS
226 } else if (!efi_guidcmp(sp->guid,
227 SAL_PLAT_MEM_DEV_ERR_SECT_GUID)) {
1da177e4
LT
228 platform_err = 1;
229 LOG_INDEX_ADD_SECT_PTR(slidx->mem_dev_err, sp);
20305e59
HS
230 } else if (!efi_guidcmp(sp->guid,
231 SAL_PLAT_SEL_DEV_ERR_SECT_GUID)) {
1da177e4
LT
232 platform_err = 1;
233 LOG_INDEX_ADD_SECT_PTR(slidx->sel_dev_err, sp);
20305e59
HS
234 } else if (!efi_guidcmp(sp->guid,
235 SAL_PLAT_PCI_BUS_ERR_SECT_GUID)) {
1da177e4
LT
236 platform_err = 1;
237 LOG_INDEX_ADD_SECT_PTR(slidx->pci_bus_err, sp);
20305e59
HS
238 } else if (!efi_guidcmp(sp->guid,
239 SAL_PLAT_SMBIOS_DEV_ERR_SECT_GUID)) {
1da177e4
LT
240 platform_err = 1;
241 LOG_INDEX_ADD_SECT_PTR(slidx->smbios_dev_err, sp);
20305e59
HS
242 } else if (!efi_guidcmp(sp->guid,
243 SAL_PLAT_PCI_COMP_ERR_SECT_GUID)) {
1da177e4
LT
244 platform_err = 1;
245 LOG_INDEX_ADD_SECT_PTR(slidx->pci_comp_err, sp);
20305e59
HS
246 } else if (!efi_guidcmp(sp->guid,
247 SAL_PLAT_SPECIFIC_ERR_SECT_GUID)) {
1da177e4
LT
248 platform_err = 1;
249 LOG_INDEX_ADD_SECT_PTR(slidx->plat_specific_err, sp);
20305e59
HS
250 } else if (!efi_guidcmp(sp->guid,
251 SAL_PLAT_HOST_CTLR_ERR_SECT_GUID)) {
1da177e4
LT
252 platform_err = 1;
253 LOG_INDEX_ADD_SECT_PTR(slidx->host_ctlr_err, sp);
20305e59
HS
254 } else if (!efi_guidcmp(sp->guid,
255 SAL_PLAT_BUS_ERR_SECT_GUID)) {
1da177e4
LT
256 platform_err = 1;
257 LOG_INDEX_ADD_SECT_PTR(slidx->plat_bus_err, sp);
258 } else {
259 LOG_INDEX_ADD_SECT_PTR(slidx->unsupported, sp);
260 }
261 }
262 slidx->n_sections = sects;
263
264 return platform_err;
265}
266
267/**
268 * init_record_index_pools - Initialize pool of lists for SAL record index
269 *
270 * Return value:
271 * 0 on Success / -ENOMEM on Failure
272 */
20305e59 273static int
1da177e4
LT
274init_record_index_pools(void)
275{
276 int i;
277 int rec_max_size; /* Maximum size of SAL error records */
278 int sect_min_size; /* Minimum size of SAL error sections */
279 /* minimum size table of each section */
20305e59
HS
280 static int sal_log_sect_min_sizes[] = {
281 sizeof(sal_log_processor_info_t)
282 + sizeof(sal_processor_static_info_t),
1da177e4
LT
283 sizeof(sal_log_mem_dev_err_info_t),
284 sizeof(sal_log_sel_dev_err_info_t),
285 sizeof(sal_log_pci_bus_err_info_t),
286 sizeof(sal_log_smbios_dev_err_info_t),
287 sizeof(sal_log_pci_comp_err_info_t),
288 sizeof(sal_log_plat_specific_err_info_t),
289 sizeof(sal_log_host_ctlr_err_info_t),
290 sizeof(sal_log_plat_bus_err_info_t),
291 };
292
293 /*
294 * MCA handler cannot allocate new memory on flight,
295 * so we preallocate enough memory to handle a SAL record.
296 *
297 * Initialize a handling set of slidx_pool:
298 * 1. Pick up the max size of SAL error records
299 * 2. Pick up the min size of SAL error sections
300 * 3. Allocate the pool as enough to 2 SAL records
301 * (now we can estimate the maxinum of section in a record.)
302 */
303
304 /* - 1 - */
305 rec_max_size = sal_rec_max;
306
307 /* - 2 - */
308 sect_min_size = sal_log_sect_min_sizes[0];
309 for (i = 1; i < sizeof sal_log_sect_min_sizes/sizeof(size_t); i++)
310 if (sect_min_size > sal_log_sect_min_sizes[i])
311 sect_min_size = sal_log_sect_min_sizes[i];
312
313 /* - 3 - */
314 slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
20305e59
HS
315 slidx_pool.buffer = (slidx_list_t *)
316 kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
1da177e4
LT
317
318 return slidx_pool.buffer ? 0 : -ENOMEM;
319}
320
321
322/*****************************************************************************
323 * Recovery functions *
324 *****************************************************************************/
325
326/**
327 * is_mca_global - Check whether this MCA is global or not
328 * @peidx: pointer of index of processor error section
329 * @pbci: pointer to pal_bus_check_info_t
20305e59 330 * @sos: pointer to hand off struct between SAL and OS
1da177e4
LT
331 *
332 * Return value:
333 * MCA_IS_LOCAL / MCA_IS_GLOBAL
334 */
335
336static mca_type_t
7f613c7d
KO
337is_mca_global(peidx_table_t *peidx, pal_bus_check_info_t *pbci,
338 struct ia64_sal_os_state *sos)
1da177e4 339{
20305e59
HS
340 pal_processor_state_info_t *psp =
341 (pal_processor_state_info_t*)peidx_psp(peidx);
1da177e4 342
20305e59 343 /*
1da177e4 344 * PAL can request a rendezvous, if the MCA has a global scope.
20305e59 345 * If "rz_always" flag is set, SAL requests MCA rendezvous
1da177e4
LT
346 * in spite of global MCA.
347 * Therefore it is local MCA when rendezvous has not been requested.
348 * Failed to rendezvous, the system must be down.
349 */
7f613c7d 350 switch (sos->rv_rc) {
1da177e4
LT
351 case -1: /* SAL rendezvous unsuccessful */
352 return MCA_IS_GLOBAL;
353 case 0: /* SAL rendezvous not required */
354 return MCA_IS_LOCAL;
355 case 1: /* SAL rendezvous successful int */
356 case 2: /* SAL rendezvous successful int with init */
357 default:
358 break;
359 }
360
361 /*
362 * If One or more Cache/TLB/Reg_File/Uarch_Check is here,
363 * it would be a local MCA. (i.e. processor internal error)
364 */
365 if (psp->tc || psp->cc || psp->rc || psp->uc)
366 return MCA_IS_LOCAL;
367
368 /*
369 * Bus_Check structure with Bus_Check.ib (internal bus error) flag set
370 * would be a global MCA. (e.g. a system bus address parity error)
371 */
372 if (!pbci || pbci->ib)
373 return MCA_IS_GLOBAL;
374
375 /*
376 * Bus_Check structure with Bus_Check.eb (external bus error) flag set
377 * could be either a local MCA or a global MCA.
378 *
379 * Referring Bus_Check.bsi:
380 * 0: Unknown/unclassified
381 * 1: BERR#
382 * 2: BINIT#
383 * 3: Hard Fail
384 * (FIXME: Are these SGI specific or generic bsi values?)
385 */
386 if (pbci->eb)
387 switch (pbci->bsi) {
388 case 0:
389 /* e.g. a load from poisoned memory */
390 return MCA_IS_LOCAL;
391 case 1:
392 case 2:
393 case 3:
394 return MCA_IS_GLOBAL;
395 }
396
397 return MCA_IS_GLOBAL;
398}
399
400/**
401 * recover_from_read_error - Try to recover the errors which type are "read"s.
402 * @slidx: pointer of index of SAL error record
403 * @peidx: pointer of index of processor error section
404 * @pbci: pointer of pal_bus_check_info
20305e59 405 * @sos: pointer to hand off struct between SAL and OS
1da177e4
LT
406 *
407 * Return value:
408 * 1 on Success / 0 on Failure
409 */
410
411static int
20305e59
HS
412recover_from_read_error(slidx_table_t *slidx,
413 peidx_table_t *peidx, pal_bus_check_info_t *pbci,
7f613c7d 414 struct ia64_sal_os_state *sos)
1da177e4
LT
415{
416 sal_log_mod_error_info_t *smei;
417 pal_min_state_area_t *pmsa;
418 struct ia64_psr *psr1, *psr2;
419 ia64_fptr_t *mca_hdlr_bh = (ia64_fptr_t*)mca_handler_bhhook;
420
421 /* Is target address valid? */
422 if (!pbci->tv)
423 return 0;
424
425 /*
426 * cpu read or memory-mapped io read
427 *
428 * offending process affected process OS MCA do
429 * kernel mode kernel mode down system
430 * kernel mode user mode kill the process
431 * user mode kernel mode down system (*)
432 * user mode user mode kill the process
433 *
434 * (*) You could terminate offending user-mode process
435 * if (pbci->pv && pbci->pl != 0) *and* if you sure
436 * the process not have any locks of kernel.
437 */
438
439 psr1 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_ipsr);
440
441 /*
442 * Check the privilege level of interrupted context.
443 * If it is user-mode, then terminate affected process.
444 */
445 if (psr1->cpl != 0) {
446 smei = peidx_bus_check(peidx, 0);
447 if (smei->valid.target_identifier) {
448 /*
449 * setup for resume to bottom half of MCA,
450 * "mca_handler_bhhook"
451 */
7f613c7d 452 pmsa = sos->pal_min_state;
1da177e4
LT
453 /* pass to bhhook as 1st argument (gr8) */
454 pmsa->pmsa_gr[8-1] = smei->target_identifier;
455 /* set interrupted return address (but no use) */
456 pmsa->pmsa_br0 = pmsa->pmsa_iip;
457 /* change resume address to bottom half */
458 pmsa->pmsa_iip = mca_hdlr_bh->fp;
459 pmsa->pmsa_gr[1-1] = mca_hdlr_bh->gp;
460 /* set cpl with kernel mode */
461 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr;
462 psr2->cpl = 0;
463 psr2->ri = 0;
b1b901c2 464 psr2->i = 0;
1da177e4
LT
465
466 return 1;
467 }
468
469 }
470
471 return 0;
472}
473
474/**
475 * recover_from_platform_error - Recover from platform error.
476 * @slidx: pointer of index of SAL error record
477 * @peidx: pointer of index of processor error section
478 * @pbci: pointer of pal_bus_check_info
20305e59 479 * @sos: pointer to hand off struct between SAL and OS
1da177e4
LT
480 *
481 * Return value:
482 * 1 on Success / 0 on Failure
483 */
484
485static int
20305e59
HS
486recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx,
487 pal_bus_check_info_t *pbci,
7f613c7d 488 struct ia64_sal_os_state *sos)
1da177e4
LT
489{
490 int status = 0;
20305e59
HS
491 pal_processor_state_info_t *psp =
492 (pal_processor_state_info_t*)peidx_psp(peidx);
1da177e4
LT
493
494 if (psp->bc && pbci->eb && pbci->bsi == 0) {
495 switch(pbci->type) {
496 case 1: /* partial read */
497 case 3: /* full line(cpu) read */
498 case 9: /* I/O space read */
20305e59
HS
499 status = recover_from_read_error(slidx, peidx, pbci,
500 sos);
1da177e4
LT
501 break;
502 case 0: /* unknown */
503 case 2: /* partial write */
504 case 4: /* full line write */
505 case 5: /* implicit or explicit write-back operation */
506 case 6: /* snoop probe */
507 case 7: /* incoming or outgoing ptc.g */
508 case 8: /* write coalescing transactions */
509 case 10: /* I/O space write */
510 case 11: /* inter-processor interrupt message(IPI) */
20305e59
HS
511 case 12: /* interrupt acknowledge or
512 external task priority cycle */
1da177e4
LT
513 default:
514 break;
515 }
516 }
517
518 return status;
519}
520
521/**
522 * recover_from_processor_error
523 * @platform: whether there are some platform error section or not
524 * @slidx: pointer of index of SAL error record
525 * @peidx: pointer of index of processor error section
526 * @pbci: pointer of pal_bus_check_info
20305e59 527 * @sos: pointer to hand off struct between SAL and OS
1da177e4
LT
528 *
529 * Return value:
530 * 1 on Success / 0 on Failure
531 */
532/*
533 * Later we try to recover when below all conditions are satisfied.
534 * 1. Only one processor error section is exist.
535 * 2. BUS_CHECK is exist and the others are not exist.(Except TLB_CHECK)
536 * 3. The entry of BUS_CHECK_INFO is 1.
537 * 4. "External bus error" flag is set and the others are not set.
538 */
539
540static int
20305e59
HS
541recover_from_processor_error(int platform, slidx_table_t *slidx,
542 peidx_table_t *peidx, pal_bus_check_info_t *pbci,
7f613c7d 543 struct ia64_sal_os_state *sos)
1da177e4 544{
20305e59
HS
545 pal_processor_state_info_t *psp =
546 (pal_processor_state_info_t*)peidx_psp(peidx);
1da177e4 547
20305e59 548 /*
1da177e4
LT
549 * We cannot recover errors with other than bus_check.
550 */
20305e59 551 if (psp->cc || psp->rc || psp->uc)
1da177e4
LT
552 return 0;
553
554 /*
555 * If there is no bus error, record is weird but we need not to recover.
556 */
557 if (psp->bc == 0 || pbci == NULL)
558 return 1;
559
560 /*
561 * Sorry, we cannot handle so many.
562 */
563 if (peidx_bus_check_num(peidx) > 1)
564 return 0;
565 /*
566 * Well, here is only one bus error.
567 */
568 if (pbci->ib || pbci->cc)
569 return 0;
570 if (pbci->eb && pbci->bsi > 0)
571 return 0;
572 if (psp->ci == 0)
573 return 0;
574
575 /*
576 * This is a local MCA and estimated as recoverble external bus error.
577 * (e.g. a load from poisoned memory)
578 * This means "there are some platform errors".
579 */
20305e59 580 if (platform)
7f613c7d 581 return recover_from_platform_error(slidx, peidx, pbci, sos);
20305e59
HS
582 /*
583 * On account of strange SAL error record, we cannot recover.
1da177e4
LT
584 */
585 return 0;
586}
587
588/**
589 * mca_try_to_recover - Try to recover from MCA
590 * @rec: pointer to a SAL error record
20305e59 591 * @sos: pointer to hand off struct between SAL and OS
1da177e4
LT
592 *
593 * Return value:
594 * 1 on Success / 0 on Failure
595 */
596
597static int
20305e59 598mca_try_to_recover(void *rec, struct ia64_sal_os_state *sos)
1da177e4
LT
599{
600 int platform_err;
601 int n_proc_err;
602 slidx_table_t slidx;
603 peidx_table_t peidx;
604 pal_bus_check_info_t pbci;
605
1da177e4
LT
606 /* Make index of SAL error record */
607 platform_err = mca_make_slidx(rec, &slidx);
608
609 /* Count processor error sections */
610 n_proc_err = slidx_count(&slidx, proc_err);
611
612 /* Now, OS can recover when there is one processor error section */
613 if (n_proc_err > 1)
614 return 0;
615 else if (n_proc_err == 0) {
616 /* Weird SAL record ... We need not to recover */
617
618 return 1;
619 }
620
621 /* Make index of processor error section */
20305e59
HS
622 mca_make_peidx((sal_log_processor_info_t*)
623 slidx_first_entry(&slidx.proc_err)->hdr, &peidx);
1da177e4
LT
624
625 /* Extract Processor BUS_CHECK[0] */
626 *((u64*)&pbci) = peidx_check_info(&peidx, bus_check, 0);
627
628 /* Check whether MCA is global or not */
7f613c7d 629 if (is_mca_global(&peidx, &pbci, sos))
1da177e4
LT
630 return 0;
631
632 /* Try to recover a processor error */
20305e59
HS
633 return recover_from_processor_error(platform_err, &slidx, &peidx,
634 &pbci, sos);
1da177e4
LT
635}
636
637/*
638 * =============================================================================
639 */
640
641int __init mca_external_handler_init(void)
642{
643 if (init_record_index_pools())
644 return -ENOMEM;
645
646 /* register external mca handlers */
20305e59 647 if (ia64_reg_MCA_extension(mca_try_to_recover)) {
1da177e4
LT
648 printk(KERN_ERR "ia64_reg_MCA_extension failed.\n");
649 kfree(slidx_pool.buffer);
650 return -EFAULT;
651 }
652 return 0;
653}
654
655void __exit mca_external_handler_exit(void)
656{
657 /* unregister external mca handlers */
658 ia64_unreg_MCA_extension();
659 kfree(slidx_pool.buffer);
660}
661
662module_init(mca_external_handler_init);
663module_exit(mca_external_handler_exit);
664
665module_param(sal_rec_max, int, 0644);
666MODULE_PARM_DESC(sal_rec_max, "Max size of SAL error record");
667
668MODULE_DESCRIPTION("ia64 platform dependent mca handler driver");
669MODULE_LICENSE("GPL");