[PATCH] alpha pt_regs cleanups: machine_check()
[linux-2.6.git] / arch / alpha / kernel / err_ev6.c
blob69b5f4ea735531903f2af37d747361f00a6356df
1 /*
2 * linux/arch/alpha/kernel/err_ev6.c
4 * Copyright (C) 2000 Jeff Wiedemeier (Compaq Computer Corporation)
6 * Error handling code supporting Alpha systems
7 */
9 #include <linux/init.h>
10 #include <linux/pci.h>
11 #include <linux/sched.h>
13 #include <asm/io.h>
14 #include <asm/irq_regs.h>
15 #include <asm/hwrpb.h>
16 #include <asm/smp.h>
17 #include <asm/err_common.h>
18 #include <asm/err_ev6.h>
20 #include "err_impl.h"
21 #include "proto.h"
23 static int
24 ev6_parse_ibox(u64 i_stat, int print)
26 int status = MCHK_DISPOSITION_REPORT;
28 #define EV6__I_STAT__PAR (1UL << 29)
29 #define EV6__I_STAT__ERRMASK (EV6__I_STAT__PAR)
31 if (!(i_stat & EV6__I_STAT__ERRMASK))
32 return MCHK_DISPOSITION_UNKNOWN_ERROR;
34 if (!print)
35 return status;
37 if (i_stat & EV6__I_STAT__PAR)
38 printk("%s Icache parity error\n", err_print_prefix);
40 return status;
43 static int
44 ev6_parse_mbox(u64 mm_stat, u64 d_stat, u64 c_stat, int print)
46 int status = MCHK_DISPOSITION_REPORT;
48 #define EV6__MM_STAT__DC_TAG_PERR (1UL << 10)
49 #define EV6__MM_STAT__ERRMASK (EV6__MM_STAT__DC_TAG_PERR)
50 #define EV6__D_STAT__TPERR_P0 (1UL << 0)
51 #define EV6__D_STAT__TPERR_P1 (1UL << 1)
52 #define EV6__D_STAT__ECC_ERR_ST (1UL << 2)
53 #define EV6__D_STAT__ECC_ERR_LD (1UL << 3)
54 #define EV6__D_STAT__SEO (1UL << 4)
55 #define EV6__D_STAT__ERRMASK (EV6__D_STAT__TPERR_P0 | \
56 EV6__D_STAT__TPERR_P1 | \
57 EV6__D_STAT__ECC_ERR_ST | \
58 EV6__D_STAT__ECC_ERR_LD | \
59 EV6__D_STAT__SEO)
61 if (!(d_stat & EV6__D_STAT__ERRMASK) &&
62 !(mm_stat & EV6__MM_STAT__ERRMASK))
63 return MCHK_DISPOSITION_UNKNOWN_ERROR;
65 if (!print)
66 return status;
68 if (mm_stat & EV6__MM_STAT__DC_TAG_PERR)
69 printk("%s Dcache tag parity error on probe\n",
70 err_print_prefix);
71 if (d_stat & EV6__D_STAT__TPERR_P0)
72 printk("%s Dcache tag parity error - pipe 0\n",
73 err_print_prefix);
74 if (d_stat & EV6__D_STAT__TPERR_P1)
75 printk("%s Dcache tag parity error - pipe 1\n",
76 err_print_prefix);
77 if (d_stat & EV6__D_STAT__ECC_ERR_ST)
78 printk("%s ECC error occurred on a store\n",
79 err_print_prefix);
80 if (d_stat & EV6__D_STAT__ECC_ERR_LD)
81 printk("%s ECC error occurred on a %s load\n",
82 err_print_prefix,
83 c_stat ? "" : "speculative ");
84 if (d_stat & EV6__D_STAT__SEO)
85 printk("%s Dcache second error\n", err_print_prefix);
87 return status;
90 static int
91 ev6_parse_cbox(u64 c_addr, u64 c1_syn, u64 c2_syn,
92 u64 c_stat, u64 c_sts, int print)
94 char *sourcename[] = { "UNKNOWN", "UNKNOWN", "UNKNOWN",
95 "MEMORY", "BCACHE", "DCACHE",
96 "BCACHE PROBE", "BCACHE PROBE" };
97 char *streamname[] = { "D", "I" };
98 char *bitsname[] = { "SINGLE", "DOUBLE" };
99 int status = MCHK_DISPOSITION_REPORT;
100 int source = -1, stream = -1, bits = -1;
102 #define EV6__C_STAT__BC_PERR (0x01)
103 #define EV6__C_STAT__DC_PERR (0x02)
104 #define EV6__C_STAT__DSTREAM_MEM_ERR (0x03)
105 #define EV6__C_STAT__DSTREAM_BC_ERR (0x04)
106 #define EV6__C_STAT__DSTREAM_DC_ERR (0x05)
107 #define EV6__C_STAT__PROBE_BC_ERR0 (0x06) /* both 6 and 7 indicate... */
108 #define EV6__C_STAT__PROBE_BC_ERR1 (0x07) /* ...probe bc error. */
109 #define EV6__C_STAT__ISTREAM_MEM_ERR (0x0B)
110 #define EV6__C_STAT__ISTREAM_BC_ERR (0x0C)
111 #define EV6__C_STAT__DSTREAM_MEM_DBL (0x13)
112 #define EV6__C_STAT__DSTREAM_BC_DBL (0x14)
113 #define EV6__C_STAT__ISTREAM_MEM_DBL (0x1B)
114 #define EV6__C_STAT__ISTREAM_BC_DBL (0x1C)
115 #define EV6__C_STAT__SOURCE_MEMORY (0x03)
116 #define EV6__C_STAT__SOURCE_BCACHE (0x04)
117 #define EV6__C_STAT__SOURCE__S (0)
118 #define EV6__C_STAT__SOURCE__M (0x07)
119 #define EV6__C_STAT__ISTREAM__S (3)
120 #define EV6__C_STAT__ISTREAM__M (0x01)
121 #define EV6__C_STAT__DOUBLE__S (4)
122 #define EV6__C_STAT__DOUBLE__M (0x01)
123 #define EV6__C_STAT__ERRMASK (0x1F)
124 #define EV6__C_STS__SHARED (1 << 0)
125 #define EV6__C_STS__DIRTY (1 << 1)
126 #define EV6__C_STS__VALID (1 << 2)
127 #define EV6__C_STS__PARITY (1 << 3)
129 if (!(c_stat & EV6__C_STAT__ERRMASK))
130 return MCHK_DISPOSITION_UNKNOWN_ERROR;
132 if (!print)
133 return status;
135 source = EXTRACT(c_stat, EV6__C_STAT__SOURCE);
136 stream = EXTRACT(c_stat, EV6__C_STAT__ISTREAM);
137 bits = EXTRACT(c_stat, EV6__C_STAT__DOUBLE);
139 if (c_stat & EV6__C_STAT__BC_PERR) {
140 printk("%s Bcache tag parity error\n", err_print_prefix);
141 source = -1;
144 if (c_stat & EV6__C_STAT__DC_PERR) {
145 printk("%s Dcache tag parity error\n", err_print_prefix);
146 source = -1;
149 if (c_stat == EV6__C_STAT__PROBE_BC_ERR0 ||
150 c_stat == EV6__C_STAT__PROBE_BC_ERR1) {
151 printk("%s Bcache single-bit error on a probe hit\n",
152 err_print_prefix);
153 source = -1;
156 if (source != -1)
157 printk("%s %s-STREAM %s-BIT ECC error from %s\n",
158 err_print_prefix,
159 streamname[stream], bitsname[bits], sourcename[source]);
161 printk("%s Address: 0x%016lx\n"
162 " Syndrome[upper.lower]: %02lx.%02lx\n",
163 err_print_prefix,
164 c_addr,
165 c2_syn, c1_syn);
167 if (source == EV6__C_STAT__SOURCE_MEMORY ||
168 source == EV6__C_STAT__SOURCE_BCACHE)
169 printk("%s Block status: %s%s%s%s\n",
170 err_print_prefix,
171 (c_sts & EV6__C_STS__SHARED) ? "SHARED " : "",
172 (c_sts & EV6__C_STS__DIRTY) ? "DIRTY " : "",
173 (c_sts & EV6__C_STS__VALID) ? "VALID " : "",
174 (c_sts & EV6__C_STS__PARITY) ? "PARITY " : "");
176 return status;
179 void
180 ev6_register_error_handlers(void)
182 /* None right now. */
186 ev6_process_logout_frame(struct el_common *mchk_header, int print)
188 struct el_common_EV6_mcheck *ev6mchk =
189 (struct el_common_EV6_mcheck *)mchk_header;
190 int status = MCHK_DISPOSITION_UNKNOWN_ERROR;
192 status |= ev6_parse_ibox(ev6mchk->I_STAT, print);
193 status |= ev6_parse_mbox(ev6mchk->MM_STAT, ev6mchk->DC_STAT,
194 ev6mchk->C_STAT, print);
195 status |= ev6_parse_cbox(ev6mchk->C_ADDR, ev6mchk->DC1_SYNDROME,
196 ev6mchk->DC0_SYNDROME, ev6mchk->C_STAT,
197 ev6mchk->C_STS, print);
199 if (!print)
200 return status;
202 if (status != MCHK_DISPOSITION_DISMISS) {
203 char *saved_err_prefix = err_print_prefix;
206 * Dump some additional information from the frame
208 printk("%s EXC_ADDR: 0x%016lx IER_CM: 0x%016lx"
209 " ISUM: 0x%016lx\n"
210 " PAL_BASE: 0x%016lx I_CTL: 0x%016lx"
211 " PCTX: 0x%016lx\n",
212 err_print_prefix,
213 ev6mchk->EXC_ADDR, ev6mchk->IER_CM, ev6mchk->ISUM,
214 ev6mchk->PAL_BASE, ev6mchk->I_CTL, ev6mchk->PCTX);
216 if (status == MCHK_DISPOSITION_UNKNOWN_ERROR) {
217 printk("%s UNKNOWN error, frame follows:\n",
218 err_print_prefix);
219 } else {
220 /* had decode -- downgrade print level for frame */
221 err_print_prefix = KERN_NOTICE;
224 mchk_dump_logout_frame(mchk_header);
226 err_print_prefix = saved_err_prefix;
229 return status;
232 void
233 ev6_machine_check(u64 vector, u64 la_ptr)
235 struct el_common *mchk_header = (struct el_common *)la_ptr;
238 * Sync the processor
240 mb();
241 draina();
244 * Parse the logout frame without printing first. If the only error(s)
245 * found are have a disposition of "dismiss", then just dismiss them
246 * and don't print any message
248 if (ev6_process_logout_frame(mchk_header, 0) !=
249 MCHK_DISPOSITION_DISMISS) {
250 char *saved_err_prefix = err_print_prefix;
251 err_print_prefix = KERN_CRIT;
254 * Either a nondismissable error was detected or no
255 * recognized error was detected in the logout frame
256 * -- report the error in either case
258 printk("%s*CPU %s Error (Vector 0x%x) reported on CPU %d:\n",
259 err_print_prefix,
260 (vector == SCB_Q_PROCERR)?"Correctable":"Uncorrectable",
261 (unsigned int)vector, (int)smp_processor_id());
263 ev6_process_logout_frame(mchk_header, 1);
264 dik_show_regs(get_irq_regs(), NULL);
266 err_print_prefix = saved_err_prefix;
270 * Release the logout frame
272 wrmces(0x7);
273 mb();