Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6] / arch / alpha / kernel / err_ev7.c
1 /*
2  *      linux/arch/alpha/kernel/err_ev7.c
3  *
4  *      Copyright (C) 2000 Jeff Wiedemeier (Compaq Computer Corporation)
5  *
6  *      Error handling code supporting Alpha systems
7  */
8
9 #include <linux/init.h>
10 #include <linux/sched.h>
11
12 #include <asm/io.h>
13 #include <asm/hwrpb.h>
14 #include <asm/smp.h>
15 #include <asm/err_common.h>
16 #include <asm/err_ev7.h>
17
18 #include "err_impl.h"
19 #include "proto.h"
20
21 struct ev7_lf_subpackets *
22 ev7_collect_logout_frame_subpackets(struct el_subpacket *el_ptr,
23                                     struct ev7_lf_subpackets *lf_subpackets)
24 {
25         struct el_subpacket *subpacket;
26         int i;
27
28         /*
29          * A Marvel machine check frame is always packaged in an
30          * el_subpacket of class HEADER, type LOGOUT_FRAME.
31          */
32         if (el_ptr->class != EL_CLASS__HEADER || 
33             el_ptr->type != EL_TYPE__HEADER__LOGOUT_FRAME)
34                 return NULL;
35
36         /*
37          * It is a logout frame header. Look at the one subpacket.
38          */
39         el_ptr = (struct el_subpacket *)
40                 ((unsigned long)el_ptr + el_ptr->length);
41
42         /*
43          * It has to be class PAL, type LOGOUT_FRAME.
44          */
45         if (el_ptr->class != EL_CLASS__PAL ||
46             el_ptr->type != EL_TYPE__PAL__LOGOUT_FRAME)
47                 return NULL;
48
49         lf_subpackets->logout = (struct ev7_pal_logout_subpacket *)
50                 el_ptr->by_type.raw.data_start;
51
52         /*
53          * Process the subpackets.
54          */
55         subpacket = (struct el_subpacket *)
56                 ((unsigned long)el_ptr + el_ptr->length);
57         for (i = 0;
58              subpacket && i < lf_subpackets->logout->subpacket_count;
59              subpacket = (struct el_subpacket *)
60                      ((unsigned long)subpacket + subpacket->length), i++) {
61                 /*
62                  * All subpackets should be class PAL.
63                  */
64                 if (subpacket->class != EL_CLASS__PAL) {
65                         printk("%s**UNEXPECTED SUBPACKET CLASS %d "
66                                "IN LOGOUT FRAME (packet %d\n",
67                                err_print_prefix, subpacket->class, i);
68                         return NULL;
69                 }
70
71                 /*
72                  * Remember the subpacket.
73                  */
74                 switch(subpacket->type) {
75                 case EL_TYPE__PAL__EV7_PROCESSOR:
76                         lf_subpackets->ev7 =
77                                 (struct ev7_pal_processor_subpacket *)
78                                 subpacket->by_type.raw.data_start;
79                         break;
80
81                 case EL_TYPE__PAL__EV7_RBOX:
82                         lf_subpackets->rbox = (struct ev7_pal_rbox_subpacket *)
83                                 subpacket->by_type.raw.data_start;
84                         break;
85
86                 case EL_TYPE__PAL__EV7_ZBOX:
87                         lf_subpackets->zbox = (struct ev7_pal_zbox_subpacket *)
88                                 subpacket->by_type.raw.data_start;
89                         break;
90
91                 case EL_TYPE__PAL__EV7_IO:
92                         lf_subpackets->io = (struct ev7_pal_io_subpacket *)
93                                 subpacket->by_type.raw.data_start;
94                         break;
95
96                 case EL_TYPE__PAL__ENV__AMBIENT_TEMPERATURE:
97                 case EL_TYPE__PAL__ENV__AIRMOVER_FAN:
98                 case EL_TYPE__PAL__ENV__VOLTAGE:
99                 case EL_TYPE__PAL__ENV__INTRUSION:
100                 case EL_TYPE__PAL__ENV__POWER_SUPPLY:
101                 case EL_TYPE__PAL__ENV__LAN:
102                 case EL_TYPE__PAL__ENV__HOT_PLUG:
103                         lf_subpackets->env[ev7_lf_env_index(subpacket->type)] =
104                                 (struct ev7_pal_environmental_subpacket *)
105                                 subpacket->by_type.raw.data_start;
106                         break;
107                                 
108                 default:
109                         /*
110                          * Don't know what kind of frame this is.
111                          */
112                         return NULL;
113                 }
114         }
115
116         return lf_subpackets;
117 }
118
119 void
120 ev7_machine_check(u64 vector, u64 la_ptr)
121 {
122         struct el_subpacket *el_ptr = (struct el_subpacket *)la_ptr;
123         char *saved_err_prefix = err_print_prefix;
124
125         /*
126          * Sync the processor
127          */
128         mb();
129         draina();
130
131         err_print_prefix = KERN_CRIT;
132         printk("%s*CPU %s Error (Vector 0x%x) reported on CPU %d\n",
133                err_print_prefix, 
134                (vector == SCB_Q_PROCERR) ? "Correctable" : "Uncorrectable",
135                (unsigned int)vector, (int)smp_processor_id());
136         el_process_subpacket(el_ptr);
137         err_print_prefix = saved_err_prefix;
138
139         /* 
140          * Release the logout frame 
141          */
142         wrmces(0x7);
143         mb();
144 }
145
146 static char *el_ev7_processor_subpacket_annotation[] = {
147         "Subpacket Header",     "I_STAT",       "DC_STAT",
148         "C_ADDR",               "C_SYNDROME_1", "C_SYNDROME_0",
149         "C_STAT",               "C_STS",        "MM_STAT",
150         "EXC_ADDR",             "IER_CM",       "ISUM",
151         "PAL_BASE",             "I_CTL",        "PROCESS_CONTEXT",
152         "CBOX_CTL",             "CBOX_STP_CTL", "CBOX_ACC_CTL",
153         "CBOX_LCL_SET",         "CBOX_GLB_SET", "BBOX_CTL",
154         "BBOX_ERR_STS",         "BBOX_ERR_IDX", "CBOX_DDP_ERR_STS",
155         "BBOX_DAT_RMP",         NULL
156 };
157
158 static char *el_ev7_zbox_subpacket_annotation[] = {
159         "Subpacket Header",     
160         "ZBOX(0): DRAM_ERR_STATUS_2 / DRAM_ERR_STATUS_1",
161         "ZBOX(0): DRAM_ERROR_CTL    / DRAM_ERR_STATUS_3",
162         "ZBOX(0): DIFT_TIMEOUT      / DRAM_ERR_ADR",
163         "ZBOX(0): FRC_ERR_ADR       / DRAM_MAPPER_CTL",
164         "ZBOX(0): reserved          / DIFT_ERR_STATUS",
165         "ZBOX(1): DRAM_ERR_STATUS_2 / DRAM_ERR_STATUS_1",
166         "ZBOX(1): DRAM_ERROR_CTL    / DRAM_ERR_STATUS_3",
167         "ZBOX(1): DIFT_TIMEOUT      / DRAM_ERR_ADR",
168         "ZBOX(1): FRC_ERR_ADR       / DRAM_MAPPER_CTL",
169         "ZBOX(1): reserved          / DIFT_ERR_STATUS",
170         "CBOX_CTL",             "CBOX_STP_CTL",
171         "ZBOX(0)_ERROR_PA",     "ZBOX(1)_ERROR_PA",
172         "ZBOX(0)_ORED_SYNDROME","ZBOX(1)_ORED_SYNDROME",
173         NULL
174 };
175
176 static char *el_ev7_rbox_subpacket_annotation[] = {
177         "Subpacket Header",     "RBOX_CFG",     "RBOX_N_CFG",
178         "RBOX_S_CFG",           "RBOX_E_CFG",   "RBOX_W_CFG",
179         "RBOX_N_ERR",           "RBOX_S_ERR",   "RBOX_E_ERR",
180         "RBOX_W_ERR",           "RBOX_IO_CFG",  "RBOX_IO_ERR",
181         "RBOX_L_ERR",           "RBOX_WHOAMI",  "RBOX_IMASL",
182         "RBOX_INTQ",            "RBOX_INT",     NULL
183 };
184
185 static char *el_ev7_io_subpacket_annotation[] = {
186         "Subpacket Header",     "IO_ASIC_REV",  "IO_SYS_REV",
187         "IO7_UPH",              "HPI_CTL",      "CRD_CTL",
188         "HEI_CTL",              "PO7_ERROR_SUM","PO7_UNCRR_SYM",
189         "PO7_CRRCT_SYM",        "PO7_UGBGE_SYM","PO7_ERR_PKT0",
190         "PO7_ERR_PKT1",         "reserved",     "reserved",
191         "PO0_ERR_SUM",          "PO0_TLB_ERR",  "PO0_SPL_COMPLT",
192         "PO0_TRANS_SUM",        "PO0_FIRST_ERR","PO0_MULT_ERR",
193         "DM CSR PH",            "DM CSR PH",    "DM CSR PH",
194         "DM CSR PH",            "reserved",
195         "PO1_ERR_SUM",          "PO1_TLB_ERR",  "PO1_SPL_COMPLT",
196         "PO1_TRANS_SUM",        "PO1_FIRST_ERR","PO1_MULT_ERR",
197         "DM CSR PH",            "DM CSR PH",    "DM CSR PH",
198         "DM CSR PH",            "reserved",
199         "PO2_ERR_SUM",          "PO2_TLB_ERR",  "PO2_SPL_COMPLT",
200         "PO2_TRANS_SUM",        "PO2_FIRST_ERR","PO2_MULT_ERR",
201         "DM CSR PH",            "DM CSR PH",    "DM CSR PH",
202         "DM CSR PH",            "reserved",
203         "PO3_ERR_SUM",          "PO3_TLB_ERR",  "PO3_SPL_COMPLT",
204         "PO3_TRANS_SUM",        "PO3_FIRST_ERR","PO3_MULT_ERR",
205         "DM CSR PH",            "DM CSR PH",    "DM CSR PH",
206         "DM CSR PH",            "reserved",     
207         NULL
208 };
209         
210 static struct el_subpacket_annotation el_ev7_pal_annotations[] = {
211         SUBPACKET_ANNOTATION(EL_CLASS__PAL,
212                              EL_TYPE__PAL__EV7_PROCESSOR,
213                              1,
214                              "EV7 Processor Subpacket",
215                              el_ev7_processor_subpacket_annotation),
216         SUBPACKET_ANNOTATION(EL_CLASS__PAL,
217                              EL_TYPE__PAL__EV7_ZBOX,
218                              1,
219                              "EV7 ZBOX Subpacket",
220                              el_ev7_zbox_subpacket_annotation),
221         SUBPACKET_ANNOTATION(EL_CLASS__PAL,
222                              EL_TYPE__PAL__EV7_RBOX,
223                              1,
224                              "EV7 RBOX Subpacket",
225                              el_ev7_rbox_subpacket_annotation),
226         SUBPACKET_ANNOTATION(EL_CLASS__PAL,
227                              EL_TYPE__PAL__EV7_IO,
228                              1,
229                              "EV7 IO Subpacket",
230                              el_ev7_io_subpacket_annotation)
231 };
232
233 static struct el_subpacket *
234 ev7_process_pal_subpacket(struct el_subpacket *header)
235 {
236         struct ev7_pal_subpacket *packet;
237
238         if (header->class != EL_CLASS__PAL) {
239                 printk("%s  ** Unexpected header CLASS %d TYPE %d, aborting\n",
240                        err_print_prefix,
241                        header->class, header->type);
242                 return NULL;
243         }
244
245         packet = (struct ev7_pal_subpacket *)header->by_type.raw.data_start;
246
247         switch(header->type) {
248         case EL_TYPE__PAL__LOGOUT_FRAME:
249                 printk("%s*** MCHK occurred on LPID %ld (RBOX %lx)\n",
250                        err_print_prefix,
251                        packet->by_type.logout.whami, 
252                        packet->by_type.logout.rbox_whami);
253                 el_print_timestamp(&packet->by_type.logout.timestamp);
254                 printk("%s  EXC_ADDR: %016lx\n"
255                          "  HALT_CODE: %lx\n", 
256                        err_print_prefix,
257                        packet->by_type.logout.exc_addr,
258                        packet->by_type.logout.halt_code);
259                 el_process_subpackets(header,
260                                       packet->by_type.logout.subpacket_count);
261                 break;
262         default:
263                 printk("%s  ** PAL TYPE %d SUBPACKET\n", 
264                        err_print_prefix,
265                        header->type);
266                 el_annotate_subpacket(header);
267                 break;
268         }
269         
270         return (struct el_subpacket *)((unsigned long)header + header->length);
271 }
272
273 struct el_subpacket_handler ev7_pal_subpacket_handler =
274         SUBPACKET_HANDLER_INIT(EL_CLASS__PAL, ev7_process_pal_subpacket);
275
276 void __init
277 ev7_register_error_handlers(void)
278 {
279         int i;
280
281         for (i = 0; i < ARRAY_SIZE(el_ev7_pal_annotations); i++)
282                 cdl_register_subpacket_annotation(&el_ev7_pal_annotations[i]);
283
284         cdl_register_subpacket_handler(&ev7_pal_subpacket_handler);
285 }
286