3 * Purpose: Generic MCA handling layer
5 * Copyright (C) 2003 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
8 * Copyright (C) 2002 Dell Inc.
9 * Copyright (C) Matt Domsch <Matt_Domsch@dell.com>
11 * Copyright (C) 2002 Intel
12 * Copyright (C) Jenna Hall <jenna.s.hall@intel.com>
14 * Copyright (C) 2001 Intel
15 * Copyright (C) Fred Lewis <frederick.v.lewis@intel.com>
17 * Copyright (C) 2000 Intel
18 * Copyright (C) Chuck Fleckenstein <cfleck@co.intel.com>
20 * Copyright (C) 1999, 2004-2008 Silicon Graphics, Inc.
21 * Copyright (C) Vijay Chander <vijay@engr.sgi.com>
23 * Copyright (C) 2006 FUJITSU LIMITED
24 * Copyright (C) Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
26 * 2000-03-29 Chuck Fleckenstein <cfleck@co.intel.com>
27 * Fixed PAL/SAL update issues, began MCA bug fixes, logging issues,
28 * added min save state dump, added INIT handler.
30 * 2001-01-03 Fred Lewis <frederick.v.lewis@intel.com>
31 * Added setup of CMCI and CPEI IRQs, logging of corrected platform
32 * errors, completed code for logging of corrected & uncorrected
33 * machine check errors, and updated for conformance with Nov. 2000
34 * revision of the SAL 3.0 spec.
36 * 2002-01-04 Jenna Hall <jenna.s.hall@intel.com>
37 * Aligned MCA stack to 16 bytes, added platform vs. CPU error flag,
38 * set SAL default return values, changed error record structure to
39 * linked list, added init call to sal_get_state_info_size().
41 * 2002-03-25 Matt Domsch <Matt_Domsch@dell.com>
44 * 2003-04-15 David Mosberger-Tang <davidm@hpl.hp.com>
45 * Added INIT backtrace support.
47 * 2003-12-08 Keith Owens <kaos@sgi.com>
48 * smp_call_function() must not be called from interrupt context
49 * (can deadlock on tasklist_lock).
50 * Use keventd to call smp_call_function().
52 * 2004-02-01 Keith Owens <kaos@sgi.com>
53 * Avoid deadlock when using printk() for MCA and INIT records.
54 * Delete all record printing code, moved to salinfo_decode in user
55 * space. Mark variables and functions static where possible.
56 * Delete dead variables and functions. Reorder to remove the need
57 * for forward declarations and to consolidate related code.
59 * 2005-08-12 Keith Owens <kaos@sgi.com>
60 * Convert MCA/INIT handlers to use per event stacks and SAL/OS
63 * 2005-10-07 Keith Owens <kaos@sgi.com>
64 * Add notify_die() hooks.
66 * 2006-09-15 Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
67 * Add printing support for MCA/INIT.
69 * 2007-04-27 Russ Anderson <rja@sgi.com>
70 * Support multiple cpus going through OS_MCA in the same event.
72 #include <linux/types.h>
73 #include <linux/init.h>
74 #include <linux/sched.h>
75 #include <linux/interrupt.h>
76 #include <linux/irq.h>
77 #include <linux/bootmem.h>
78 #include <linux/acpi.h>
79 #include <linux/timer.h>
80 #include <linux/module.h>
81 #include <linux/kernel.h>
82 #include <linux/smp.h>
83 #include <linux/workqueue.h>
84 #include <linux/cpumask.h>
85 #include <linux/kdebug.h>
86 #include <linux/cpu.h>
88 #include <asm/delay.h>
89 #include <asm/machvec.h>
90 #include <asm/meminit.h>
92 #include <asm/ptrace.h>
93 #include <asm/system.h>
96 #include <asm/kexec.h>
99 #include <asm/hw_irq.h>
104 #if defined(IA64_MCA_DEBUG_INFO)
105 # define IA64_MCA_DEBUG(fmt...) printk(fmt)
107 # define IA64_MCA_DEBUG(fmt...)
110 /* Used by mca_asm.S */
111 DEFINE_PER_CPU(u64
, ia64_mca_data
); /* == __per_cpu_mca[smp_processor_id()] */
112 DEFINE_PER_CPU(u64
, ia64_mca_per_cpu_pte
); /* PTE to map per-CPU area */
113 DEFINE_PER_CPU(u64
, ia64_mca_pal_pte
); /* PTE to map PAL code */
114 DEFINE_PER_CPU(u64
, ia64_mca_pal_base
); /* vaddr PAL code granule */
116 unsigned long __per_cpu_mca
[NR_CPUS
];
119 extern void ia64_os_init_dispatch_monarch (void);
120 extern void ia64_os_init_dispatch_slave (void);
122 static int monarch_cpu
= -1;
124 static ia64_mc_info_t ia64_mc_info
;
126 #define MAX_CPE_POLL_INTERVAL (15*60*HZ) /* 15 minutes */
127 #define MIN_CPE_POLL_INTERVAL (2*60*HZ) /* 2 minutes */
128 #define CMC_POLL_INTERVAL (1*60*HZ) /* 1 minute */
129 #define CPE_HISTORY_LENGTH 5
130 #define CMC_HISTORY_LENGTH 5
133 static struct timer_list cpe_poll_timer
;
135 static struct timer_list cmc_poll_timer
;
137 * This variable tells whether we are currently in polling mode.
138 * Start with this in the wrong state so we won't play w/ timers
139 * before the system is ready.
141 static int cmc_polling_enabled
= 1;
144 * Clearing this variable prevents CPE polling from getting activated
145 * in mca_late_init. Use it if your system doesn't provide a CPEI,
146 * but encounters problems retrieving CPE logs. This should only be
147 * necessary for debugging.
149 static int cpe_poll_enabled
= 1;
151 extern void salinfo_log_wakeup(int type
, u8
*buffer
, u64 size
, int irqsafe
);
153 static int mca_init __initdata
;
156 * limited & delayed printing support for MCA/INIT handler
159 #define mprintk(fmt...) ia64_mca_printk(fmt)
161 #define MLOGBUF_SIZE (512+256*NR_CPUS)
162 #define MLOGBUF_MSGMAX 256
163 static char mlogbuf
[MLOGBUF_SIZE
];
164 static DEFINE_SPINLOCK(mlogbuf_wlock
); /* mca context only */
165 static DEFINE_SPINLOCK(mlogbuf_rlock
); /* normal context only */
166 static unsigned long mlogbuf_start
;
167 static unsigned long mlogbuf_end
;
168 static unsigned int mlogbuf_finished
= 0;
169 static unsigned long mlogbuf_timestamp
= 0;
171 static int loglevel_save
= -1;
172 #define BREAK_LOGLEVEL(__console_loglevel) \
173 oops_in_progress = 1; \
174 if (loglevel_save < 0) \
175 loglevel_save = __console_loglevel; \
176 __console_loglevel = 15;
178 #define RESTORE_LOGLEVEL(__console_loglevel) \
179 if (loglevel_save >= 0) { \
180 __console_loglevel = loglevel_save; \
181 loglevel_save = -1; \
183 mlogbuf_finished = 0; \
184 oops_in_progress = 0;
187 * Push messages into buffer, print them later if not urgent.
189 void ia64_mca_printk(const char *fmt
, ...)
193 char temp_buf
[MLOGBUF_MSGMAX
];
197 printed_len
= vscnprintf(temp_buf
, sizeof(temp_buf
), fmt
, args
);
200 /* Copy the output into mlogbuf */
201 if (oops_in_progress
) {
202 /* mlogbuf was abandoned, use printk directly instead. */
205 spin_lock(&mlogbuf_wlock
);
206 for (p
= temp_buf
; *p
; p
++) {
207 unsigned long next
= (mlogbuf_end
+ 1) % MLOGBUF_SIZE
;
208 if (next
!= mlogbuf_start
) {
209 mlogbuf
[mlogbuf_end
] = *p
;
216 mlogbuf
[mlogbuf_end
] = '\0';
217 spin_unlock(&mlogbuf_wlock
);
220 EXPORT_SYMBOL(ia64_mca_printk
);
223 * Print buffered messages.
224 * NOTE: call this after returning normal context. (ex. from salinfod)
226 void ia64_mlogbuf_dump(void)
228 char temp_buf
[MLOGBUF_MSGMAX
];
232 unsigned int printed_len
;
234 /* Get output from mlogbuf */
235 while (mlogbuf_start
!= mlogbuf_end
) {
240 spin_lock_irqsave(&mlogbuf_rlock
, flags
);
242 index
= mlogbuf_start
;
243 while (index
!= mlogbuf_end
) {
245 index
= (index
+ 1) % MLOGBUF_SIZE
;
249 if (++printed_len
>= MLOGBUF_MSGMAX
- 1)
255 mlogbuf_start
= index
;
257 mlogbuf_timestamp
= 0;
258 spin_unlock_irqrestore(&mlogbuf_rlock
, flags
);
261 EXPORT_SYMBOL(ia64_mlogbuf_dump
);
264 * Call this if system is going to down or if immediate flushing messages to
265 * console is required. (ex. recovery was failed, crash dump is going to be
266 * invoked, long-wait rendezvous etc.)
267 * NOTE: this should be called from monarch.
269 static void ia64_mlogbuf_finish(int wait
)
271 BREAK_LOGLEVEL(console_loglevel
);
273 spin_lock_init(&mlogbuf_rlock
);
275 printk(KERN_EMERG
"mlogbuf_finish: printing switched to urgent mode, "
276 "MCA/INIT might be dodgy or fail.\n");
281 /* wait for console */
282 printk("Delaying for 5 seconds...\n");
285 mlogbuf_finished
= 1;
289 * Print buffered messages from INIT context.
291 static void ia64_mlogbuf_dump_from_init(void)
293 if (mlogbuf_finished
)
296 if (mlogbuf_timestamp
&& (mlogbuf_timestamp
+ 30*HZ
> jiffies
)) {
297 printk(KERN_ERR
"INIT: mlogbuf_dump is interrupted by INIT "
298 " and the system seems to be messed up.\n");
299 ia64_mlogbuf_finish(0);
303 if (!spin_trylock(&mlogbuf_rlock
)) {
304 printk(KERN_ERR
"INIT: mlogbuf_dump is interrupted by INIT. "
305 "Generated messages other than stack dump will be "
306 "buffered to mlogbuf and will be printed later.\n");
307 printk(KERN_ERR
"INIT: If messages would not printed after "
308 "this INIT, wait 30sec and assert INIT again.\n");
309 if (!mlogbuf_timestamp
)
310 mlogbuf_timestamp
= jiffies
;
313 spin_unlock(&mlogbuf_rlock
);
318 ia64_mca_spin(const char *func
)
320 if (monarch_cpu
== smp_processor_id())
321 ia64_mlogbuf_finish(0);
322 mprintk(KERN_EMERG
"%s: spinning here, not returning to SAL\n", func
);
327 * IA64_MCA log support
329 #define IA64_MAX_LOGS 2 /* Double-buffering for nested MCAs */
330 #define IA64_MAX_LOG_TYPES 4 /* MCA, INIT, CMC, CPE */
332 typedef struct ia64_state_log_s
336 unsigned long isl_count
;
337 ia64_err_rec_t
*isl_log
[IA64_MAX_LOGS
]; /* need space to store header + error log */
340 static ia64_state_log_t ia64_state_log
[IA64_MAX_LOG_TYPES
];
342 #define IA64_LOG_ALLOCATE(it, size) \
343 {ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \
344 (ia64_err_rec_t *)alloc_bootmem(size); \
345 ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \
346 (ia64_err_rec_t *)alloc_bootmem(size);}
347 #define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock)
348 #define IA64_LOG_LOCK(it) spin_lock_irqsave(&ia64_state_log[it].isl_lock, s)
349 #define IA64_LOG_UNLOCK(it) spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s)
350 #define IA64_LOG_NEXT_INDEX(it) ia64_state_log[it].isl_index
351 #define IA64_LOG_CURR_INDEX(it) 1 - ia64_state_log[it].isl_index
352 #define IA64_LOG_INDEX_INC(it) \
353 {ia64_state_log[it].isl_index = 1 - ia64_state_log[it].isl_index; \
354 ia64_state_log[it].isl_count++;}
355 #define IA64_LOG_INDEX_DEC(it) \
356 ia64_state_log[it].isl_index = 1 - ia64_state_log[it].isl_index
357 #define IA64_LOG_NEXT_BUFFER(it) (void *)((ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)]))
358 #define IA64_LOG_CURR_BUFFER(it) (void *)((ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)]))
359 #define IA64_LOG_COUNT(it) ia64_state_log[it].isl_count
363 * Reset the OS ia64 log buffer
364 * Inputs : info_type (SAL_INFO_TYPE_{MCA,INIT,CMC,CPE})
368 ia64_log_init(int sal_info_type
)
372 IA64_LOG_NEXT_INDEX(sal_info_type
) = 0;
373 IA64_LOG_LOCK_INIT(sal_info_type
);
375 // SAL will tell us the maximum size of any error record of this type
376 max_size
= ia64_sal_get_state_info_size(sal_info_type
);
378 /* alloc_bootmem() doesn't like zero-sized allocations! */
381 // set up OS data structures to hold error info
382 IA64_LOG_ALLOCATE(sal_info_type
, max_size
);
383 memset(IA64_LOG_CURR_BUFFER(sal_info_type
), 0, max_size
);
384 memset(IA64_LOG_NEXT_BUFFER(sal_info_type
), 0, max_size
);
390 * Get the current MCA log from SAL and copy it into the OS log buffer.
392 * Inputs : info_type (SAL_INFO_TYPE_{MCA,INIT,CMC,CPE})
393 * irq_safe whether you can use printk at this point
394 * Outputs : size (total record length)
395 * *buffer (ptr to error record)
399 ia64_log_get(int sal_info_type
, u8
**buffer
, int irq_safe
)
401 sal_log_record_header_t
*log_buffer
;
405 IA64_LOG_LOCK(sal_info_type
);
407 /* Get the process state information */
408 log_buffer
= IA64_LOG_NEXT_BUFFER(sal_info_type
);
410 total_len
= ia64_sal_get_state_info(sal_info_type
, (u64
*)log_buffer
);
413 IA64_LOG_INDEX_INC(sal_info_type
);
414 IA64_LOG_UNLOCK(sal_info_type
);
416 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
417 IA64_MCA_DEBUG("%s: SAL error record type %d retrieved. "
418 "Record length = %ld\n", __FUNCTION__
, sal_info_type
, total_len
);
420 IA64_MCA_DEBUG("%s: SAL error record type %d retrieved. Record length = %ld\n",
421 __func__
, sal_info_type
, total_len
);
422 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
424 *buffer
= (u8
*) log_buffer
;
427 IA64_LOG_UNLOCK(sal_info_type
);
433 * ia64_mca_log_sal_error_record
435 * This function retrieves a specified error record type from SAL
436 * and wakes up any processes waiting for error records.
438 * Inputs : sal_info_type (Type of error record MCA/CMC/CPE)
439 * FIXME: remove MCA and irq_safe.
442 ia64_mca_log_sal_error_record(int sal_info_type
)
445 sal_log_record_header_t
*rh
;
447 int irq_safe
= sal_info_type
!= SAL_INFO_TYPE_MCA
;
448 #ifdef IA64_MCA_DEBUG_INFO
449 static const char * const rec_name
[] = { "MCA", "INIT", "CMC", "CPE" };
452 size
= ia64_log_get(sal_info_type
, &buffer
, irq_safe
);
456 salinfo_log_wakeup(sal_info_type
, buffer
, size
, irq_safe
);
459 IA64_MCA_DEBUG("CPU %d: SAL log contains %s error record\n",
461 sal_info_type
< ARRAY_SIZE(rec_name
) ? rec_name
[sal_info_type
] : "UNKNOWN");
463 /* Clear logs from corrected errors in case there's no user-level logger */
464 rh
= (sal_log_record_header_t
*)buffer
;
465 if (rh
->severity
== sal_log_severity_corrected
)
466 ia64_sal_clear_state_info(sal_info_type
);
471 * See if the MCA surfaced in an instruction range
472 * that has been tagged as recoverable.
475 * first First address range to check
476 * last Last address range to check
477 * ip Instruction pointer, address we are looking for
480 * 1 on Success (in the table)/ 0 on Failure (not in the table)
483 search_mca_table (const struct mca_table_entry
*first
,
484 const struct mca_table_entry
*last
,
487 const struct mca_table_entry
*curr
;
488 u64 curr_start
, curr_end
;
491 while (curr
<= last
) {
492 curr_start
= (u64
) &curr
->start_addr
+ curr
->start_addr
;
493 curr_end
= (u64
) &curr
->end_addr
+ curr
->end_addr
;
495 if ((ip
>= curr_start
) && (ip
<= curr_end
)) {
503 /* Given an address, look for it in the mca tables. */
504 int mca_recover_range(unsigned long addr
)
506 extern struct mca_table_entry __start___mca_table
[];
507 extern struct mca_table_entry __stop___mca_table
[];
509 return search_mca_table(__start___mca_table
, __stop___mca_table
-1, addr
);
511 EXPORT_SYMBOL_GPL(mca_recover_range
);
516 int ia64_cpe_irq
= -1;
519 ia64_mca_cpe_int_handler (int cpe_irq
, void *arg
)
521 static unsigned long cpe_history
[CPE_HISTORY_LENGTH
];
523 static DEFINE_SPINLOCK(cpe_history_lock
);
525 IA64_MCA_DEBUG("%s: received interrupt vector = %#x on CPU %d\n",
526 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
527 __FUNCTION__
, cpe_irq
, smp_processor_id());
529 __func__
, cpe_irq
, smp_processor_id());
530 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
532 /* SAL spec states this should run w/ interrupts enabled */
535 spin_lock(&cpe_history_lock
);
536 if (!cpe_poll_enabled
&& cpe_vector
>= 0) {
538 int i
, count
= 1; /* we know 1 happened now */
539 unsigned long now
= jiffies
;
541 for (i
= 0; i
< CPE_HISTORY_LENGTH
; i
++) {
542 if (now
- cpe_history
[i
] <= HZ
)
546 IA64_MCA_DEBUG(KERN_INFO
"CPE threshold %d/%d\n", count
, CPE_HISTORY_LENGTH
);
547 if (count
>= CPE_HISTORY_LENGTH
) {
549 cpe_poll_enabled
= 1;
550 spin_unlock(&cpe_history_lock
);
551 disable_irq_nosync(local_vector_to_irq(IA64_CPE_VECTOR
));
554 * Corrected errors will still be corrected, but
555 * make sure there's a log somewhere that indicates
556 * something is generating more than we can handle.
558 printk(KERN_WARNING
"WARNING: Switching to polling CPE handler; error records may be lost\n");
560 mod_timer(&cpe_poll_timer
, jiffies
+ MIN_CPE_POLL_INTERVAL
);
562 /* lock already released, get out now */
565 cpe_history
[index
++] = now
;
566 if (index
== CPE_HISTORY_LENGTH
)
570 spin_unlock(&cpe_history_lock
);
572 /* Get the CPE error record and log it */
573 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CPE
);
578 #endif /* CONFIG_ACPI */
582 * ia64_mca_register_cpev
584 * Register the corrected platform error vector with SAL.
587 * cpev Corrected Platform Error Vector number
593 ia64_mca_register_cpev (int cpev
)
595 /* Register the CPE interrupt vector with SAL */
596 struct ia64_sal_retval isrv
;
598 isrv
= ia64_sal_mc_set_params(SAL_MC_PARAM_CPE_INT
, SAL_MC_PARAM_MECHANISM_INT
, cpev
, 0, 0);
600 printk(KERN_ERR
"Failed to register Corrected Platform "
601 "Error interrupt vector with SAL (status %ld)\n", isrv
.status
);
605 IA64_MCA_DEBUG("%s: corrected platform error "
606 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
607 "vector %#x registered\n", __FUNCTION__
, cpev
);
609 "vector %#x registered\n", __func__
, cpev
);
610 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
612 #endif /* CONFIG_ACPI */
615 * ia64_mca_cmc_vector_setup
617 * Setup the corrected machine check vector register in the processor.
618 * (The interrupt is masked on boot. ia64_mca_late_init unmask this.)
619 * This function is invoked on a per-processor basis.
628 ia64_mca_cmc_vector_setup (void)
632 cmcv
.cmcv_regval
= 0;
633 cmcv
.cmcv_mask
= 1; /* Mask/disable interrupt at first */
634 cmcv
.cmcv_vector
= IA64_CMC_VECTOR
;
635 ia64_setreg(_IA64_REG_CR_CMCV
, cmcv
.cmcv_regval
);
637 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
638 IA64_MCA_DEBUG("%s: CPU %d corrected "
639 "machine check vector %#x registered.\n",
640 __FUNCTION__
, smp_processor_id(), IA64_CMC_VECTOR
);
642 IA64_MCA_DEBUG("%s: CPU %d corrected machine check vector %#x registered.\n",
643 __func__
, smp_processor_id(), IA64_CMC_VECTOR
);
644 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
646 IA64_MCA_DEBUG("%s: CPU %d CMCV = %#016lx\n",
647 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
648 __FUNCTION__
, smp_processor_id(), ia64_getreg(_IA64_REG_CR_CMCV
));
650 __func__
, smp_processor_id(), ia64_getreg(_IA64_REG_CR_CMCV
));
651 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
655 * ia64_mca_cmc_vector_disable
657 * Mask the corrected machine check vector register in the processor.
658 * This function is invoked on a per-processor basis.
667 ia64_mca_cmc_vector_disable (void *dummy
)
671 cmcv
.cmcv_regval
= ia64_getreg(_IA64_REG_CR_CMCV
);
673 cmcv
.cmcv_mask
= 1; /* Mask/disable interrupt */
674 ia64_setreg(_IA64_REG_CR_CMCV
, cmcv
.cmcv_regval
);
676 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
677 IA64_MCA_DEBUG("%s: CPU %d corrected "
678 "machine check vector %#x disabled.\n",
679 __FUNCTION__
, smp_processor_id(), cmcv
.cmcv_vector
);
681 IA64_MCA_DEBUG("%s: CPU %d corrected machine check vector %#x disabled.\n",
682 __func__
, smp_processor_id(), cmcv
.cmcv_vector
);
683 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
687 * ia64_mca_cmc_vector_enable
689 * Unmask the corrected machine check vector register in the processor.
690 * This function is invoked on a per-processor basis.
699 ia64_mca_cmc_vector_enable (void *dummy
)
703 cmcv
.cmcv_regval
= ia64_getreg(_IA64_REG_CR_CMCV
);
705 cmcv
.cmcv_mask
= 0; /* Unmask/enable interrupt */
706 ia64_setreg(_IA64_REG_CR_CMCV
, cmcv
.cmcv_regval
);
708 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
709 IA64_MCA_DEBUG("%s: CPU %d corrected "
710 "machine check vector %#x enabled.\n",
711 __FUNCTION__
, smp_processor_id(), cmcv
.cmcv_vector
);
713 IA64_MCA_DEBUG("%s: CPU %d corrected machine check vector %#x enabled.\n",
714 __func__
, smp_processor_id(), cmcv
.cmcv_vector
);
715 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
719 * ia64_mca_cmc_vector_disable_keventd
721 * Called via keventd (smp_call_function() is not safe in interrupt context) to
722 * disable the cmc interrupt vector.
725 ia64_mca_cmc_vector_disable_keventd(struct work_struct
*unused
)
727 on_each_cpu(ia64_mca_cmc_vector_disable
, NULL
, 1, 0);
731 * ia64_mca_cmc_vector_enable_keventd
733 * Called via keventd (smp_call_function() is not safe in interrupt context) to
734 * enable the cmc interrupt vector.
737 ia64_mca_cmc_vector_enable_keventd(struct work_struct
*unused
)
739 on_each_cpu(ia64_mca_cmc_vector_enable
, NULL
, 1, 0);
745 * Send an inter-cpu interrupt to wake-up a particular cpu.
751 ia64_mca_wakeup(int cpu
)
753 platform_send_ipi(cpu
, IA64_MCA_WAKEUP_VECTOR
, IA64_IPI_DM_INT
, 0);
757 * ia64_mca_wakeup_all
759 * Wakeup all the slave cpus which have rendez'ed previously.
765 ia64_mca_wakeup_all(void)
769 /* Clear the Rendez checkin flag for all cpus */
770 for_each_online_cpu(cpu
) {
771 if (ia64_mc_info
.imi_rendez_checkin
[cpu
] == IA64_MCA_RENDEZ_CHECKIN_DONE
)
772 ia64_mca_wakeup(cpu
);
778 * ia64_mca_rendez_interrupt_handler
780 * This is handler used to put slave processors into spinloop
781 * while the monarch processor does the mca handling and later
782 * wake each slave up once the monarch is done. The state
783 * IA64_MCA_RENDEZ_CHECKIN_DONE indicates the cpu is rendez'ed
784 * in SAL. The state IA64_MCA_RENDEZ_CHECKIN_NOTDONE indicates
785 * the cpu has come out of OS rendezvous.
791 ia64_mca_rendez_int_handler(int rendez_irq
, void *arg
)
794 int cpu
= smp_processor_id();
795 struct ia64_mca_notify_die nd
=
796 { .sos
= NULL
, .monarch_cpu
= &monarch_cpu
};
798 /* Mask all interrupts */
799 local_irq_save(flags
);
800 if (notify_die(DIE_MCA_RENDZVOUS_ENTER
, "MCA", get_irq_regs(),
801 (long)&nd
, 0, 0) == NOTIFY_STOP
)
802 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
803 ia64_mca_spin(__FUNCTION__
);
805 ia64_mca_spin(__func__
);
806 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
808 ia64_mc_info
.imi_rendez_checkin
[cpu
] = IA64_MCA_RENDEZ_CHECKIN_DONE
;
809 /* Register with the SAL monarch that the slave has
812 ia64_sal_mc_rendez();
814 if (notify_die(DIE_MCA_RENDZVOUS_PROCESS
, "MCA", get_irq_regs(),
815 (long)&nd
, 0, 0) == NOTIFY_STOP
)
816 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
817 ia64_mca_spin(__FUNCTION__
);
819 ia64_mca_spin(__func__
);
820 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
822 /* Wait for the monarch cpu to exit. */
823 while (monarch_cpu
!= -1)
824 cpu_relax(); /* spin until monarch leaves */
826 if (notify_die(DIE_MCA_RENDZVOUS_LEAVE
, "MCA", get_irq_regs(),
827 (long)&nd
, 0, 0) == NOTIFY_STOP
)
828 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
829 ia64_mca_spin(__FUNCTION__
);
831 ia64_mca_spin(__func__
);
832 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
834 ia64_mc_info
.imi_rendez_checkin
[cpu
] = IA64_MCA_RENDEZ_CHECKIN_NOTDONE
;
835 /* Enable all interrupts */
836 local_irq_restore(flags
);
841 * ia64_mca_wakeup_int_handler
843 * The interrupt handler for processing the inter-cpu interrupt to the
844 * slave cpu which was spinning in the rendez loop.
845 * Since this spinning is done by turning off the interrupts and
846 * polling on the wakeup-interrupt bit in the IRR, there is
847 * nothing useful to be done in the handler.
849 * Inputs : wakeup_irq (Wakeup-interrupt bit)
850 * arg (Interrupt handler specific argument)
855 ia64_mca_wakeup_int_handler(int wakeup_irq
, void *arg
)
860 /* Function pointer for extra MCA recovery */
861 int (*ia64_mca_ucmc_extension
)
862 (void*,struct ia64_sal_os_state
*)
866 ia64_reg_MCA_extension(int (*fn
)(void *, struct ia64_sal_os_state
*))
868 if (ia64_mca_ucmc_extension
)
871 ia64_mca_ucmc_extension
= fn
;
876 ia64_unreg_MCA_extension(void)
878 if (ia64_mca_ucmc_extension
)
879 ia64_mca_ucmc_extension
= NULL
;
882 EXPORT_SYMBOL(ia64_reg_MCA_extension
);
883 EXPORT_SYMBOL(ia64_unreg_MCA_extension
);
887 copy_reg(const u64
*fr
, u64 fnat
, u64
*tr
, u64
*tnat
)
889 u64 fslot
, tslot
, nat
;
891 fslot
= ((unsigned long)fr
>> 3) & 63;
892 tslot
= ((unsigned long)tr
>> 3) & 63;
893 *tnat
&= ~(1UL << tslot
);
894 nat
= (fnat
>> fslot
) & 1;
895 *tnat
|= (nat
<< tslot
);
898 /* Change the comm field on the MCA/INT task to include the pid that
899 * was interrupted, it makes for easier debugging. If that pid was 0
900 * (swapper or nested MCA/INIT) then use the start of the previous comm
901 * field suffixed with its cpu.
905 ia64_mca_modify_comm(const struct task_struct
*previous_current
)
907 char *p
, comm
[sizeof(current
->comm
)];
908 if (previous_current
->pid
)
909 snprintf(comm
, sizeof(comm
), "%s %d",
910 current
->comm
, previous_current
->pid
);
913 if ((p
= strchr(previous_current
->comm
, ' ')))
914 l
= p
- previous_current
->comm
;
916 l
= strlen(previous_current
->comm
);
917 snprintf(comm
, sizeof(comm
), "%s %*s %d",
918 current
->comm
, l
, previous_current
->comm
,
919 task_thread_info(previous_current
)->cpu
);
921 memcpy(current
->comm
, comm
, sizeof(current
->comm
));
924 /* On entry to this routine, we are running on the per cpu stack, see
925 * mca_asm.h. The original stack has not been touched by this event. Some of
926 * the original stack's registers will be in the RBS on this stack. This stack
927 * also contains a partial pt_regs and switch_stack, the rest of the data is in
930 * The first thing to do is modify the original stack to look like a blocked
931 * task so we can run backtrace on the original task. Also mark the per cpu
932 * stack as current to ensure that we use the correct task state, it also means
933 * that we can do backtrace on the MCA/INIT handler code itself.
936 static struct task_struct
*
937 ia64_mca_modify_original_stack(struct pt_regs
*regs
,
938 const struct switch_stack
*sw
,
939 struct ia64_sal_os_state
*sos
,
944 extern char ia64_leave_kernel
[]; /* Need asm address, not function descriptor */
945 const pal_min_state_area_t
*ms
= sos
->pal_min_state
;
946 struct task_struct
*previous_current
;
947 struct pt_regs
*old_regs
;
948 struct switch_stack
*old_sw
;
949 unsigned size
= sizeof(struct pt_regs
) +
950 sizeof(struct switch_stack
) + 16;
951 u64
*old_bspstore
, *old_bsp
;
952 u64
*new_bspstore
, *new_bsp
;
953 u64 old_unat
, old_rnat
, new_rnat
, nat
;
954 u64 slots
, loadrs
= regs
->loadrs
;
955 u64 r12
= ms
->pmsa_gr
[12-1], r13
= ms
->pmsa_gr
[13-1];
956 u64 ar_bspstore
= regs
->ar_bspstore
;
957 u64 ar_bsp
= regs
->ar_bspstore
+ (loadrs
>> 16);
960 int cpu
= smp_processor_id();
962 previous_current
= curr_task(cpu
);
963 set_curr_task(cpu
, current
);
964 if ((p
= strchr(current
->comm
, ' ')))
967 /* Best effort attempt to cope with MCA/INIT delivered while in
970 regs
->cr_ipsr
= ms
->pmsa_ipsr
;
971 if (ia64_psr(regs
)->dt
== 0) {
983 if (ia64_psr(regs
)->rt
== 0) {
996 /* mca_asm.S ia64_old_stack() cannot assume that the dirty registers
997 * have been copied to the old stack, the old stack may fail the
998 * validation tests below. So ia64_old_stack() must restore the dirty
999 * registers from the new stack. The old and new bspstore probably
1000 * have different alignments, so loadrs calculated on the old bsp
1001 * cannot be used to restore from the new bsp. Calculate a suitable
1002 * loadrs for the new stack and save it in the new pt_regs, where
1003 * ia64_old_stack() can get it.
1005 old_bspstore
= (u64
*)ar_bspstore
;
1006 old_bsp
= (u64
*)ar_bsp
;
1007 slots
= ia64_rse_num_regs(old_bspstore
, old_bsp
);
1008 new_bspstore
= (u64
*)((u64
)current
+ IA64_RBS_OFFSET
);
1009 new_bsp
= ia64_rse_skip_regs(new_bspstore
, slots
);
1010 regs
->loadrs
= (new_bsp
- new_bspstore
) * 8 << 16;
1012 /* Verify the previous stack state before we change it */
1013 if (user_mode(regs
)) {
1014 msg
= "occurred in user space";
1015 /* previous_current is guaranteed to be valid when the task was
1016 * in user space, so ...
1018 ia64_mca_modify_comm(previous_current
);
1022 if (r13
!= sos
->prev_IA64_KR_CURRENT
) {
1023 msg
= "inconsistent previous current and r13";
1027 if (!mca_recover_range(ms
->pmsa_iip
)) {
1028 if ((r12
- r13
) >= KERNEL_STACK_SIZE
) {
1029 msg
= "inconsistent r12 and r13";
1032 if ((ar_bspstore
- r13
) >= KERNEL_STACK_SIZE
) {
1033 msg
= "inconsistent ar.bspstore and r13";
1036 va
.p
= old_bspstore
;
1038 msg
= "old_bspstore is in the wrong region";
1041 if ((ar_bsp
- r13
) >= KERNEL_STACK_SIZE
) {
1042 msg
= "inconsistent ar.bsp and r13";
1045 size
+= (ia64_rse_skip_regs(old_bspstore
, slots
) - old_bspstore
) * 8;
1046 if (ar_bspstore
+ size
> r12
) {
1047 msg
= "no room for blocked state";
1052 ia64_mca_modify_comm(previous_current
);
1054 /* Make the original task look blocked. First stack a struct pt_regs,
1055 * describing the state at the time of interrupt. mca_asm.S built a
1056 * partial pt_regs, copy it and fill in the blanks using minstate.
1058 p
= (char *)r12
- sizeof(*regs
);
1059 old_regs
= (struct pt_regs
*)p
;
1060 memcpy(old_regs
, regs
, sizeof(*regs
));
1061 /* If ipsr.ic then use pmsa_{iip,ipsr,ifs}, else use
1062 * pmsa_{xip,xpsr,xfs}
1064 if (ia64_psr(regs
)->ic
) {
1065 old_regs
->cr_iip
= ms
->pmsa_iip
;
1066 old_regs
->cr_ipsr
= ms
->pmsa_ipsr
;
1067 old_regs
->cr_ifs
= ms
->pmsa_ifs
;
1069 old_regs
->cr_iip
= ms
->pmsa_xip
;
1070 old_regs
->cr_ipsr
= ms
->pmsa_xpsr
;
1071 old_regs
->cr_ifs
= ms
->pmsa_xfs
;
1073 old_regs
->pr
= ms
->pmsa_pr
;
1074 old_regs
->b0
= ms
->pmsa_br0
;
1075 old_regs
->loadrs
= loadrs
;
1076 old_regs
->ar_rsc
= ms
->pmsa_rsc
;
1077 old_unat
= old_regs
->ar_unat
;
1078 copy_reg(&ms
->pmsa_gr
[1-1], ms
->pmsa_nat_bits
, &old_regs
->r1
, &old_unat
);
1079 copy_reg(&ms
->pmsa_gr
[2-1], ms
->pmsa_nat_bits
, &old_regs
->r2
, &old_unat
);
1080 copy_reg(&ms
->pmsa_gr
[3-1], ms
->pmsa_nat_bits
, &old_regs
->r3
, &old_unat
);
1081 copy_reg(&ms
->pmsa_gr
[8-1], ms
->pmsa_nat_bits
, &old_regs
->r8
, &old_unat
);
1082 copy_reg(&ms
->pmsa_gr
[9-1], ms
->pmsa_nat_bits
, &old_regs
->r9
, &old_unat
);
1083 copy_reg(&ms
->pmsa_gr
[10-1], ms
->pmsa_nat_bits
, &old_regs
->r10
, &old_unat
);
1084 copy_reg(&ms
->pmsa_gr
[11-1], ms
->pmsa_nat_bits
, &old_regs
->r11
, &old_unat
);
1085 copy_reg(&ms
->pmsa_gr
[12-1], ms
->pmsa_nat_bits
, &old_regs
->r12
, &old_unat
);
1086 copy_reg(&ms
->pmsa_gr
[13-1], ms
->pmsa_nat_bits
, &old_regs
->r13
, &old_unat
);
1087 copy_reg(&ms
->pmsa_gr
[14-1], ms
->pmsa_nat_bits
, &old_regs
->r14
, &old_unat
);
1088 copy_reg(&ms
->pmsa_gr
[15-1], ms
->pmsa_nat_bits
, &old_regs
->r15
, &old_unat
);
1089 if (ia64_psr(old_regs
)->bn
)
1090 bank
= ms
->pmsa_bank1_gr
;
1092 bank
= ms
->pmsa_bank0_gr
;
1093 copy_reg(&bank
[16-16], ms
->pmsa_nat_bits
, &old_regs
->r16
, &old_unat
);
1094 copy_reg(&bank
[17-16], ms
->pmsa_nat_bits
, &old_regs
->r17
, &old_unat
);
1095 copy_reg(&bank
[18-16], ms
->pmsa_nat_bits
, &old_regs
->r18
, &old_unat
);
1096 copy_reg(&bank
[19-16], ms
->pmsa_nat_bits
, &old_regs
->r19
, &old_unat
);
1097 copy_reg(&bank
[20-16], ms
->pmsa_nat_bits
, &old_regs
->r20
, &old_unat
);
1098 copy_reg(&bank
[21-16], ms
->pmsa_nat_bits
, &old_regs
->r21
, &old_unat
);
1099 copy_reg(&bank
[22-16], ms
->pmsa_nat_bits
, &old_regs
->r22
, &old_unat
);
1100 copy_reg(&bank
[23-16], ms
->pmsa_nat_bits
, &old_regs
->r23
, &old_unat
);
1101 copy_reg(&bank
[24-16], ms
->pmsa_nat_bits
, &old_regs
->r24
, &old_unat
);
1102 copy_reg(&bank
[25-16], ms
->pmsa_nat_bits
, &old_regs
->r25
, &old_unat
);
1103 copy_reg(&bank
[26-16], ms
->pmsa_nat_bits
, &old_regs
->r26
, &old_unat
);
1104 copy_reg(&bank
[27-16], ms
->pmsa_nat_bits
, &old_regs
->r27
, &old_unat
);
1105 copy_reg(&bank
[28-16], ms
->pmsa_nat_bits
, &old_regs
->r28
, &old_unat
);
1106 copy_reg(&bank
[29-16], ms
->pmsa_nat_bits
, &old_regs
->r29
, &old_unat
);
1107 copy_reg(&bank
[30-16], ms
->pmsa_nat_bits
, &old_regs
->r30
, &old_unat
);
1108 copy_reg(&bank
[31-16], ms
->pmsa_nat_bits
, &old_regs
->r31
, &old_unat
);
1110 /* Next stack a struct switch_stack. mca_asm.S built a partial
1111 * switch_stack, copy it and fill in the blanks using pt_regs and
1114 * In the synthesized switch_stack, b0 points to ia64_leave_kernel,
1115 * ar.pfs is set to 0.
1117 * unwind.c::unw_unwind() does special processing for interrupt frames.
1118 * It checks if the PRED_NON_SYSCALL predicate is set, if the predicate
1119 * is clear then unw_unwind() does _not_ adjust bsp over pt_regs. Not
1120 * that this is documented, of course. Set PRED_NON_SYSCALL in the
1121 * switch_stack on the original stack so it will unwind correctly when
1122 * unwind.c reads pt_regs.
1124 * thread.ksp is updated to point to the synthesized switch_stack.
1126 p
-= sizeof(struct switch_stack
);
1127 old_sw
= (struct switch_stack
*)p
;
1128 memcpy(old_sw
, sw
, sizeof(*sw
));
1129 old_sw
->caller_unat
= old_unat
;
1130 old_sw
->ar_fpsr
= old_regs
->ar_fpsr
;
1131 copy_reg(&ms
->pmsa_gr
[4-1], ms
->pmsa_nat_bits
, &old_sw
->r4
, &old_unat
);
1132 copy_reg(&ms
->pmsa_gr
[5-1], ms
->pmsa_nat_bits
, &old_sw
->r5
, &old_unat
);
1133 copy_reg(&ms
->pmsa_gr
[6-1], ms
->pmsa_nat_bits
, &old_sw
->r6
, &old_unat
);
1134 copy_reg(&ms
->pmsa_gr
[7-1], ms
->pmsa_nat_bits
, &old_sw
->r7
, &old_unat
);
1135 old_sw
->b0
= (u64
)ia64_leave_kernel
;
1136 old_sw
->b1
= ms
->pmsa_br1
;
1138 old_sw
->ar_unat
= old_unat
;
1139 old_sw
->pr
= old_regs
->pr
| (1UL << PRED_NON_SYSCALL
);
1140 previous_current
->thread
.ksp
= (u64
)p
- 16;
1142 /* Finally copy the original stack's registers back to its RBS.
1143 * Registers from ar.bspstore through ar.bsp at the time of the event
1144 * are in the current RBS, copy them back to the original stack. The
1145 * copy must be done register by register because the original bspstore
1146 * and the current one have different alignments, so the saved RNAT
1147 * data occurs at different places.
1149 * mca_asm does cover, so the old_bsp already includes all registers at
1150 * the time of MCA/INIT. It also does flushrs, so all registers before
1151 * this function have been written to backing store on the MCA/INIT
1154 new_rnat
= ia64_get_rnat(ia64_rse_rnat_addr(new_bspstore
));
1155 old_rnat
= regs
->ar_rnat
;
1157 if (ia64_rse_is_rnat_slot(new_bspstore
)) {
1158 new_rnat
= ia64_get_rnat(new_bspstore
++);
1160 if (ia64_rse_is_rnat_slot(old_bspstore
)) {
1161 *old_bspstore
++ = old_rnat
;
1164 nat
= (new_rnat
>> ia64_rse_slot_num(new_bspstore
)) & 1UL;
1165 old_rnat
&= ~(1UL << ia64_rse_slot_num(old_bspstore
));
1166 old_rnat
|= (nat
<< ia64_rse_slot_num(old_bspstore
));
1167 *old_bspstore
++ = *new_bspstore
++;
1169 old_sw
->ar_bspstore
= (unsigned long)old_bspstore
;
1170 old_sw
->ar_rnat
= old_rnat
;
1172 sos
->prev_task
= previous_current
;
1173 return previous_current
;
1176 printk(KERN_INFO
"cpu %d, %s %s, original stack not modified\n",
1177 smp_processor_id(), type
, msg
);
1178 return previous_current
;
1181 /* The monarch/slave interaction is based on monarch_cpu and requires that all
1182 * slaves have entered rendezvous before the monarch leaves. If any cpu has
1183 * not entered rendezvous yet then wait a bit. The assumption is that any
1184 * slave that has not rendezvoused after a reasonable time is never going to do
1185 * so. In this context, slave includes cpus that respond to the MCA rendezvous
1186 * interrupt, as well as cpus that receive the INIT slave event.
1190 ia64_wait_for_slaves(int monarch
, const char *type
)
1195 * wait 5 seconds total for slaves (arbitrary)
1197 for (i
= 0; i
< 5000; i
++) {
1199 for_each_online_cpu(c
) {
1202 if (ia64_mc_info
.imi_rendez_checkin
[c
]
1203 == IA64_MCA_RENDEZ_CHECKIN_NOTDONE
) {
1204 udelay(1000); /* short wait */
1214 * Maybe slave(s) dead. Print buffered messages immediately.
1216 ia64_mlogbuf_finish(0);
1217 mprintk(KERN_INFO
"OS %s slave did not rendezvous on cpu", type
);
1218 for_each_online_cpu(c
) {
1221 if (ia64_mc_info
.imi_rendez_checkin
[c
] == IA64_MCA_RENDEZ_CHECKIN_NOTDONE
)
1228 mprintk(KERN_INFO
"All OS %s slaves have reached rendezvous\n", type
);
1235 * This is uncorrectable machine check handler called from OS_MCA
1236 * dispatch code which is in turn called from SAL_CHECK().
1237 * This is the place where the core of OS MCA handling is done.
1238 * Right now the logs are extracted and displayed in a well-defined
1239 * format. This handler code is supposed to be run only on the
1240 * monarch processor. Once the monarch is done with MCA handling
1241 * further MCA logging is enabled by clearing logs.
1242 * Monarch also has the duty of sending wakeup-IPIs to pull the
1243 * slave processors out of rendezvous spinloop.
1245 * If multiple processors call into OS_MCA, the first will become
1246 * the monarch. Subsequent cpus will be recorded in the mca_cpu
1247 * bitmask. After the first monarch has processed its MCA, it
1248 * will wake up the next cpu in the mca_cpu bitmask and then go
1249 * into the rendezvous loop. When all processors have serviced
1250 * their MCA, the last monarch frees up the rest of the processors.
1253 ia64_mca_handler(struct pt_regs
*regs
, struct switch_stack
*sw
,
1254 struct ia64_sal_os_state
*sos
)
1256 int recover
, cpu
= smp_processor_id();
1257 struct task_struct
*previous_current
;
1258 struct ia64_mca_notify_die nd
=
1259 { .sos
= sos
, .monarch_cpu
= &monarch_cpu
};
1260 static atomic_t mca_count
;
1261 static cpumask_t mca_cpu
;
1263 if (atomic_add_return(1, &mca_count
) == 1) {
1267 cpu_set(cpu
, mca_cpu
);
1270 mprintk(KERN_INFO
"Entered OS MCA handler. PSP=%lx cpu=%d "
1271 "monarch=%ld\n", sos
->proc_state_param
, cpu
, sos
->monarch
);
1273 previous_current
= ia64_mca_modify_original_stack(regs
, sw
, sos
, "MCA");
1275 if (notify_die(DIE_MCA_MONARCH_ENTER
, "MCA", regs
, (long)&nd
, 0, 0)
1277 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1278 ia64_mca_spin(__FUNCTION__
);
1280 ia64_mca_spin(__func__
);
1281 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1283 ia64_mc_info
.imi_rendez_checkin
[cpu
] = IA64_MCA_RENDEZ_CHECKIN_CONCURRENT_MCA
;
1285 ia64_wait_for_slaves(cpu
, "MCA");
1287 /* Wakeup all the processors which are spinning in the
1288 * rendezvous loop. They will leave SAL, then spin in the OS
1289 * with interrupts disabled until this monarch cpu leaves the
1290 * MCA handler. That gets control back to the OS so we can
1291 * backtrace the other cpus, backtrace when spinning in SAL
1294 ia64_mca_wakeup_all();
1295 if (notify_die(DIE_MCA_MONARCH_PROCESS
, "MCA", regs
, (long)&nd
, 0, 0)
1297 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1298 ia64_mca_spin(__FUNCTION__
);
1300 ia64_mca_spin(__func__
);
1301 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1303 while (cpu_isset(cpu
, mca_cpu
))
1304 cpu_relax(); /* spin until monarch wakes us */
1307 /* Get the MCA error record and log it */
1308 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_MCA
);
1310 /* MCA error recovery */
1311 recover
= (ia64_mca_ucmc_extension
1312 && ia64_mca_ucmc_extension(
1313 IA64_LOG_CURR_BUFFER(SAL_INFO_TYPE_MCA
),
1317 sal_log_record_header_t
*rh
= IA64_LOG_CURR_BUFFER(SAL_INFO_TYPE_MCA
);
1318 rh
->severity
= sal_log_severity_corrected
;
1319 ia64_sal_clear_state_info(SAL_INFO_TYPE_MCA
);
1320 sos
->os_status
= IA64_MCA_CORRECTED
;
1322 /* Dump buffered message to console */
1323 ia64_mlogbuf_finish(1);
1325 atomic_set(&kdump_in_progress
, 1);
1329 if (notify_die(DIE_MCA_MONARCH_LEAVE
, "MCA", regs
, (long)&nd
, 0, recover
)
1331 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1332 ia64_mca_spin(__FUNCTION__
);
1334 ia64_mca_spin(__func__
);
1335 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1338 if (atomic_dec_return(&mca_count
) > 0) {
1341 /* wake up the next monarch cpu,
1342 * and put this cpu in the rendez loop.
1344 for_each_online_cpu(i
) {
1345 if (cpu_isset(i
, mca_cpu
)) {
1347 cpu_clear(i
, mca_cpu
); /* wake next cpu */
1348 while (monarch_cpu
!= -1)
1349 cpu_relax(); /* spin until last cpu leaves */
1350 set_curr_task(cpu
, previous_current
);
1351 ia64_mc_info
.imi_rendez_checkin
[cpu
]
1352 = IA64_MCA_RENDEZ_CHECKIN_NOTDONE
;
1357 set_curr_task(cpu
, previous_current
);
1358 ia64_mc_info
.imi_rendez_checkin
[cpu
] = IA64_MCA_RENDEZ_CHECKIN_NOTDONE
;
1359 monarch_cpu
= -1; /* This frees the slaves and previous monarchs */
1362 static DECLARE_WORK(cmc_disable_work
, ia64_mca_cmc_vector_disable_keventd
);
1363 static DECLARE_WORK(cmc_enable_work
, ia64_mca_cmc_vector_enable_keventd
);
1366 * ia64_mca_cmc_int_handler
1368 * This is corrected machine check interrupt handler.
1369 * Right now the logs are extracted and displayed in a well-defined
1374 * client data arg ptr
1380 ia64_mca_cmc_int_handler(int cmc_irq
, void *arg
)
1382 static unsigned long cmc_history
[CMC_HISTORY_LENGTH
];
1384 static DEFINE_SPINLOCK(cmc_history_lock
);
1386 IA64_MCA_DEBUG("%s: received interrupt vector = %#x on CPU %d\n",
1387 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1388 __FUNCTION__
, cmc_irq
, smp_processor_id());
1390 __func__
, cmc_irq
, smp_processor_id());
1391 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1393 /* SAL spec states this should run w/ interrupts enabled */
1396 spin_lock(&cmc_history_lock
);
1397 if (!cmc_polling_enabled
) {
1398 int i
, count
= 1; /* we know 1 happened now */
1399 unsigned long now
= jiffies
;
1401 for (i
= 0; i
< CMC_HISTORY_LENGTH
; i
++) {
1402 if (now
- cmc_history
[i
] <= HZ
)
1406 IA64_MCA_DEBUG(KERN_INFO
"CMC threshold %d/%d\n", count
, CMC_HISTORY_LENGTH
);
1407 if (count
>= CMC_HISTORY_LENGTH
) {
1409 cmc_polling_enabled
= 1;
1410 spin_unlock(&cmc_history_lock
);
1411 /* If we're being hit with CMC interrupts, we won't
1412 * ever execute the schedule_work() below. Need to
1413 * disable CMC interrupts on this processor now.
1415 ia64_mca_cmc_vector_disable(NULL
);
1416 schedule_work(&cmc_disable_work
);
1419 * Corrected errors will still be corrected, but
1420 * make sure there's a log somewhere that indicates
1421 * something is generating more than we can handle.
1423 printk(KERN_WARNING
"WARNING: Switching to polling CMC handler; error records may be lost\n");
1425 mod_timer(&cmc_poll_timer
, jiffies
+ CMC_POLL_INTERVAL
);
1427 /* lock already released, get out now */
1430 cmc_history
[index
++] = now
;
1431 if (index
== CMC_HISTORY_LENGTH
)
1435 spin_unlock(&cmc_history_lock
);
1437 /* Get the CMC error record and log it */
1438 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CMC
);
1444 * ia64_mca_cmc_int_caller
1446 * Triggered by sw interrupt from CMC polling routine. Calls
1447 * real interrupt handler and either triggers a sw interrupt
1448 * on the next cpu or does cleanup at the end.
1452 * client data arg ptr
1457 ia64_mca_cmc_int_caller(int cmc_irq
, void *arg
)
1459 static int start_count
= -1;
1462 cpuid
= smp_processor_id();
1464 /* If first cpu, update count */
1465 if (start_count
== -1)
1466 start_count
= IA64_LOG_COUNT(SAL_INFO_TYPE_CMC
);
1468 ia64_mca_cmc_int_handler(cmc_irq
, arg
);
1470 for (++cpuid
; cpuid
< NR_CPUS
&& !cpu_online(cpuid
) ; cpuid
++);
1472 if (cpuid
< NR_CPUS
) {
1473 platform_send_ipi(cpuid
, IA64_CMCP_VECTOR
, IA64_IPI_DM_INT
, 0);
1475 /* If no log record, switch out of polling mode */
1476 if (start_count
== IA64_LOG_COUNT(SAL_INFO_TYPE_CMC
)) {
1478 printk(KERN_WARNING
"Returning to interrupt driven CMC handler\n");
1479 schedule_work(&cmc_enable_work
);
1480 cmc_polling_enabled
= 0;
1484 mod_timer(&cmc_poll_timer
, jiffies
+ CMC_POLL_INTERVAL
);
1496 * Poll for Corrected Machine Checks (CMCs)
1498 * Inputs : dummy(unused)
1503 ia64_mca_cmc_poll (unsigned long dummy
)
1505 /* Trigger a CMC interrupt cascade */
1506 platform_send_ipi(first_cpu(cpu_online_map
), IA64_CMCP_VECTOR
, IA64_IPI_DM_INT
, 0);
1510 * ia64_mca_cpe_int_caller
1512 * Triggered by sw interrupt from CPE polling routine. Calls
1513 * real interrupt handler and either triggers a sw interrupt
1514 * on the next cpu or does cleanup at the end.
1518 * client data arg ptr
1525 ia64_mca_cpe_int_caller(int cpe_irq
, void *arg
)
1527 static int start_count
= -1;
1528 static int poll_time
= MIN_CPE_POLL_INTERVAL
;
1531 cpuid
= smp_processor_id();
1533 /* If first cpu, update count */
1534 if (start_count
== -1)
1535 start_count
= IA64_LOG_COUNT(SAL_INFO_TYPE_CPE
);
1537 ia64_mca_cpe_int_handler(cpe_irq
, arg
);
1539 for (++cpuid
; cpuid
< NR_CPUS
&& !cpu_online(cpuid
) ; cpuid
++);
1541 if (cpuid
< NR_CPUS
) {
1542 platform_send_ipi(cpuid
, IA64_CPEP_VECTOR
, IA64_IPI_DM_INT
, 0);
1545 * If a log was recorded, increase our polling frequency,
1546 * otherwise, backoff or return to interrupt mode.
1548 if (start_count
!= IA64_LOG_COUNT(SAL_INFO_TYPE_CPE
)) {
1549 poll_time
= max(MIN_CPE_POLL_INTERVAL
, poll_time
/ 2);
1550 } else if (cpe_vector
< 0) {
1551 poll_time
= min(MAX_CPE_POLL_INTERVAL
, poll_time
* 2);
1553 poll_time
= MIN_CPE_POLL_INTERVAL
;
1555 printk(KERN_WARNING
"Returning to interrupt driven CPE handler\n");
1556 enable_irq(local_vector_to_irq(IA64_CPE_VECTOR
));
1557 cpe_poll_enabled
= 0;
1560 if (cpe_poll_enabled
)
1561 mod_timer(&cpe_poll_timer
, jiffies
+ poll_time
);
1571 * Poll for Corrected Platform Errors (CPEs), trigger interrupt
1572 * on first cpu, from there it will trickle through all the cpus.
1574 * Inputs : dummy(unused)
1579 ia64_mca_cpe_poll (unsigned long dummy
)
1581 /* Trigger a CPE interrupt cascade */
1582 platform_send_ipi(first_cpu(cpu_online_map
), IA64_CPEP_VECTOR
, IA64_IPI_DM_INT
, 0);
1585 #endif /* CONFIG_ACPI */
1588 default_monarch_init_process(struct notifier_block
*self
, unsigned long val
, void *data
)
1591 struct task_struct
*g
, *t
;
1592 if (val
!= DIE_INIT_MONARCH_PROCESS
)
1595 if (atomic_read(&kdump_in_progress
))
1600 * FIXME: mlogbuf will brim over with INIT stack dumps.
1601 * To enable show_stack from INIT, we use oops_in_progress which should
1602 * be used in real oops. This would cause something wrong after INIT.
1604 BREAK_LOGLEVEL(console_loglevel
);
1605 ia64_mlogbuf_dump_from_init();
1607 printk(KERN_ERR
"Processes interrupted by INIT -");
1608 for_each_online_cpu(c
) {
1609 struct ia64_sal_os_state
*s
;
1610 t
= __va(__per_cpu_mca
[c
] + IA64_MCA_CPU_INIT_STACK_OFFSET
);
1611 s
= (struct ia64_sal_os_state
*)((char *)t
+ MCA_SOS_OFFSET
);
1615 printk(" %d", g
->pid
);
1617 printk(" %d (cpu %d task 0x%p)", g
->pid
, task_cpu(g
), g
);
1621 if (read_trylock(&tasklist_lock
)) {
1622 do_each_thread (g
, t
) {
1623 printk("\nBacktrace of pid %d (%s)\n", t
->pid
, t
->comm
);
1624 show_stack(t
, NULL
);
1625 } while_each_thread (g
, t
);
1626 read_unlock(&tasklist_lock
);
1628 /* FIXME: This will not restore zapped printk locks. */
1629 RESTORE_LOGLEVEL(console_loglevel
);
1634 * C portion of the OS INIT handler
1636 * Called from ia64_os_init_dispatch
1638 * Inputs: pointer to pt_regs where processor info was saved. SAL/OS state for
1639 * this event. This code is used for both monarch and slave INIT events, see
1642 * All INIT events switch to the INIT stack and change the previous process to
1643 * blocked status. If one of the INIT events is the monarch then we are
1644 * probably processing the nmi button/command. Use the monarch cpu to dump all
1645 * the processes. The slave INIT events all spin until the monarch cpu
1646 * returns. We can also get INIT slave events for MCA, in which case the MCA
1647 * process is the monarch.
1651 ia64_init_handler(struct pt_regs
*regs
, struct switch_stack
*sw
,
1652 struct ia64_sal_os_state
*sos
)
1654 static atomic_t slaves
;
1655 static atomic_t monarchs
;
1656 struct task_struct
*previous_current
;
1657 int cpu
= smp_processor_id();
1658 struct ia64_mca_notify_die nd
=
1659 { .sos
= sos
, .monarch_cpu
= &monarch_cpu
};
1661 (void) notify_die(DIE_INIT_ENTER
, "INIT", regs
, (long)&nd
, 0, 0);
1663 mprintk(KERN_INFO
"Entered OS INIT handler. PSP=%lx cpu=%d monarch=%ld\n",
1664 sos
->proc_state_param
, cpu
, sos
->monarch
);
1665 salinfo_log_wakeup(SAL_INFO_TYPE_INIT
, NULL
, 0, 0);
1667 previous_current
= ia64_mca_modify_original_stack(regs
, sw
, sos
, "INIT");
1668 sos
->os_status
= IA64_INIT_RESUME
;
1670 /* FIXME: Workaround for broken proms that drive all INIT events as
1671 * slaves. The last slave that enters is promoted to be a monarch.
1672 * Remove this code in September 2006, that gives platforms a year to
1673 * fix their proms and get their customers updated.
1675 if (!sos
->monarch
&& atomic_add_return(1, &slaves
) == num_online_cpus()) {
1676 mprintk(KERN_WARNING
"%s: Promoting cpu %d to monarch.\n",
1677 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1681 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1682 atomic_dec(&slaves
);
1686 /* FIXME: Workaround for broken proms that drive all INIT events as
1687 * monarchs. Second and subsequent monarchs are demoted to slaves.
1688 * Remove this code in September 2006, that gives platforms a year to
1689 * fix their proms and get their customers updated.
1691 if (sos
->monarch
&& atomic_add_return(1, &monarchs
) > 1) {
1692 mprintk(KERN_WARNING
"%s: Demoting cpu %d to slave.\n",
1693 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1697 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1698 atomic_dec(&monarchs
);
1702 if (!sos
->monarch
) {
1703 ia64_mc_info
.imi_rendez_checkin
[cpu
] = IA64_MCA_RENDEZ_CHECKIN_INIT
;
1704 while (monarch_cpu
== -1)
1705 cpu_relax(); /* spin until monarch enters */
1706 if (notify_die(DIE_INIT_SLAVE_ENTER
, "INIT", regs
, (long)&nd
, 0, 0)
1708 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1709 ia64_mca_spin(__FUNCTION__
);
1711 ia64_mca_spin(__func__
);
1712 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1713 if (notify_die(DIE_INIT_SLAVE_PROCESS
, "INIT", regs
, (long)&nd
, 0, 0)
1715 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1716 ia64_mca_spin(__FUNCTION__
);
1718 ia64_mca_spin(__func__
);
1719 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1720 while (monarch_cpu
!= -1)
1721 cpu_relax(); /* spin until monarch leaves */
1722 if (notify_die(DIE_INIT_SLAVE_LEAVE
, "INIT", regs
, (long)&nd
, 0, 0)
1724 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1725 ia64_mca_spin(__FUNCTION__
);
1727 ia64_mca_spin(__func__
);
1728 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1729 mprintk("Slave on cpu %d returning to normal service.\n", cpu
);
1730 set_curr_task(cpu
, previous_current
);
1731 ia64_mc_info
.imi_rendez_checkin
[cpu
] = IA64_MCA_RENDEZ_CHECKIN_NOTDONE
;
1732 atomic_dec(&slaves
);
1737 if (notify_die(DIE_INIT_MONARCH_ENTER
, "INIT", regs
, (long)&nd
, 0, 0)
1739 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1740 ia64_mca_spin(__FUNCTION__
);
1742 ia64_mca_spin(__func__
);
1743 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1746 * Wait for a bit. On some machines (e.g., HP's zx2000 and zx6000, INIT can be
1747 * generated via the BMC's command-line interface, but since the console is on the
1748 * same serial line, the user will need some time to switch out of the BMC before
1751 mprintk("Delaying for 5 seconds...\n");
1753 ia64_wait_for_slaves(cpu
, "INIT");
1754 /* If nobody intercepts DIE_INIT_MONARCH_PROCESS then we drop through
1755 * to default_monarch_init_process() above and just print all the
1758 if (notify_die(DIE_INIT_MONARCH_PROCESS
, "INIT", regs
, (long)&nd
, 0, 0)
1760 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1761 ia64_mca_spin(__FUNCTION__
);
1763 ia64_mca_spin(__func__
);
1764 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1765 if (notify_die(DIE_INIT_MONARCH_LEAVE
, "INIT", regs
, (long)&nd
, 0, 0)
1767 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1768 ia64_mca_spin(__FUNCTION__
);
1770 ia64_mca_spin(__func__
);
1771 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1772 mprintk("\nINIT dump complete. Monarch on cpu %d returning to normal service.\n", cpu
);
1773 atomic_dec(&monarchs
);
1774 set_curr_task(cpu
, previous_current
);
1780 ia64_mca_disable_cpe_polling(char *str
)
1782 cpe_poll_enabled
= 0;
1786 __setup("disable_cpe_poll", ia64_mca_disable_cpe_polling
);
1788 static struct irqaction cmci_irqaction
= {
1789 .handler
= ia64_mca_cmc_int_handler
,
1790 .flags
= IRQF_DISABLED
,
1794 static struct irqaction cmcp_irqaction
= {
1795 .handler
= ia64_mca_cmc_int_caller
,
1796 .flags
= IRQF_DISABLED
,
1800 static struct irqaction mca_rdzv_irqaction
= {
1801 .handler
= ia64_mca_rendez_int_handler
,
1802 .flags
= IRQF_DISABLED
,
1806 static struct irqaction mca_wkup_irqaction
= {
1807 .handler
= ia64_mca_wakeup_int_handler
,
1808 .flags
= IRQF_DISABLED
,
1813 static struct irqaction mca_cpe_irqaction
= {
1814 .handler
= ia64_mca_cpe_int_handler
,
1815 .flags
= IRQF_DISABLED
,
1819 static struct irqaction mca_cpep_irqaction
= {
1820 .handler
= ia64_mca_cpe_int_caller
,
1821 .flags
= IRQF_DISABLED
,
1824 #endif /* CONFIG_ACPI */
1826 /* Minimal format of the MCA/INIT stacks. The pseudo processes that run on
1827 * these stacks can never sleep, they cannot return from the kernel to user
1828 * space, they do not appear in a normal ps listing. So there is no need to
1829 * format most of the fields.
1832 static void __cpuinit
1833 format_mca_init_stack(void *mca_data
, unsigned long offset
,
1834 const char *type
, int cpu
)
1836 struct task_struct
*p
= (struct task_struct
*)((char *)mca_data
+ offset
);
1837 struct thread_info
*ti
;
1838 memset(p
, 0, KERNEL_STACK_SIZE
);
1839 ti
= task_thread_info(p
);
1840 ti
->flags
= _TIF_MCA_INIT
;
1841 ti
->preempt_count
= 1;
1845 p
->state
= TASK_UNINTERRUPTIBLE
;
1846 cpu_set(cpu
, p
->cpus_allowed
);
1847 INIT_LIST_HEAD(&p
->tasks
);
1848 p
->parent
= p
->real_parent
= p
->group_leader
= p
;
1849 INIT_LIST_HEAD(&p
->children
);
1850 INIT_LIST_HEAD(&p
->sibling
);
1851 strncpy(p
->comm
, type
, sizeof(p
->comm
)-1);
1854 /* Caller prevents this from being called after init */
1855 static void * __init_refok
mca_bootmem(void)
1857 return __alloc_bootmem(sizeof(struct ia64_mca_cpu
),
1858 KERNEL_STACK_SIZE
, 0);
1861 /* Do per-CPU MCA-related initialization. */
1863 ia64_mca_cpu_init(void *cpu_data
)
1867 long sz
= sizeof(struct ia64_mca_cpu
);
1868 int cpu
= smp_processor_id();
1869 static int first_time
= 1;
1872 * Structure will already be allocated if cpu has been online,
1875 if (__per_cpu_mca
[cpu
]) {
1876 data
= __va(__per_cpu_mca
[cpu
]);
1879 data
= mca_bootmem();
1882 data
= page_address(alloc_pages_node(numa_node_id(),
1883 GFP_KERNEL
, get_order(sz
)));
1885 panic("Could not allocate MCA memory for cpu %d\n",
1888 format_mca_init_stack(data
, offsetof(struct ia64_mca_cpu
, mca_stack
),
1890 format_mca_init_stack(data
, offsetof(struct ia64_mca_cpu
, init_stack
),
1892 __get_cpu_var(ia64_mca_data
) = __per_cpu_mca
[cpu
] = __pa(data
);
1895 * Stash away a copy of the PTE needed to map the per-CPU page.
1896 * We may need it during MCA recovery.
1898 __get_cpu_var(ia64_mca_per_cpu_pte
) =
1899 pte_val(mk_pte_phys(__pa(cpu_data
), PAGE_KERNEL
));
1902 * Also, stash away a copy of the PAL address and the PTE
1905 pal_vaddr
= efi_get_pal_addr();
1908 __get_cpu_var(ia64_mca_pal_base
) =
1909 GRANULEROUNDDOWN((unsigned long) pal_vaddr
);
1910 __get_cpu_var(ia64_mca_pal_pte
) = pte_val(mk_pte_phys(__pa(pal_vaddr
),
1914 static void __cpuinit
ia64_mca_cmc_vector_adjust(void *dummy
)
1916 unsigned long flags
;
1918 local_irq_save(flags
);
1919 if (!cmc_polling_enabled
)
1920 ia64_mca_cmc_vector_enable(NULL
);
1921 local_irq_restore(flags
);
1924 static int __cpuinit
mca_cpu_callback(struct notifier_block
*nfb
,
1925 unsigned long action
,
1928 int hotcpu
= (unsigned long) hcpu
;
1932 case CPU_ONLINE_FROZEN
:
1933 smp_call_function_single(hotcpu
, ia64_mca_cmc_vector_adjust
,
1940 static struct notifier_block mca_cpu_notifier __cpuinitdata
= {
1941 .notifier_call
= mca_cpu_callback
1947 * Do all the system level mca specific initialization.
1949 * 1. Register spinloop and wakeup request interrupt vectors
1951 * 2. Register OS_MCA handler entry point
1953 * 3. Register OS_INIT handler entry point
1955 * 4. Initialize MCA/CMC/INIT related log buffers maintained by the OS.
1957 * Note that this initialization is done very early before some kernel
1958 * services are available.
1967 ia64_fptr_t
*init_hldlr_ptr_monarch
= (ia64_fptr_t
*)ia64_os_init_dispatch_monarch
;
1968 ia64_fptr_t
*init_hldlr_ptr_slave
= (ia64_fptr_t
*)ia64_os_init_dispatch_slave
;
1969 ia64_fptr_t
*mca_hldlr_ptr
= (ia64_fptr_t
*)ia64_os_mca_dispatch
;
1972 struct ia64_sal_retval isrv
;
1973 u64 timeout
= IA64_MCA_RENDEZ_TIMEOUT
; /* platform specific */
1974 static struct notifier_block default_init_monarch_nb
= {
1975 .notifier_call
= default_monarch_init_process
,
1976 .priority
= 0/* we need to notified last */
1979 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
1980 IA64_MCA_DEBUG("%s: begin\n", __FUNCTION__
);
1982 IA64_MCA_DEBUG("%s: begin\n", __func__
);
1983 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
1985 /* Clear the Rendez checkin flag for all cpus */
1986 for(i
= 0 ; i
< NR_CPUS
; i
++)
1987 ia64_mc_info
.imi_rendez_checkin
[i
] = IA64_MCA_RENDEZ_CHECKIN_NOTDONE
;
1990 * Register the rendezvous spinloop and wakeup mechanism with SAL
1993 /* Register the rendezvous interrupt vector with SAL */
1995 isrv
= ia64_sal_mc_set_params(SAL_MC_PARAM_RENDEZ_INT
,
1996 SAL_MC_PARAM_MECHANISM_INT
,
1997 IA64_MCA_RENDEZ_VECTOR
,
1999 SAL_MC_PARAM_RZ_ALWAYS
);
2004 printk(KERN_INFO
"Increasing MCA rendezvous timeout from "
2005 "%ld to %ld milliseconds\n", timeout
, isrv
.v0
);
2007 (void) notify_die(DIE_MCA_NEW_TIMEOUT
, "MCA", NULL
, timeout
, 0, 0);
2010 printk(KERN_ERR
"Failed to register rendezvous interrupt "
2011 "with SAL (status %ld)\n", rc
);
2015 /* Register the wakeup interrupt vector with SAL */
2016 isrv
= ia64_sal_mc_set_params(SAL_MC_PARAM_RENDEZ_WAKEUP
,
2017 SAL_MC_PARAM_MECHANISM_INT
,
2018 IA64_MCA_WAKEUP_VECTOR
,
2022 printk(KERN_ERR
"Failed to register wakeup interrupt with SAL "
2023 "(status %ld)\n", rc
);
2027 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2028 IA64_MCA_DEBUG("%s: registered MCA rendezvous spinloop and wakeup mech.\n", __FUNCTION__
);
2030 IA64_MCA_DEBUG("%s: registered MCA rendezvous spinloop and wakeup mech.\n", __func__
);
2031 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2033 ia64_mc_info
.imi_mca_handler
= ia64_tpa(mca_hldlr_ptr
->fp
);
2035 * XXX - disable SAL checksum by setting size to 0; should be
2036 * ia64_tpa(ia64_os_mca_dispatch_end) - ia64_tpa(ia64_os_mca_dispatch);
2038 ia64_mc_info
.imi_mca_handler_size
= 0;
2040 /* Register the os mca handler with SAL */
2041 if ((rc
= ia64_sal_set_vectors(SAL_VECTOR_OS_MCA
,
2042 ia64_mc_info
.imi_mca_handler
,
2043 ia64_tpa(mca_hldlr_ptr
->gp
),
2044 ia64_mc_info
.imi_mca_handler_size
,
2047 printk(KERN_ERR
"Failed to register OS MCA handler with SAL "
2048 "(status %ld)\n", rc
);
2052 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2053 IA64_MCA_DEBUG("%s: registered OS MCA handler with SAL at 0x%lx, gp = 0x%lx\n", __FUNCTION__
,
2055 IA64_MCA_DEBUG("%s: registered OS MCA handler with SAL at 0x%lx, gp = 0x%lx\n", __func__
,
2056 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2057 ia64_mc_info
.imi_mca_handler
, ia64_tpa(mca_hldlr_ptr
->gp
));
2060 * XXX - disable SAL checksum by setting size to 0, should be
2061 * size of the actual init handler in mca_asm.S.
2063 ia64_mc_info
.imi_monarch_init_handler
= ia64_tpa(init_hldlr_ptr_monarch
->fp
);
2064 ia64_mc_info
.imi_monarch_init_handler_size
= 0;
2065 ia64_mc_info
.imi_slave_init_handler
= ia64_tpa(init_hldlr_ptr_slave
->fp
);
2066 ia64_mc_info
.imi_slave_init_handler_size
= 0;
2068 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2069 IA64_MCA_DEBUG("%s: OS INIT handler at %lx\n", __FUNCTION__
,
2071 IA64_MCA_DEBUG("%s: OS INIT handler at %lx\n", __func__
,
2072 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2073 ia64_mc_info
.imi_monarch_init_handler
);
2075 /* Register the os init handler with SAL */
2076 if ((rc
= ia64_sal_set_vectors(SAL_VECTOR_OS_INIT
,
2077 ia64_mc_info
.imi_monarch_init_handler
,
2078 ia64_tpa(ia64_getreg(_IA64_REG_GP
)),
2079 ia64_mc_info
.imi_monarch_init_handler_size
,
2080 ia64_mc_info
.imi_slave_init_handler
,
2081 ia64_tpa(ia64_getreg(_IA64_REG_GP
)),
2082 ia64_mc_info
.imi_slave_init_handler_size
)))
2084 printk(KERN_ERR
"Failed to register m/s INIT handlers with SAL "
2085 "(status %ld)\n", rc
);
2088 if (register_die_notifier(&default_init_monarch_nb
)) {
2089 printk(KERN_ERR
"Failed to register default monarch INIT process\n");
2093 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2094 IA64_MCA_DEBUG("%s: registered OS INIT handler with SAL\n", __FUNCTION__
);
2096 IA64_MCA_DEBUG("%s: registered OS INIT handler with SAL\n", __func__
);
2097 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2100 * Configure the CMCI/P vector and handler. Interrupts for CMC are
2101 * per-processor, so AP CMC interrupts are setup in smp_callin() (smpboot.c).
2103 register_percpu_irq(IA64_CMC_VECTOR
, &cmci_irqaction
);
2104 register_percpu_irq(IA64_CMCP_VECTOR
, &cmcp_irqaction
);
2105 ia64_mca_cmc_vector_setup(); /* Setup vector on BSP */
2107 /* Setup the MCA rendezvous interrupt vector */
2108 register_percpu_irq(IA64_MCA_RENDEZ_VECTOR
, &mca_rdzv_irqaction
);
2110 /* Setup the MCA wakeup interrupt vector */
2111 register_percpu_irq(IA64_MCA_WAKEUP_VECTOR
, &mca_wkup_irqaction
);
2114 /* Setup the CPEI/P handler */
2115 register_percpu_irq(IA64_CPEP_VECTOR
, &mca_cpep_irqaction
);
2118 /* Initialize the areas set aside by the OS to buffer the
2119 * platform/processor error states for MCA/INIT/CMC
2122 ia64_log_init(SAL_INFO_TYPE_MCA
);
2123 ia64_log_init(SAL_INFO_TYPE_INIT
);
2124 ia64_log_init(SAL_INFO_TYPE_CMC
);
2125 ia64_log_init(SAL_INFO_TYPE_CPE
);
2128 printk(KERN_INFO
"MCA related initialization done\n");
2132 * ia64_mca_late_init
2134 * Opportunity to setup things that require initialization later
2135 * than ia64_mca_init. Setup a timer to poll for CPEs if the
2136 * platform doesn't support an interrupt driven mechanism.
2142 ia64_mca_late_init(void)
2147 register_hotcpu_notifier(&mca_cpu_notifier
);
2149 /* Setup the CMCI/P vector and handler */
2150 init_timer(&cmc_poll_timer
);
2151 cmc_poll_timer
.function
= ia64_mca_cmc_poll
;
2153 /* Unmask/enable the vector */
2154 cmc_polling_enabled
= 0;
2155 schedule_work(&cmc_enable_work
);
2157 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2158 IA64_MCA_DEBUG("%s: CMCI/P setup and enabled.\n", __FUNCTION__
);
2160 IA64_MCA_DEBUG("%s: CMCI/P setup and enabled.\n", __func__
);
2161 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2164 /* Setup the CPEI/P vector and handler */
2165 cpe_vector
= acpi_request_vector(ACPI_INTERRUPT_CPEI
);
2166 init_timer(&cpe_poll_timer
);
2167 cpe_poll_timer
.function
= ia64_mca_cpe_poll
;
2173 if (cpe_vector
>= 0) {
2174 /* If platform supports CPEI, enable the irq. */
2175 irq
= local_vector_to_irq(cpe_vector
);
2177 cpe_poll_enabled
= 0;
2178 desc
= irq_desc
+ irq
;
2179 desc
->status
|= IRQ_PER_CPU
;
2180 setup_irq(irq
, &mca_cpe_irqaction
);
2182 ia64_mca_register_cpev(cpe_vector
);
2183 IA64_MCA_DEBUG("%s: CPEI/P setup and enabled.\n",
2184 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2188 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2191 printk(KERN_ERR
"%s: Failed to find irq for CPE "
2192 "interrupt handler, vector %d\n",
2193 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2194 __FUNCTION__
, cpe_vector
);
2196 __func__
, cpe_vector
);
2197 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2199 /* If platform doesn't support CPEI, get the timer going. */
2200 if (cpe_poll_enabled
) {
2201 ia64_mca_cpe_poll(0UL);
2202 <<<<<<< HEAD
:arch
/ia64
/kernel
/mca
.c
2203 IA64_MCA_DEBUG("%s: CPEP setup and enabled.\n", __FUNCTION__
);
2205 IA64_MCA_DEBUG("%s: CPEP setup and enabled.\n", __func__
);
2206 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/mca
.c
2214 device_initcall(ia64_mca_late_init
);