xref: /linux/arch/alpha/kernel/err_ev6.c (revision 1ffb1c0c64b4a2b75eed1f63cc47f2beb711c92f)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *	linux/arch/alpha/kernel/err_ev6.c
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *	Copyright (C) 2000 Jeff Wiedemeier (Compaq Computer Corporation)
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *	Error handling code supporting Alpha systems
71da177e4SLinus Torvalds  */
81da177e4SLinus Torvalds 
91da177e4SLinus Torvalds #include <linux/init.h>
101da177e4SLinus Torvalds #include <linux/sched.h>
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds #include <asm/io.h>
134fa1970aSAl Viro #include <asm/irq_regs.h>
141da177e4SLinus Torvalds #include <asm/hwrpb.h>
151da177e4SLinus Torvalds #include <asm/smp.h>
161da177e4SLinus Torvalds #include <asm/err_common.h>
171da177e4SLinus Torvalds #include <asm/err_ev6.h>
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds #include "err_impl.h"
201da177e4SLinus Torvalds #include "proto.h"
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds static int
231da177e4SLinus Torvalds ev6_parse_ibox(u64 i_stat, int print)
241da177e4SLinus Torvalds {
251da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_REPORT;
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds #define EV6__I_STAT__PAR	(1UL << 29)
281da177e4SLinus Torvalds #define EV6__I_STAT__ERRMASK	(EV6__I_STAT__PAR)
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds 	if (!(i_stat & EV6__I_STAT__ERRMASK))
311da177e4SLinus Torvalds 		return MCHK_DISPOSITION_UNKNOWN_ERROR;
321da177e4SLinus Torvalds 
331da177e4SLinus Torvalds 	if (!print)
341da177e4SLinus Torvalds 		return status;
351da177e4SLinus Torvalds 
361da177e4SLinus Torvalds 	if (i_stat & EV6__I_STAT__PAR)
371da177e4SLinus Torvalds 		printk("%s    Icache parity error\n", err_print_prefix);
381da177e4SLinus Torvalds 
391da177e4SLinus Torvalds 	return status;
401da177e4SLinus Torvalds }
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds static int
431da177e4SLinus Torvalds ev6_parse_mbox(u64 mm_stat, u64 d_stat, u64 c_stat, int print)
441da177e4SLinus Torvalds {
451da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_REPORT;
461da177e4SLinus Torvalds 
471da177e4SLinus Torvalds #define EV6__MM_STAT__DC_TAG_PERR	(1UL << 10)
481da177e4SLinus Torvalds #define EV6__MM_STAT__ERRMASK		(EV6__MM_STAT__DC_TAG_PERR)
491da177e4SLinus Torvalds #define EV6__D_STAT__TPERR_P0		(1UL << 0)
501da177e4SLinus Torvalds #define EV6__D_STAT__TPERR_P1		(1UL << 1)
511da177e4SLinus Torvalds #define EV6__D_STAT__ECC_ERR_ST		(1UL << 2)
521da177e4SLinus Torvalds #define EV6__D_STAT__ECC_ERR_LD		(1UL << 3)
531da177e4SLinus Torvalds #define EV6__D_STAT__SEO		(1UL << 4)
541da177e4SLinus Torvalds #define EV6__D_STAT__ERRMASK		(EV6__D_STAT__TPERR_P0 |	\
551da177e4SLinus Torvalds                                          EV6__D_STAT__TPERR_P1 | 	\
561da177e4SLinus Torvalds                                          EV6__D_STAT__ECC_ERR_ST | 	\
571da177e4SLinus Torvalds                                          EV6__D_STAT__ECC_ERR_LD | 	\
581da177e4SLinus Torvalds                                          EV6__D_STAT__SEO)
591da177e4SLinus Torvalds 
601da177e4SLinus Torvalds 	if (!(d_stat & EV6__D_STAT__ERRMASK) &&
611da177e4SLinus Torvalds 	    !(mm_stat & EV6__MM_STAT__ERRMASK))
621da177e4SLinus Torvalds 		return MCHK_DISPOSITION_UNKNOWN_ERROR;
631da177e4SLinus Torvalds 
641da177e4SLinus Torvalds 	if (!print)
651da177e4SLinus Torvalds 		return status;
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds 	if (mm_stat & EV6__MM_STAT__DC_TAG_PERR)
681da177e4SLinus Torvalds 		printk("%s    Dcache tag parity error on probe\n",
691da177e4SLinus Torvalds 		       err_print_prefix);
701da177e4SLinus Torvalds 	if (d_stat & EV6__D_STAT__TPERR_P0)
711da177e4SLinus Torvalds 		printk("%s    Dcache tag parity error - pipe 0\n",
721da177e4SLinus Torvalds 		       err_print_prefix);
731da177e4SLinus Torvalds 	if (d_stat & EV6__D_STAT__TPERR_P1)
741da177e4SLinus Torvalds 		printk("%s    Dcache tag parity error - pipe 1\n",
751da177e4SLinus Torvalds 		       err_print_prefix);
761da177e4SLinus Torvalds 	if (d_stat & EV6__D_STAT__ECC_ERR_ST)
771da177e4SLinus Torvalds 		printk("%s    ECC error occurred on a store\n",
781da177e4SLinus Torvalds 		       err_print_prefix);
791da177e4SLinus Torvalds 	if (d_stat & EV6__D_STAT__ECC_ERR_LD)
801da177e4SLinus Torvalds 		printk("%s    ECC error occurred on a %s load\n",
811da177e4SLinus Torvalds 		       err_print_prefix,
821da177e4SLinus Torvalds 		       c_stat ? "" : "speculative ");
831da177e4SLinus Torvalds 	if (d_stat & EV6__D_STAT__SEO)
841da177e4SLinus Torvalds 		printk("%s    Dcache second error\n", err_print_prefix);
851da177e4SLinus Torvalds 
861da177e4SLinus Torvalds 	return status;
871da177e4SLinus Torvalds }
881da177e4SLinus Torvalds 
891da177e4SLinus Torvalds static int
901da177e4SLinus Torvalds ev6_parse_cbox(u64 c_addr, u64 c1_syn, u64 c2_syn,
911da177e4SLinus Torvalds 	       u64 c_stat, u64 c_sts, int print)
921da177e4SLinus Torvalds {
931da177e4SLinus Torvalds 	char *sourcename[] = { "UNKNOWN", "UNKNOWN", "UNKNOWN",
941da177e4SLinus Torvalds 			       "MEMORY", "BCACHE", "DCACHE",
951da177e4SLinus Torvalds 			       "BCACHE PROBE", "BCACHE PROBE" };
961da177e4SLinus Torvalds 	char *streamname[] = { "D", "I" };
971da177e4SLinus Torvalds 	char *bitsname[] = { "SINGLE", "DOUBLE" };
981da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_REPORT;
991da177e4SLinus Torvalds 	int source = -1, stream = -1, bits = -1;
1001da177e4SLinus Torvalds 
1011da177e4SLinus Torvalds #define EV6__C_STAT__BC_PERR		(0x01)
1021da177e4SLinus Torvalds #define EV6__C_STAT__DC_PERR		(0x02)
1031da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_MEM_ERR	(0x03)
1041da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_BC_ERR	(0x04)
1051da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_DC_ERR	(0x05)
1061da177e4SLinus Torvalds #define EV6__C_STAT__PROBE_BC_ERR0	(0x06)	/* both 6 and 7 indicate... */
1071da177e4SLinus Torvalds #define EV6__C_STAT__PROBE_BC_ERR1	(0x07)	/* ...probe bc error.       */
1081da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_MEM_ERR	(0x0B)
1091da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_BC_ERR	(0x0C)
1101da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_MEM_DBL	(0x13)
1111da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_BC_DBL	(0x14)
1121da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_MEM_DBL	(0x1B)
1131da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_BC_DBL	(0x1C)
1141da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE_MEMORY	(0x03)
1151da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE_BCACHE	(0x04)
1161da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE__S		(0)
1171da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE__M 		(0x07)
1181da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM__S		(3)
1191da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM__M		(0x01)
1201da177e4SLinus Torvalds #define EV6__C_STAT__DOUBLE__S		(4)
1211da177e4SLinus Torvalds #define EV6__C_STAT__DOUBLE__M		(0x01)
1221da177e4SLinus Torvalds #define EV6__C_STAT__ERRMASK		(0x1F)
1231da177e4SLinus Torvalds #define EV6__C_STS__SHARED		(1 << 0)
1241da177e4SLinus Torvalds #define EV6__C_STS__DIRTY		(1 << 1)
1251da177e4SLinus Torvalds #define EV6__C_STS__VALID		(1 << 2)
1261da177e4SLinus Torvalds #define EV6__C_STS__PARITY		(1 << 3)
1271da177e4SLinus Torvalds 
1281da177e4SLinus Torvalds 	if (!(c_stat & EV6__C_STAT__ERRMASK))
1291da177e4SLinus Torvalds 		return MCHK_DISPOSITION_UNKNOWN_ERROR;
1301da177e4SLinus Torvalds 
1311da177e4SLinus Torvalds 	if (!print)
1321da177e4SLinus Torvalds 		return status;
1331da177e4SLinus Torvalds 
1341da177e4SLinus Torvalds 	source = EXTRACT(c_stat, EV6__C_STAT__SOURCE);
1351da177e4SLinus Torvalds 	stream = EXTRACT(c_stat, EV6__C_STAT__ISTREAM);
1361da177e4SLinus Torvalds 	bits = EXTRACT(c_stat, EV6__C_STAT__DOUBLE);
1371da177e4SLinus Torvalds 
1381da177e4SLinus Torvalds 	if (c_stat & EV6__C_STAT__BC_PERR) {
1391da177e4SLinus Torvalds 		printk("%s    Bcache tag parity error\n", err_print_prefix);
1401da177e4SLinus Torvalds 		source = -1;
1411da177e4SLinus Torvalds 	}
1421da177e4SLinus Torvalds 
1431da177e4SLinus Torvalds 	if (c_stat & EV6__C_STAT__DC_PERR) {
1441da177e4SLinus Torvalds 		printk("%s    Dcache tag parity error\n", err_print_prefix);
1451da177e4SLinus Torvalds 		source = -1;
1461da177e4SLinus Torvalds 	}
1471da177e4SLinus Torvalds 
1481da177e4SLinus Torvalds 	if (c_stat == EV6__C_STAT__PROBE_BC_ERR0 ||
1491da177e4SLinus Torvalds 	    c_stat == EV6__C_STAT__PROBE_BC_ERR1) {
1501da177e4SLinus Torvalds 		printk("%s    Bcache single-bit error on a probe hit\n",
1511da177e4SLinus Torvalds 		       err_print_prefix);
1521da177e4SLinus Torvalds 		source = -1;
1531da177e4SLinus Torvalds 	}
1541da177e4SLinus Torvalds 
1551da177e4SLinus Torvalds 	if (source != -1)
1561da177e4SLinus Torvalds 		printk("%s    %s-STREAM %s-BIT ECC error from %s\n",
1571da177e4SLinus Torvalds 		       err_print_prefix,
1581da177e4SLinus Torvalds 		       streamname[stream], bitsname[bits], sourcename[source]);
1591da177e4SLinus Torvalds 
1605f0e3da6SRandy Dunlap 	printk("%s    Address: 0x%016llx\n"
1615f0e3da6SRandy Dunlap 	         "    Syndrome[upper.lower]: %02llx.%02llx\n",
1621da177e4SLinus Torvalds 	       err_print_prefix,
1631da177e4SLinus Torvalds 	       c_addr,
1641da177e4SLinus Torvalds 	       c2_syn, c1_syn);
1651da177e4SLinus Torvalds 
1661da177e4SLinus Torvalds 	if (source == EV6__C_STAT__SOURCE_MEMORY ||
1671da177e4SLinus Torvalds 	    source == EV6__C_STAT__SOURCE_BCACHE)
1681da177e4SLinus Torvalds 		printk("%s    Block status: %s%s%s%s\n",
1691da177e4SLinus Torvalds 		       err_print_prefix,
1701da177e4SLinus Torvalds 		       (c_sts & EV6__C_STS__SHARED) ? "SHARED " : "",
1711da177e4SLinus Torvalds 		       (c_sts & EV6__C_STS__DIRTY)  ? "DIRTY "  : "",
1721da177e4SLinus Torvalds 		       (c_sts & EV6__C_STS__VALID)  ? "VALID "  : "",
1731da177e4SLinus Torvalds 		       (c_sts & EV6__C_STS__PARITY) ? "PARITY " : "");
1741da177e4SLinus Torvalds 
1751da177e4SLinus Torvalds 	return status;
1761da177e4SLinus Torvalds }
1771da177e4SLinus Torvalds 
1781da177e4SLinus Torvalds void
1791da177e4SLinus Torvalds ev6_register_error_handlers(void)
1801da177e4SLinus Torvalds {
1811da177e4SLinus Torvalds 	/* None right now. */
1821da177e4SLinus Torvalds }
1831da177e4SLinus Torvalds 
1841da177e4SLinus Torvalds int
1851da177e4SLinus Torvalds ev6_process_logout_frame(struct el_common *mchk_header, int print)
1861da177e4SLinus Torvalds {
1871da177e4SLinus Torvalds 	struct el_common_EV6_mcheck *ev6mchk =
1881da177e4SLinus Torvalds 		(struct el_common_EV6_mcheck *)mchk_header;
1891da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_UNKNOWN_ERROR;
1901da177e4SLinus Torvalds 
1911da177e4SLinus Torvalds 	status |= ev6_parse_ibox(ev6mchk->I_STAT, print);
1921da177e4SLinus Torvalds 	status |= ev6_parse_mbox(ev6mchk->MM_STAT, ev6mchk->DC_STAT,
1931da177e4SLinus Torvalds 				 ev6mchk->C_STAT, print);
1941da177e4SLinus Torvalds 	status |= ev6_parse_cbox(ev6mchk->C_ADDR, ev6mchk->DC1_SYNDROME,
1951da177e4SLinus Torvalds 				 ev6mchk->DC0_SYNDROME, ev6mchk->C_STAT,
1961da177e4SLinus Torvalds 				 ev6mchk->C_STS, print);
1971da177e4SLinus Torvalds 
1981da177e4SLinus Torvalds 	if (!print)
1991da177e4SLinus Torvalds 		return status;
2001da177e4SLinus Torvalds 
2011da177e4SLinus Torvalds 	if (status != MCHK_DISPOSITION_DISMISS) {
2021da177e4SLinus Torvalds 		char *saved_err_prefix = err_print_prefix;
2031da177e4SLinus Torvalds 
2041da177e4SLinus Torvalds 		/*
2051da177e4SLinus Torvalds 		 * Dump some additional information from the frame
2061da177e4SLinus Torvalds 		 */
2071da177e4SLinus Torvalds 		printk("%s    EXC_ADDR: 0x%016lx   IER_CM: 0x%016lx"
2081da177e4SLinus Torvalds 		            "   ISUM: 0x%016lx\n"
2091da177e4SLinus Torvalds 		         "    PAL_BASE: 0x%016lx   I_CTL:  0x%016lx"
2101da177e4SLinus Torvalds 		            "   PCTX: 0x%016lx\n",
2111da177e4SLinus Torvalds 		       err_print_prefix,
2121da177e4SLinus Torvalds 		       ev6mchk->EXC_ADDR, ev6mchk->IER_CM, ev6mchk->ISUM,
2131da177e4SLinus Torvalds 		       ev6mchk->PAL_BASE, ev6mchk->I_CTL, ev6mchk->PCTX);
2141da177e4SLinus Torvalds 
2151da177e4SLinus Torvalds 		if (status == MCHK_DISPOSITION_UNKNOWN_ERROR) {
2161da177e4SLinus Torvalds 			printk("%s    UNKNOWN error, frame follows:\n",
2171da177e4SLinus Torvalds 			       err_print_prefix);
2181da177e4SLinus Torvalds 		} else {
2191da177e4SLinus Torvalds 			/* had decode -- downgrade print level for frame */
2201da177e4SLinus Torvalds 			err_print_prefix = KERN_NOTICE;
2211da177e4SLinus Torvalds 		}
2221da177e4SLinus Torvalds 
2231da177e4SLinus Torvalds 		mchk_dump_logout_frame(mchk_header);
2241da177e4SLinus Torvalds 
2251da177e4SLinus Torvalds 		err_print_prefix = saved_err_prefix;
2261da177e4SLinus Torvalds 	}
2271da177e4SLinus Torvalds 
2281da177e4SLinus Torvalds 	return status;
2291da177e4SLinus Torvalds }
2301da177e4SLinus Torvalds 
2311da177e4SLinus Torvalds void
232*1ffb1c0cSIvan Kokshaysky ev6_machine_check(unsigned long vector, unsigned long la_ptr)
2331da177e4SLinus Torvalds {
2341da177e4SLinus Torvalds 	struct el_common *mchk_header = (struct el_common *)la_ptr;
2351da177e4SLinus Torvalds 
2361da177e4SLinus Torvalds 	/*
2371da177e4SLinus Torvalds 	 * Sync the processor
2381da177e4SLinus Torvalds 	 */
2391da177e4SLinus Torvalds 	mb();
2401da177e4SLinus Torvalds 	draina();
2411da177e4SLinus Torvalds 
2421da177e4SLinus Torvalds 	/*
2431da177e4SLinus Torvalds 	 * Parse the logout frame without printing first. If the only error(s)
2441da177e4SLinus Torvalds 	 * found are have a disposition of "dismiss", then just dismiss them
2451da177e4SLinus Torvalds 	 * and don't print any message
2461da177e4SLinus Torvalds 	 */
2471da177e4SLinus Torvalds 	if (ev6_process_logout_frame(mchk_header, 0) !=
2481da177e4SLinus Torvalds 	    MCHK_DISPOSITION_DISMISS) {
2491da177e4SLinus Torvalds 		char *saved_err_prefix = err_print_prefix;
2501da177e4SLinus Torvalds 		err_print_prefix = KERN_CRIT;
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds 		/*
2531da177e4SLinus Torvalds 		 * Either a nondismissable error was detected or no
2541da177e4SLinus Torvalds 		 * recognized error was detected  in the logout frame
2551da177e4SLinus Torvalds 		 * -- report the error in either case
2561da177e4SLinus Torvalds 		 */
2571da177e4SLinus Torvalds 		printk("%s*CPU %s Error (Vector 0x%x) reported on CPU %d:\n",
2581da177e4SLinus Torvalds 		       err_print_prefix,
2591da177e4SLinus Torvalds 		       (vector == SCB_Q_PROCERR)?"Correctable":"Uncorrectable",
2601da177e4SLinus Torvalds 		       (unsigned int)vector, (int)smp_processor_id());
2611da177e4SLinus Torvalds 
2621da177e4SLinus Torvalds 		ev6_process_logout_frame(mchk_header, 1);
2634fa1970aSAl Viro 		dik_show_regs(get_irq_regs(), NULL);
2641da177e4SLinus Torvalds 
2651da177e4SLinus Torvalds 		err_print_prefix = saved_err_prefix;
2661da177e4SLinus Torvalds 	}
2671da177e4SLinus Torvalds 
2681da177e4SLinus Torvalds 	/*
2691da177e4SLinus Torvalds 	 * Release the logout frame
2701da177e4SLinus Torvalds 	 */
2711da177e4SLinus Torvalds 	wrmces(0x7);
2721da177e4SLinus Torvalds 	mb();
2731da177e4SLinus Torvalds }
2741da177e4SLinus Torvalds 
275