xref: /linux/arch/alpha/kernel/err_titan.c (revision 280da4e4d306667b7faa95152b54f7ca4266ff1e)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *	linux/arch/alpha/kernel/err_titan.c
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *	Copyright (C) 2000 Jeff Wiedemeier (Compaq Computer Corporation)
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *	Error handling code supporting TITAN systems
71da177e4SLinus Torvalds  */
81da177e4SLinus Torvalds 
91da177e4SLinus Torvalds #include <linux/init.h>
101da177e4SLinus Torvalds #include <linux/pci.h>
111da177e4SLinus Torvalds #include <linux/sched.h>
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds #include <asm/io.h>
141da177e4SLinus Torvalds #include <asm/core_titan.h>
151da177e4SLinus Torvalds #include <asm/hwrpb.h>
161da177e4SLinus Torvalds #include <asm/smp.h>
171da177e4SLinus Torvalds #include <asm/err_common.h>
181da177e4SLinus Torvalds #include <asm/err_ev6.h>
191b75b05bSIvan Kokshaysky #include <asm/irq_regs.h>
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include "err_impl.h"
221da177e4SLinus Torvalds #include "proto.h"
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds static int
261da177e4SLinus Torvalds titan_parse_c_misc(u64 c_misc, int print)
271da177e4SLinus Torvalds {
281da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
291da177e4SLinus Torvalds 	char *src;
301da177e4SLinus Torvalds 	int nxs = 0;
311da177e4SLinus Torvalds #endif
321da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_REPORT;
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds #define TITAN__CCHIP_MISC__NXM		(1UL << 28)
351da177e4SLinus Torvalds #define TITAN__CCHIP_MISC__NXS__S	(29)
361da177e4SLinus Torvalds #define TITAN__CCHIP_MISC__NXS__M	(0x7)
371da177e4SLinus Torvalds 
381da177e4SLinus Torvalds 	if (!(c_misc & TITAN__CCHIP_MISC__NXM))
391da177e4SLinus Torvalds 		return MCHK_DISPOSITION_UNKNOWN_ERROR;
401da177e4SLinus Torvalds 
411da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
421da177e4SLinus Torvalds 	if (!print)
431da177e4SLinus Torvalds 		return status;
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds 	nxs = EXTRACT(c_misc, TITAN__CCHIP_MISC__NXS);
461da177e4SLinus Torvalds 	switch(nxs) {
471da177e4SLinus Torvalds 	case 0:	/* CPU 0 */
481da177e4SLinus Torvalds 	case 1:	/* CPU 1 */
491da177e4SLinus Torvalds 	case 2:	/* CPU 2 */
501da177e4SLinus Torvalds 	case 3:	/* CPU 3 */
511da177e4SLinus Torvalds 		src = "CPU";
521da177e4SLinus Torvalds 		/* num is already the CPU number */
531da177e4SLinus Torvalds 		break;
541da177e4SLinus Torvalds 	case 4:	/* Pchip 0 */
551da177e4SLinus Torvalds 	case 5:	/* Pchip 1 */
561da177e4SLinus Torvalds 		src = "Pchip";
571da177e4SLinus Torvalds 		nxs -= 4;
581da177e4SLinus Torvalds 		break;
591da177e4SLinus Torvalds 	default:/* reserved */
601da177e4SLinus Torvalds 		src = "Unknown, NXS =";
611da177e4SLinus Torvalds 		/* leave num untouched */
621da177e4SLinus Torvalds 		break;
631da177e4SLinus Torvalds 	}
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds 	printk("%s    Non-existent memory access from: %s %d\n",
661da177e4SLinus Torvalds 	       err_print_prefix, src, nxs);
671da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
681da177e4SLinus Torvalds 
691da177e4SLinus Torvalds 	return status;
701da177e4SLinus Torvalds }
711da177e4SLinus Torvalds 
721da177e4SLinus Torvalds static int
731da177e4SLinus Torvalds titan_parse_p_serror(int which, u64 serror, int print)
741da177e4SLinus Torvalds {
751da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_REPORT;
761da177e4SLinus Torvalds 
771da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
7831019075SJoe Perches 	static const char * const serror_src[] = {
7931019075SJoe Perches 		"GPCI", "APCI", "AGP HP", "AGP LP"
8031019075SJoe Perches 	};
8131019075SJoe Perches 	static const char * const serror_cmd[] = {
8231019075SJoe Perches 		"DMA Read", "DMA RMW", "SGTE Read", "Reserved"
8331019075SJoe Perches 	};
841da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
851da177e4SLinus Torvalds 
861da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__LOST_UECC	(1UL << 0)
871da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__UECC	(1UL << 1)
881da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__CRE	(1UL << 2)
891da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__NXIO	(1UL << 3)
901da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__LOST_CRE	(1UL << 4)
911da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__ECCMASK	(TITAN__PCHIP_SERROR__UECC |	  \
921da177e4SLinus Torvalds 					 TITAN__PCHIP_SERROR__CRE)
931da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__ERRMASK	(TITAN__PCHIP_SERROR__LOST_UECC | \
941da177e4SLinus Torvalds 					 TITAN__PCHIP_SERROR__UECC |	  \
951da177e4SLinus Torvalds 					 TITAN__PCHIP_SERROR__CRE |	  \
961da177e4SLinus Torvalds 					 TITAN__PCHIP_SERROR__NXIO |	  \
971da177e4SLinus Torvalds 					 TITAN__PCHIP_SERROR__LOST_CRE)
981da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__SRC__S	(52)
991da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__SRC__M	(0x3)
1001da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__CMD__S	(54)
1011da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__CMD__M	(0x3)
1021da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__SYN__S	(56)
1031da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__SYN__M	(0xff)
1041da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__ADDR__S	(15)
1051da177e4SLinus Torvalds #define TITAN__PCHIP_SERROR__ADDR__M	(0xffffffffUL)
1061da177e4SLinus Torvalds 
1071da177e4SLinus Torvalds 	if (!(serror & TITAN__PCHIP_SERROR__ERRMASK))
1081da177e4SLinus Torvalds 		return MCHK_DISPOSITION_UNKNOWN_ERROR;
1091da177e4SLinus Torvalds 
1101da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
1111da177e4SLinus Torvalds 	if (!print)
1121da177e4SLinus Torvalds 		return status;
1131da177e4SLinus Torvalds 
1145f0e3da6SRandy Dunlap 	printk("%s  PChip %d SERROR: %016llx\n",
1151da177e4SLinus Torvalds 	       err_print_prefix, which, serror);
1161da177e4SLinus Torvalds 	if (serror & TITAN__PCHIP_SERROR__ECCMASK) {
1171da177e4SLinus Torvalds 		printk("%s    %sorrectable ECC Error:\n"
1181da177e4SLinus Torvalds 		       "      Source: %-6s  Command: %-8s  Syndrome: 0x%08x\n"
1195f0e3da6SRandy Dunlap 		       "      Address: 0x%llx\n",
1201da177e4SLinus Torvalds 		       err_print_prefix,
1211da177e4SLinus Torvalds 		       (serror & TITAN__PCHIP_SERROR__UECC) ? "Unc" : "C",
1221da177e4SLinus Torvalds 		       serror_src[EXTRACT(serror, TITAN__PCHIP_SERROR__SRC)],
1231da177e4SLinus Torvalds 		       serror_cmd[EXTRACT(serror, TITAN__PCHIP_SERROR__CMD)],
1241da177e4SLinus Torvalds 		       (unsigned)EXTRACT(serror, TITAN__PCHIP_SERROR__SYN),
1251da177e4SLinus Torvalds 		       EXTRACT(serror, TITAN__PCHIP_SERROR__ADDR));
1261da177e4SLinus Torvalds 	}
1271da177e4SLinus Torvalds 	if (serror & TITAN__PCHIP_SERROR__NXIO)
1281da177e4SLinus Torvalds 		printk("%s    Non Existent I/O Error\n", err_print_prefix);
1291da177e4SLinus Torvalds 	if (serror & TITAN__PCHIP_SERROR__LOST_UECC)
1301da177e4SLinus Torvalds 		printk("%s    Lost Uncorrectable ECC Error\n",
1311da177e4SLinus Torvalds 		       err_print_prefix);
1321da177e4SLinus Torvalds 	if (serror & TITAN__PCHIP_SERROR__LOST_CRE)
1331da177e4SLinus Torvalds 		printk("%s    Lost Correctable ECC Error\n", err_print_prefix);
1341da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
1351da177e4SLinus Torvalds 
1361da177e4SLinus Torvalds 	return status;
1371da177e4SLinus Torvalds }
1381da177e4SLinus Torvalds 
1391da177e4SLinus Torvalds static int
1401da177e4SLinus Torvalds titan_parse_p_perror(int which, int port, u64 perror, int print)
1411da177e4SLinus Torvalds {
1421da177e4SLinus Torvalds 	int cmd;
1431da177e4SLinus Torvalds 	unsigned long addr;
1441da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_REPORT;
1451da177e4SLinus Torvalds 
1461da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
14731019075SJoe Perches 	static const char * const perror_cmd[] = {
14831019075SJoe Perches 		"Interrupt Acknowledge", "Special Cycle",
1491da177e4SLinus Torvalds 		"I/O Read",		"I/O Write",
1501da177e4SLinus Torvalds 		"Reserved",		"Reserved",
1511da177e4SLinus Torvalds 		"Memory Read",		"Memory Write",
1521da177e4SLinus Torvalds 		"Reserved",		"Reserved",
1531da177e4SLinus Torvalds 		"Configuration Read",	"Configuration Write",
1541da177e4SLinus Torvalds 		"Memory Read Multiple",	"Dual Address Cycle",
1551da177e4SLinus Torvalds 		"Memory Read Line",	"Memory Write and Invalidate"
1561da177e4SLinus Torvalds 	};
1571da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
1581da177e4SLinus Torvalds 
1591da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__LOST	(1UL << 0)
1601da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__SERR	(1UL << 1)
1611da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__PERR	(1UL << 2)
1621da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__DCRTO	(1UL << 3)
1631da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__SGE	(1UL << 4)
1641da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__APE	(1UL << 5)
1651da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__TA		(1UL << 6)
1661da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__DPE	(1UL << 7)
1671da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__NDS	(1UL << 8)
1681da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__IPTPR	(1UL << 9)
1691da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__IPTPW	(1UL << 10)
1701da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__ERRMASK	(TITAN__PCHIP_PERROR__LOST |	\
1711da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__SERR |	\
1721da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__PERR |	\
1731da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__DCRTO |	\
1741da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__SGE |	\
1751da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__APE |	\
1761da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__TA |	\
1771da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__DPE |	\
1781da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__NDS |	\
1791da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__IPTPR |	\
1801da177e4SLinus Torvalds 					 TITAN__PCHIP_PERROR__IPTPW)
1811da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__DAC	(1UL << 47)
1821da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__MWIN	(1UL << 48)
1831da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__CMD__S	(52)
1841da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__CMD__M	(0x0f)
1851da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__ADDR__S	(14)
1861da177e4SLinus Torvalds #define TITAN__PCHIP_PERROR__ADDR__M	(0x1fffffffful)
1871da177e4SLinus Torvalds 
1881da177e4SLinus Torvalds 	if (!(perror & TITAN__PCHIP_PERROR__ERRMASK))
1891da177e4SLinus Torvalds 		return MCHK_DISPOSITION_UNKNOWN_ERROR;
1901da177e4SLinus Torvalds 
1911da177e4SLinus Torvalds 	cmd = EXTRACT(perror, TITAN__PCHIP_PERROR__CMD);
1921da177e4SLinus Torvalds 	addr = EXTRACT(perror, TITAN__PCHIP_PERROR__ADDR) << 2;
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds 	/*
1951da177e4SLinus Torvalds 	 * Initializing the BIOS on a video card on a bus without
1961da177e4SLinus Torvalds 	 * a south bridge (subtractive decode agent) can result in
1971da177e4SLinus Torvalds 	 * master aborts as the BIOS probes the capabilities of the
1981da177e4SLinus Torvalds 	 * card. XFree86 does such initialization. If the error
1991da177e4SLinus Torvalds 	 * is a master abort (No DevSel as PCI Master) and the command
2001da177e4SLinus Torvalds 	 * is an I/O read or write below the address where we start
2011da177e4SLinus Torvalds 	 * assigning PCI I/O spaces (SRM uses 0x1000), then mark the
2021da177e4SLinus Torvalds 	 * error as dismissable so starting XFree86 doesn't result
2031da177e4SLinus Torvalds 	 * in a series of uncorrectable errors being reported. Also
2041da177e4SLinus Torvalds 	 * dismiss master aborts to VGA frame buffer space
2051da177e4SLinus Torvalds 	 * (0xA0000 - 0xC0000) and legacy BIOS space (0xC0000 - 0x100000)
2061da177e4SLinus Torvalds 	 * for the same reason.
2071da177e4SLinus Torvalds 	 *
2081da177e4SLinus Torvalds 	 * Also mark the error dismissible if it looks like the right
2091da177e4SLinus Torvalds 	 * error but only the Lost bit is set. Since the BIOS initialization
2101da177e4SLinus Torvalds 	 * can cause multiple master aborts and the error interrupt can
2111da177e4SLinus Torvalds 	 * be handled on a different CPU than the BIOS code is run on,
2121da177e4SLinus Torvalds 	 * it is possible for a second master abort to occur between the
2131da177e4SLinus Torvalds 	 * time the PALcode reads PERROR and the time it writes PERROR
2141da177e4SLinus Torvalds 	 * to acknowledge the error. If this timing happens, a second
2151da177e4SLinus Torvalds 	 * error will be signalled after the first, and if no additional
2161da177e4SLinus Torvalds 	 * errors occur, will look like a Lost error with no additional
2171da177e4SLinus Torvalds 	 * errors on the same transaction as the previous error.
2181da177e4SLinus Torvalds 	 */
2191da177e4SLinus Torvalds 	if (((perror & TITAN__PCHIP_PERROR__NDS) ||
2201da177e4SLinus Torvalds 	     ((perror & TITAN__PCHIP_PERROR__ERRMASK) ==
2211da177e4SLinus Torvalds 	      TITAN__PCHIP_PERROR__LOST)) &&
2221da177e4SLinus Torvalds 	    ((((cmd & 0xE) == 2) && (addr < 0x1000)) ||
2231da177e4SLinus Torvalds 	     (((cmd & 0xE) == 6) && (addr >= 0xA0000) && (addr < 0x100000)))) {
2241da177e4SLinus Torvalds 		status = MCHK_DISPOSITION_DISMISS;
2251da177e4SLinus Torvalds 	}
2261da177e4SLinus Torvalds 
2271da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
2281da177e4SLinus Torvalds 	if (!print)
2291da177e4SLinus Torvalds 		return status;
2301da177e4SLinus Torvalds 
2315f0e3da6SRandy Dunlap 	printk("%s  PChip %d %cPERROR: %016llx\n",
2321da177e4SLinus Torvalds 	       err_print_prefix, which,
2331da177e4SLinus Torvalds 	       port ? 'A' : 'G', perror);
2341da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__IPTPW)
2351da177e4SLinus Torvalds 		printk("%s    Invalid Peer-to-Peer Write\n", err_print_prefix);
2361da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__IPTPR)
2371da177e4SLinus Torvalds 		printk("%s    Invalid Peer-to-Peer Read\n", err_print_prefix);
2381da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__NDS)
2391da177e4SLinus Torvalds 		printk("%s    No DEVSEL as PCI Master [Master Abort]\n",
2401da177e4SLinus Torvalds 		       err_print_prefix);
2411da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__DPE)
2421da177e4SLinus Torvalds 		printk("%s    Data Parity Error\n", err_print_prefix);
2431da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__TA)
2441da177e4SLinus Torvalds 		printk("%s    Target Abort\n", err_print_prefix);
2451da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__APE)
2461da177e4SLinus Torvalds 		printk("%s    Address Parity Error\n", err_print_prefix);
2471da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__SGE)
2481da177e4SLinus Torvalds 		printk("%s    Scatter-Gather Error, Invalid PTE\n",
2491da177e4SLinus Torvalds 		       err_print_prefix);
2501da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__DCRTO)
2511da177e4SLinus Torvalds 		printk("%s    Delayed-Completion Retry Timeout\n",
2521da177e4SLinus Torvalds 		       err_print_prefix);
2531da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__PERR)
2541da177e4SLinus Torvalds 		printk("%s    PERR Asserted\n", err_print_prefix);
2551da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__SERR)
2561da177e4SLinus Torvalds 		printk("%s    SERR Asserted\n", err_print_prefix);
2571da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__LOST)
2581da177e4SLinus Torvalds 		printk("%s    Lost Error\n", err_print_prefix);
2591da177e4SLinus Torvalds 	printk("%s      Command: 0x%x - %s\n"
2601da177e4SLinus Torvalds 		 "      Address: 0x%lx\n",
2611da177e4SLinus Torvalds 	       err_print_prefix,
2621da177e4SLinus Torvalds 	       cmd, perror_cmd[cmd],
2631da177e4SLinus Torvalds 	       addr);
2641da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__DAC)
2651da177e4SLinus Torvalds 		printk("%s      Dual Address Cycle\n", err_print_prefix);
2661da177e4SLinus Torvalds 	if (perror & TITAN__PCHIP_PERROR__MWIN)
2671da177e4SLinus Torvalds 		printk("%s      Hit in Monster Window\n", err_print_prefix);
2681da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
2691da177e4SLinus Torvalds 
2701da177e4SLinus Torvalds 	return status;
2711da177e4SLinus Torvalds }
2721da177e4SLinus Torvalds 
2731da177e4SLinus Torvalds static int
2741da177e4SLinus Torvalds titan_parse_p_agperror(int which, u64 agperror, int print)
2751da177e4SLinus Torvalds {
2761da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_REPORT;
2771da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
2781da177e4SLinus Torvalds 	int cmd, len;
2791da177e4SLinus Torvalds 	unsigned long addr;
2801da177e4SLinus Torvalds 
28131019075SJoe Perches 	static const char * const agperror_cmd[] = {
28231019075SJoe Perches 		"Read (low-priority)",	"Read (high-priority)",
28331019075SJoe Perches 		"Write (low-priority)",	"Write (high-priority)",
2841da177e4SLinus Torvalds 		"Reserved",		"Reserved",
2851da177e4SLinus Torvalds 		"Flush",		"Fence"
2861da177e4SLinus Torvalds 	};
2871da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
2881da177e4SLinus Torvalds 
2891da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__LOST	(1UL << 0)
2901da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__LPQFULL	(1UL << 1)
2911da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__HPQFULL	(1UL << 2)
2921da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__RESCMD	(1UL << 3)
2931da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__IPTE	(1UL << 4)
2941da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__PTP	(1UL << 5)
2951da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__NOWINDOW	(1UL << 6)
2961da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__ERRMASK	(TITAN__PCHIP_AGPERROR__LOST |    \
2971da177e4SLinus Torvalds 					 TITAN__PCHIP_AGPERROR__LPQFULL | \
2981da177e4SLinus Torvalds 					 TITAN__PCHIP_AGPERROR__HPQFULL | \
2991da177e4SLinus Torvalds 					 TITAN__PCHIP_AGPERROR__RESCMD |  \
3001da177e4SLinus Torvalds 					 TITAN__PCHIP_AGPERROR__IPTE |    \
3011da177e4SLinus Torvalds 					 TITAN__PCHIP_AGPERROR__PTP |     \
3021da177e4SLinus Torvalds 					 TITAN__PCHIP_AGPERROR__NOWINDOW)
3031da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__DAC	(1UL << 48)
3041da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__MWIN	(1UL << 49)
3051da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__FENCE	(1UL << 59)
3061da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__CMD__S	(50)
3071da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__CMD__M	(0x07)
3081da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__ADDR__S	(15)
3091da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__ADDR__M  (0xffffffffUL)
3101da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__LEN__S	(53)
3111da177e4SLinus Torvalds #define TITAN__PCHIP_AGPERROR__LEN__M	(0x3f)
3121da177e4SLinus Torvalds 
3131da177e4SLinus Torvalds 	if (!(agperror & TITAN__PCHIP_AGPERROR__ERRMASK))
3141da177e4SLinus Torvalds 		return MCHK_DISPOSITION_UNKNOWN_ERROR;
3151da177e4SLinus Torvalds 
3161da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
3171da177e4SLinus Torvalds 	if (!print)
3181da177e4SLinus Torvalds 		return status;
3191da177e4SLinus Torvalds 
3201da177e4SLinus Torvalds 	cmd = EXTRACT(agperror, TITAN__PCHIP_AGPERROR__CMD);
3211da177e4SLinus Torvalds 	addr = EXTRACT(agperror, TITAN__PCHIP_AGPERROR__ADDR) << 3;
3221da177e4SLinus Torvalds 	len = EXTRACT(agperror, TITAN__PCHIP_AGPERROR__LEN);
3231da177e4SLinus Torvalds 
3245f0e3da6SRandy Dunlap 	printk("%s  PChip %d AGPERROR: %016llx\n", err_print_prefix,
3251da177e4SLinus Torvalds 	       which, agperror);
3261da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__NOWINDOW)
3271da177e4SLinus Torvalds 		printk("%s    No Window\n", err_print_prefix);
3281da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__PTP)
3291da177e4SLinus Torvalds 		printk("%s    Peer-to-Peer set\n", err_print_prefix);
3301da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__IPTE)
3311da177e4SLinus Torvalds 		printk("%s    Invalid PTE\n", err_print_prefix);
3321da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__RESCMD)
3331da177e4SLinus Torvalds 		printk("%s    Reserved Command\n", err_print_prefix);
3341da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__HPQFULL)
3351da177e4SLinus Torvalds 		printk("%s    HP Transaction Received while Queue Full\n",
3361da177e4SLinus Torvalds 		       err_print_prefix);
3371da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__LPQFULL)
3381da177e4SLinus Torvalds 		printk("%s    LP Transaction Received while Queue Full\n",
3391da177e4SLinus Torvalds 		       err_print_prefix);
3401da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__LOST)
3411da177e4SLinus Torvalds 		printk("%s    Lost Error\n", err_print_prefix);
3421da177e4SLinus Torvalds 	printk("%s      Command: 0x%x - %s, %d Quadwords%s\n"
3431da177e4SLinus Torvalds 		 "      Address: 0x%lx\n",
3441da177e4SLinus Torvalds 	       err_print_prefix, cmd, agperror_cmd[cmd], len,
3451da177e4SLinus Torvalds 	       (agperror & TITAN__PCHIP_AGPERROR__FENCE) ? ", FENCE" : "",
3461da177e4SLinus Torvalds 	       addr);
3471da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__DAC)
3481da177e4SLinus Torvalds 		printk("%s      Dual Address Cycle\n", err_print_prefix);
3491da177e4SLinus Torvalds 	if (agperror & TITAN__PCHIP_AGPERROR__MWIN)
3501da177e4SLinus Torvalds 		printk("%s      Hit in Monster Window\n", err_print_prefix);
3511da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
3521da177e4SLinus Torvalds 
3531da177e4SLinus Torvalds 	return status;
3541da177e4SLinus Torvalds }
3551da177e4SLinus Torvalds 
3561da177e4SLinus Torvalds static int
3571da177e4SLinus Torvalds titan_parse_p_chip(int which, u64 serror, u64 gperror,
3581da177e4SLinus Torvalds 		   u64 aperror, u64 agperror, int print)
3591da177e4SLinus Torvalds {
3601da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_UNKNOWN_ERROR;
3611da177e4SLinus Torvalds 	status |= titan_parse_p_serror(which, serror, print);
3621da177e4SLinus Torvalds 	status |= titan_parse_p_perror(which, 0, gperror, print);
3631da177e4SLinus Torvalds 	status |= titan_parse_p_perror(which, 1, aperror, print);
3641da177e4SLinus Torvalds 	status |= titan_parse_p_agperror(which, agperror, print);
3651da177e4SLinus Torvalds 	return status;
3661da177e4SLinus Torvalds }
3671da177e4SLinus Torvalds 
3681da177e4SLinus Torvalds int
3691da177e4SLinus Torvalds titan_process_logout_frame(struct el_common *mchk_header, int print)
3701da177e4SLinus Torvalds {
3711da177e4SLinus Torvalds 	struct el_TITAN_sysdata_mcheck *tmchk =
3721da177e4SLinus Torvalds 		(struct el_TITAN_sysdata_mcheck *)
3731da177e4SLinus Torvalds 		((unsigned long)mchk_header + mchk_header->sys_offset);
3741da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_UNKNOWN_ERROR;
3751da177e4SLinus Torvalds 
3761da177e4SLinus Torvalds 	status |= titan_parse_c_misc(tmchk->c_misc, print);
3771da177e4SLinus Torvalds 	status |= titan_parse_p_chip(0, tmchk->p0_serror, tmchk->p0_gperror,
3781da177e4SLinus Torvalds 				     tmchk->p0_aperror, tmchk->p0_agperror,
3791da177e4SLinus Torvalds 				     print);
3801da177e4SLinus Torvalds 	status |= titan_parse_p_chip(1, tmchk->p1_serror, tmchk->p1_gperror,
3811da177e4SLinus Torvalds 				     tmchk->p1_aperror, tmchk->p1_agperror,
3821da177e4SLinus Torvalds 				     print);
3831da177e4SLinus Torvalds 
3841da177e4SLinus Torvalds 	return status;
3851da177e4SLinus Torvalds }
3861da177e4SLinus Torvalds 
3871da177e4SLinus Torvalds void
3881ffb1c0cSIvan Kokshaysky titan_machine_check(unsigned long vector, unsigned long la_ptr)
3891da177e4SLinus Torvalds {
3901da177e4SLinus Torvalds 	struct el_common *mchk_header = (struct el_common *)la_ptr;
3911da177e4SLinus Torvalds 	struct el_TITAN_sysdata_mcheck *tmchk =
3921da177e4SLinus Torvalds 		(struct el_TITAN_sysdata_mcheck *)
3931da177e4SLinus Torvalds 		((unsigned long)mchk_header + mchk_header->sys_offset);
3941da177e4SLinus Torvalds 	u64 irqmask;
3951da177e4SLinus Torvalds 
3961da177e4SLinus Torvalds 	/*
3971da177e4SLinus Torvalds 	 * Mask of Titan interrupt sources which are reported as machine checks
3981da177e4SLinus Torvalds 	 *
3991da177e4SLinus Torvalds 	 * 63 - CChip Error
4001da177e4SLinus Torvalds 	 * 62 - PChip 0 H_Error
4011da177e4SLinus Torvalds 	 * 61 - PChip 1 H_Error
4021da177e4SLinus Torvalds 	 * 60 - PChip 0 C_Error
4031da177e4SLinus Torvalds 	 * 59 - PChip 1 C_Error
4041da177e4SLinus Torvalds 	 */
4051da177e4SLinus Torvalds #define TITAN_MCHECK_INTERRUPT_MASK	0xF800000000000000UL
4061da177e4SLinus Torvalds 
4071da177e4SLinus Torvalds 	/*
4081da177e4SLinus Torvalds 	 * Sync the processor
4091da177e4SLinus Torvalds 	 */
4101da177e4SLinus Torvalds 	mb();
4111da177e4SLinus Torvalds 	draina();
4121da177e4SLinus Torvalds 
4131da177e4SLinus Torvalds 	/*
4141da177e4SLinus Torvalds 	 * Only handle system errors here
4151da177e4SLinus Torvalds 	 */
4161da177e4SLinus Torvalds 	if ((vector != SCB_Q_SYSMCHK) && (vector != SCB_Q_SYSERR)) {
4174fa1970aSAl Viro 		ev6_machine_check(vector, la_ptr);
4181da177e4SLinus Torvalds 		return;
4191da177e4SLinus Torvalds 	}
4201da177e4SLinus Torvalds 
4211da177e4SLinus Torvalds 	/*
4221da177e4SLinus Torvalds 	 * It's a system error, handle it here
4231da177e4SLinus Torvalds 	 *
4241da177e4SLinus Torvalds 	 * The PALcode has already cleared the error, so just parse it
4251da177e4SLinus Torvalds 	 */
4261da177e4SLinus Torvalds 
4271da177e4SLinus Torvalds 	/*
4281da177e4SLinus Torvalds 	 * Parse the logout frame without printing first. If the only error(s)
4291da177e4SLinus Torvalds 	 * found are classified as "dismissable", then just dismiss them and
4301da177e4SLinus Torvalds 	 * don't print any message
4311da177e4SLinus Torvalds 	 */
4321da177e4SLinus Torvalds 	if (titan_process_logout_frame(mchk_header, 0) !=
4331da177e4SLinus Torvalds 	    MCHK_DISPOSITION_DISMISS) {
4341da177e4SLinus Torvalds 		char *saved_err_prefix = err_print_prefix;
4351da177e4SLinus Torvalds 		err_print_prefix = KERN_CRIT;
4361da177e4SLinus Torvalds 
4371da177e4SLinus Torvalds 		/*
4381da177e4SLinus Torvalds 		 * Either a nondismissable error was detected or no
4391da177e4SLinus Torvalds 		 * recognized error was detected  in the logout frame
4401da177e4SLinus Torvalds 		 * -- report the error in either case
4411da177e4SLinus Torvalds 		 */
4421da177e4SLinus Torvalds 		printk("%s"
4431da177e4SLinus Torvalds 		       "*System %s Error (Vector 0x%x) reported on CPU %d:\n",
4441da177e4SLinus Torvalds 		       err_print_prefix,
4451da177e4SLinus Torvalds 		       (vector == SCB_Q_SYSERR)?"Correctable":"Uncorrectable",
4461da177e4SLinus Torvalds 		       (unsigned int)vector, (int)smp_processor_id());
4471da177e4SLinus Torvalds 
4481da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
4491da177e4SLinus Torvalds 		titan_process_logout_frame(mchk_header, alpha_verbose_mcheck);
4501da177e4SLinus Torvalds 		if (alpha_verbose_mcheck)
4514fa1970aSAl Viro 			dik_show_regs(get_irq_regs(), NULL);
4521da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
4531da177e4SLinus Torvalds 
4541da177e4SLinus Torvalds 		err_print_prefix = saved_err_prefix;
4551da177e4SLinus Torvalds 
4561da177e4SLinus Torvalds 		/*
4571da177e4SLinus Torvalds 		 * Convert any pending interrupts which report as system
4581da177e4SLinus Torvalds 		 * machine checks to interrupts
4591da177e4SLinus Torvalds 		 */
4601da177e4SLinus Torvalds 		irqmask = tmchk->c_dirx & TITAN_MCHECK_INTERRUPT_MASK;
4612f116cbfSAl Viro 		titan_dispatch_irqs(irqmask);
4621da177e4SLinus Torvalds 	}
4631da177e4SLinus Torvalds 
4641da177e4SLinus Torvalds 
4651da177e4SLinus Torvalds 	/*
4661da177e4SLinus Torvalds 	 * Release the logout frame
4671da177e4SLinus Torvalds 	 */
4681da177e4SLinus Torvalds 	wrmces(0x7);
4691da177e4SLinus Torvalds 	mb();
4701da177e4SLinus Torvalds }
4711da177e4SLinus Torvalds 
4721da177e4SLinus Torvalds /*
4731da177e4SLinus Torvalds  * Subpacket Annotations
4741da177e4SLinus Torvalds  */
4751da177e4SLinus Torvalds static char *el_titan_pchip0_extended_annotation[] = {
4761da177e4SLinus Torvalds 	"Subpacket Header", 	"P0_SCTL",	"P0_SERREN",
4771da177e4SLinus Torvalds 	"P0_APCTL",		"P0_APERREN",	"P0_AGPERREN",
4781da177e4SLinus Torvalds 	"P0_ASPRST",		"P0_AWSBA0",	"P0_AWSBA1",
4791da177e4SLinus Torvalds 	"P0_AWSBA2",		"P0_AWSBA3",	"P0_AWSM0",
4801da177e4SLinus Torvalds 	"P0_AWSM1",		"P0_AWSM2",	"P0_AWSM3",
4811da177e4SLinus Torvalds 	"P0_ATBA0",		"P0_ATBA1",	"P0_ATBA2",
4821da177e4SLinus Torvalds 	"P0_ATBA3",		"P0_GPCTL",	"P0_GPERREN",
4831da177e4SLinus Torvalds 	"P0_GSPRST",		"P0_GWSBA0",	"P0_GWSBA1",
4841da177e4SLinus Torvalds 	"P0_GWSBA2",		"P0_GWSBA3",	"P0_GWSM0",
4851da177e4SLinus Torvalds 	"P0_GWSM1",		"P0_GWSM2",	"P0_GWSM3",
4861da177e4SLinus Torvalds 	"P0_GTBA0",		"P0_GTBA1",	"P0_GTBA2",
4871da177e4SLinus Torvalds 	"P0_GTBA3",		NULL
4881da177e4SLinus Torvalds };
4891da177e4SLinus Torvalds static char *el_titan_pchip1_extended_annotation[] = {
4901da177e4SLinus Torvalds 	"Subpacket Header", 	"P1_SCTL",	"P1_SERREN",
4911da177e4SLinus Torvalds 	"P1_APCTL",		"P1_APERREN",	"P1_AGPERREN",
4921da177e4SLinus Torvalds 	"P1_ASPRST",		"P1_AWSBA0",	"P1_AWSBA1",
4931da177e4SLinus Torvalds 	"P1_AWSBA2",		"P1_AWSBA3",	"P1_AWSM0",
4941da177e4SLinus Torvalds 	"P1_AWSM1",		"P1_AWSM2",	"P1_AWSM3",
4951da177e4SLinus Torvalds 	"P1_ATBA0",		"P1_ATBA1",	"P1_ATBA2",
4961da177e4SLinus Torvalds 	"P1_ATBA3",		"P1_GPCTL",	"P1_GPERREN",
4971da177e4SLinus Torvalds 	"P1_GSPRST",		"P1_GWSBA0",	"P1_GWSBA1",
4981da177e4SLinus Torvalds 	"P1_GWSBA2",		"P1_GWSBA3",	"P1_GWSM0",
4991da177e4SLinus Torvalds 	"P1_GWSM1",		"P1_GWSM2",	"P1_GWSM3",
5001da177e4SLinus Torvalds 	"P1_GTBA0",		"P1_GTBA1",	"P1_GTBA2",
5011da177e4SLinus Torvalds 	"P1_GTBA3",		NULL
5021da177e4SLinus Torvalds };
5031da177e4SLinus Torvalds static char *el_titan_memory_extended_annotation[] = {
5041da177e4SLinus Torvalds 	"Subpacket Header", 	"AAR0",		"AAR1",
5051da177e4SLinus Torvalds 	"AAR2",			"AAR3",		"P0_SCTL",
5061da177e4SLinus Torvalds 	"P0_GPCTL",		"P0_APCTL",	"P1_SCTL",
5071da177e4SLinus Torvalds 	"P1_GPCTL",		"P1_SCTL",	NULL
5081da177e4SLinus Torvalds };
5091da177e4SLinus Torvalds 
5101da177e4SLinus Torvalds static struct el_subpacket_annotation el_titan_annotations[] = {
5111da177e4SLinus Torvalds 	SUBPACKET_ANNOTATION(EL_CLASS__REGATTA_FAMILY,
5121da177e4SLinus Torvalds 			     EL_TYPE__REGATTA__TITAN_PCHIP0_EXTENDED,
5131da177e4SLinus Torvalds 			     1,
5141da177e4SLinus Torvalds 			     "Titan PChip 0 Extended Frame",
5151da177e4SLinus Torvalds 			     el_titan_pchip0_extended_annotation),
5161da177e4SLinus Torvalds 	SUBPACKET_ANNOTATION(EL_CLASS__REGATTA_FAMILY,
5171da177e4SLinus Torvalds 			     EL_TYPE__REGATTA__TITAN_PCHIP1_EXTENDED,
5181da177e4SLinus Torvalds 			     1,
5191da177e4SLinus Torvalds 			     "Titan PChip 1 Extended Frame",
5201da177e4SLinus Torvalds 			     el_titan_pchip1_extended_annotation),
5211da177e4SLinus Torvalds 	SUBPACKET_ANNOTATION(EL_CLASS__REGATTA_FAMILY,
5221da177e4SLinus Torvalds 			     EL_TYPE__REGATTA__TITAN_MEMORY_EXTENDED,
5231da177e4SLinus Torvalds 			     1,
5241da177e4SLinus Torvalds 			     "Titan Memory Extended Frame",
5251da177e4SLinus Torvalds 			     el_titan_memory_extended_annotation),
5261da177e4SLinus Torvalds 	SUBPACKET_ANNOTATION(EL_CLASS__REGATTA_FAMILY,
5271da177e4SLinus Torvalds 			     EL_TYPE__TERMINATION__TERMINATION,
5281da177e4SLinus Torvalds 			     1,
5291da177e4SLinus Torvalds 			     "Termination Subpacket",
5301da177e4SLinus Torvalds 			     NULL)
5311da177e4SLinus Torvalds };
5321da177e4SLinus Torvalds 
5331da177e4SLinus Torvalds static struct el_subpacket *
5341da177e4SLinus Torvalds el_process_regatta_subpacket(struct el_subpacket *header)
5351da177e4SLinus Torvalds {
5361da177e4SLinus Torvalds 	if (header->class != EL_CLASS__REGATTA_FAMILY) {
5371da177e4SLinus Torvalds 		printk("%s  ** Unexpected header CLASS %d TYPE %d, aborting\n",
5381da177e4SLinus Torvalds 		       err_print_prefix,
5391da177e4SLinus Torvalds 		       header->class, header->type);
5401da177e4SLinus Torvalds 		return NULL;
5411da177e4SLinus Torvalds 	}
5421da177e4SLinus Torvalds 
5431da177e4SLinus Torvalds 	switch(header->type) {
5441da177e4SLinus Torvalds 	case EL_TYPE__REGATTA__PROCESSOR_ERROR_FRAME:
5451da177e4SLinus Torvalds 	case EL_TYPE__REGATTA__SYSTEM_ERROR_FRAME:
5461da177e4SLinus Torvalds 	case EL_TYPE__REGATTA__ENVIRONMENTAL_FRAME:
5471da177e4SLinus Torvalds 	case EL_TYPE__REGATTA__PROCESSOR_DBL_ERROR_HALT:
5481da177e4SLinus Torvalds 	case EL_TYPE__REGATTA__SYSTEM_DBL_ERROR_HALT:
5491da177e4SLinus Torvalds 		printk("%s  ** Occurred on CPU %d:\n",
5501da177e4SLinus Torvalds 		       err_print_prefix,
5511da177e4SLinus Torvalds 		       (int)header->by_type.regatta_frame.cpuid);
552*280da4e4SRichard Henderson 		privateer_process_logout_frame((struct el_common *)
5531da177e4SLinus Torvalds 			header->by_type.regatta_frame.data_start, 1);
5541da177e4SLinus Torvalds 		break;
5551da177e4SLinus Torvalds 	default:
5561da177e4SLinus Torvalds 		printk("%s  ** REGATTA TYPE %d SUBPACKET\n",
5571da177e4SLinus Torvalds 		       err_print_prefix, header->type);
5581da177e4SLinus Torvalds 		el_annotate_subpacket(header);
5591da177e4SLinus Torvalds 		break;
5601da177e4SLinus Torvalds 	}
5611da177e4SLinus Torvalds 
5621da177e4SLinus Torvalds 
5631da177e4SLinus Torvalds 	return (struct el_subpacket *)((unsigned long)header + header->length);
5641da177e4SLinus Torvalds }
5651da177e4SLinus Torvalds 
5661da177e4SLinus Torvalds static struct el_subpacket_handler titan_subpacket_handler =
5671da177e4SLinus Torvalds 	SUBPACKET_HANDLER_INIT(EL_CLASS__REGATTA_FAMILY,
5681da177e4SLinus Torvalds 			       el_process_regatta_subpacket);
5691da177e4SLinus Torvalds 
5709548b209SIvan Kokshaysky void __init
5711da177e4SLinus Torvalds titan_register_error_handlers(void)
5721da177e4SLinus Torvalds {
5731da177e4SLinus Torvalds 	size_t i;
5741da177e4SLinus Torvalds 
5751da177e4SLinus Torvalds 	for (i = 0; i < ARRAY_SIZE (el_titan_annotations); i++)
5761da177e4SLinus Torvalds 		cdl_register_subpacket_annotation(&el_titan_annotations[i]);
5771da177e4SLinus Torvalds 
5781da177e4SLinus Torvalds 	cdl_register_subpacket_handler(&titan_subpacket_handler);
5791da177e4SLinus Torvalds 
5801da177e4SLinus Torvalds 	ev6_register_error_handlers();
5811da177e4SLinus Torvalds }
5821da177e4SLinus Torvalds 
5831da177e4SLinus Torvalds 
5841da177e4SLinus Torvalds /*
5851da177e4SLinus Torvalds  * Privateer
5861da177e4SLinus Torvalds  */
5871da177e4SLinus Torvalds 
5881da177e4SLinus Torvalds static int
5891da177e4SLinus Torvalds privateer_process_680_frame(struct el_common *mchk_header, int print)
5901da177e4SLinus Torvalds {
5911da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_UNKNOWN_ERROR;
5921da177e4SLinus Torvalds #ifdef CONFIG_VERBOSE_MCHECK
5931da177e4SLinus Torvalds 	struct el_PRIVATEER_envdata_mcheck *emchk =
5941da177e4SLinus Torvalds 		(struct el_PRIVATEER_envdata_mcheck *)
5951da177e4SLinus Torvalds 		((unsigned long)mchk_header + mchk_header->sys_offset);
5961da177e4SLinus Torvalds 
597c3a2ddeeSSimon Arlott 	/* TODO - categorize errors, for now, no error */
5981da177e4SLinus Torvalds 
5991da177e4SLinus Torvalds 	if (!print)
6001da177e4SLinus Torvalds 		return status;
6011da177e4SLinus Torvalds 
6021da177e4SLinus Torvalds 	/* TODO - decode instead of just dumping... */
6035f0e3da6SRandy Dunlap 	printk("%s  Summary Flags:         %016llx\n"
6045f0e3da6SRandy Dunlap  	         "  CChip DIRx:            %016llx\n"
6055f0e3da6SRandy Dunlap 		 "  System Management IR:  %016llx\n"
6065f0e3da6SRandy Dunlap 		 "  CPU IR:                %016llx\n"
6075f0e3da6SRandy Dunlap 		 "  Power Supply IR:       %016llx\n"
6085f0e3da6SRandy Dunlap 		 "  LM78 Fault Status:     %016llx\n"
6095f0e3da6SRandy Dunlap 		 "  System Doors:          %016llx\n"
6105f0e3da6SRandy Dunlap 		 "  Temperature Warning:   %016llx\n"
6115f0e3da6SRandy Dunlap 		 "  Fan Control:           %016llx\n"
6125f0e3da6SRandy Dunlap 		 "  Fatal Power Down Code: %016llx\n",
6131da177e4SLinus Torvalds 	       err_print_prefix,
6141da177e4SLinus Torvalds 	       emchk->summary,
6151da177e4SLinus Torvalds 	       emchk->c_dirx,
6161da177e4SLinus Torvalds 	       emchk->smir,
6171da177e4SLinus Torvalds 	       emchk->cpuir,
6181da177e4SLinus Torvalds 	       emchk->psir,
6191da177e4SLinus Torvalds 	       emchk->fault,
6201da177e4SLinus Torvalds 	       emchk->sys_doors,
6211da177e4SLinus Torvalds 	       emchk->temp_warn,
6221da177e4SLinus Torvalds 	       emchk->fan_ctrl,
6231da177e4SLinus Torvalds 	       emchk->code);
6241da177e4SLinus Torvalds #endif /* CONFIG_VERBOSE_MCHECK */
6251da177e4SLinus Torvalds 
6261da177e4SLinus Torvalds 	return status;
6271da177e4SLinus Torvalds }
6281da177e4SLinus Torvalds 
6291da177e4SLinus Torvalds int
6301da177e4SLinus Torvalds privateer_process_logout_frame(struct el_common *mchk_header, int print)
6311da177e4SLinus Torvalds {
6321da177e4SLinus Torvalds 	struct el_common_EV6_mcheck *ev6mchk =
6331da177e4SLinus Torvalds 		(struct el_common_EV6_mcheck *)mchk_header;
6341da177e4SLinus Torvalds 	int status = MCHK_DISPOSITION_UNKNOWN_ERROR;
6351da177e4SLinus Torvalds 
6361da177e4SLinus Torvalds 	/*
6371da177e4SLinus Torvalds 	 * Machine check codes
6381da177e4SLinus Torvalds 	 */
6391da177e4SLinus Torvalds #define PRIVATEER_MCHK__CORR_ECC		0x86	/* 630 */
6401da177e4SLinus Torvalds #define PRIVATEER_MCHK__DC_TAG_PERR		0x9E	/* 630 */
6411da177e4SLinus Torvalds #define PRIVATEER_MCHK__PAL_BUGCHECK		0x8E	/* 670 */
6421da177e4SLinus Torvalds #define PRIVATEER_MCHK__OS_BUGCHECK		0x90	/* 670 */
6431da177e4SLinus Torvalds #define PRIVATEER_MCHK__PROC_HRD_ERR		0x98	/* 670 */
6441da177e4SLinus Torvalds #define PRIVATEER_MCHK__ISTREAM_CMOV_PRX	0xA0	/* 670 */
6451da177e4SLinus Torvalds #define PRIVATEER_MCHK__ISTREAM_CMOV_FLT	0xA2	/* 670 */
6461da177e4SLinus Torvalds #define PRIVATEER_MCHK__SYS_HRD_ERR		0x202	/* 660 */
6471da177e4SLinus Torvalds #define PRIVATEER_MCHK__SYS_CORR_ERR		0x204	/* 620 */
6481da177e4SLinus Torvalds #define PRIVATEER_MCHK__SYS_ENVIRON		0x206	/* 680 */
6491da177e4SLinus Torvalds 
6501da177e4SLinus Torvalds 	switch(ev6mchk->MCHK_Code) {
6511da177e4SLinus Torvalds 	/*
6521da177e4SLinus Torvalds 	 * Vector 630 - Processor, Correctable
6531da177e4SLinus Torvalds 	 */
6541da177e4SLinus Torvalds 	case PRIVATEER_MCHK__CORR_ECC:
6551da177e4SLinus Torvalds 	case PRIVATEER_MCHK__DC_TAG_PERR:
6561da177e4SLinus Torvalds 		/*
6571da177e4SLinus Torvalds 		 * Fall through to vector 670 for processing...
6581da177e4SLinus Torvalds 		 */
6591da177e4SLinus Torvalds 	/*
6601da177e4SLinus Torvalds 	 * Vector 670 - Processor, Uncorrectable
6611da177e4SLinus Torvalds 	 */
6621da177e4SLinus Torvalds 	case PRIVATEER_MCHK__PAL_BUGCHECK:
6631da177e4SLinus Torvalds 	case PRIVATEER_MCHK__OS_BUGCHECK:
6641da177e4SLinus Torvalds 	case PRIVATEER_MCHK__PROC_HRD_ERR:
6651da177e4SLinus Torvalds 	case PRIVATEER_MCHK__ISTREAM_CMOV_PRX:
6661da177e4SLinus Torvalds 	case PRIVATEER_MCHK__ISTREAM_CMOV_FLT:
6671da177e4SLinus Torvalds 		status |= ev6_process_logout_frame(mchk_header, print);
6681da177e4SLinus Torvalds 		break;
6691da177e4SLinus Torvalds 
6701da177e4SLinus Torvalds 	/*
6711da177e4SLinus Torvalds 	 * Vector 620 - System, Correctable
6721da177e4SLinus Torvalds 	 */
6731da177e4SLinus Torvalds 	case PRIVATEER_MCHK__SYS_CORR_ERR:
6741da177e4SLinus Torvalds 		/*
6751da177e4SLinus Torvalds 		 * Fall through to vector 660 for processing...
6761da177e4SLinus Torvalds 		 */
6771da177e4SLinus Torvalds 	/*
6781da177e4SLinus Torvalds 	 * Vector 660 - System, Uncorrectable
6791da177e4SLinus Torvalds 	 */
6801da177e4SLinus Torvalds 	case PRIVATEER_MCHK__SYS_HRD_ERR:
6811da177e4SLinus Torvalds 		status |= titan_process_logout_frame(mchk_header, print);
6821da177e4SLinus Torvalds 		break;
6831da177e4SLinus Torvalds 
6841da177e4SLinus Torvalds 	/*
6851da177e4SLinus Torvalds 	 * Vector 680 - System, Environmental
6861da177e4SLinus Torvalds 	 */
6871da177e4SLinus Torvalds 	case PRIVATEER_MCHK__SYS_ENVIRON:	/* System, Environmental */
6881da177e4SLinus Torvalds 		status |= privateer_process_680_frame(mchk_header, print);
6891da177e4SLinus Torvalds 		break;
6901da177e4SLinus Torvalds 
6911da177e4SLinus Torvalds 	/*
6921da177e4SLinus Torvalds 	 * Unknown
6931da177e4SLinus Torvalds 	 */
6941da177e4SLinus Torvalds 	default:
6951da177e4SLinus Torvalds 		status |= MCHK_DISPOSITION_REPORT;
6961da177e4SLinus Torvalds 		if (print) {
6971da177e4SLinus Torvalds 			printk("%s** Unknown Error, frame follows\n",
6981da177e4SLinus Torvalds 			       err_print_prefix);
6991da177e4SLinus Torvalds 			mchk_dump_logout_frame(mchk_header);
7001da177e4SLinus Torvalds 		}
7011da177e4SLinus Torvalds 
7021da177e4SLinus Torvalds 	}
7031da177e4SLinus Torvalds 
7041da177e4SLinus Torvalds 	return status;
7051da177e4SLinus Torvalds }
7061da177e4SLinus Torvalds 
7071da177e4SLinus Torvalds void
7081ffb1c0cSIvan Kokshaysky privateer_machine_check(unsigned long vector, unsigned long la_ptr)
7091da177e4SLinus Torvalds {
7101da177e4SLinus Torvalds 	struct el_common *mchk_header = (struct el_common *)la_ptr;
7111da177e4SLinus Torvalds 	struct el_TITAN_sysdata_mcheck *tmchk =
7121da177e4SLinus Torvalds 		(struct el_TITAN_sysdata_mcheck *)
7131da177e4SLinus Torvalds 		(la_ptr + mchk_header->sys_offset);
7141da177e4SLinus Torvalds 	u64 irqmask;
7151da177e4SLinus Torvalds 	char *saved_err_prefix = err_print_prefix;
7161da177e4SLinus Torvalds 
7171da177e4SLinus Torvalds #define PRIVATEER_680_INTERRUPT_MASK		(0xE00UL)
7181da177e4SLinus Torvalds #define PRIVATEER_HOTPLUG_INTERRUPT_MASK	(0xE00UL)
7191da177e4SLinus Torvalds 
7201da177e4SLinus Torvalds 	/*
7211da177e4SLinus Torvalds 	 * Sync the processor.
7221da177e4SLinus Torvalds 	 */
7231da177e4SLinus Torvalds 	mb();
7241da177e4SLinus Torvalds 	draina();
7251da177e4SLinus Torvalds 
7261da177e4SLinus Torvalds 	/*
7271da177e4SLinus Torvalds 	 * Only handle system events here.
7281da177e4SLinus Torvalds 	 */
7291da177e4SLinus Torvalds 	if (vector != SCB_Q_SYSEVENT)
7304fa1970aSAl Viro 		return titan_machine_check(vector, la_ptr);
7311da177e4SLinus Torvalds 
7321da177e4SLinus Torvalds 	/*
7331da177e4SLinus Torvalds 	 * Report the event - System Events should be reported even if no
7341da177e4SLinus Torvalds 	 * error is indicated since the event could indicate the return
7351da177e4SLinus Torvalds 	 * to normal status.
7361da177e4SLinus Torvalds 	 */
7371da177e4SLinus Torvalds 	err_print_prefix = KERN_CRIT;
7381da177e4SLinus Torvalds 	printk("%s*System Event (Vector 0x%x) reported on CPU %d:\n",
7391da177e4SLinus Torvalds 	       err_print_prefix,
7401da177e4SLinus Torvalds 	       (unsigned int)vector, (int)smp_processor_id());
7411da177e4SLinus Torvalds 	privateer_process_680_frame(mchk_header, 1);
7421da177e4SLinus Torvalds 	err_print_prefix = saved_err_prefix;
7431da177e4SLinus Torvalds 
7441da177e4SLinus Torvalds 	/*
7451da177e4SLinus Torvalds 	 * Convert any pending interrupts which report as 680 machine
7461da177e4SLinus Torvalds 	 * checks to interrupts.
7471da177e4SLinus Torvalds 	 */
7481da177e4SLinus Torvalds 	irqmask = tmchk->c_dirx & PRIVATEER_680_INTERRUPT_MASK;
7491da177e4SLinus Torvalds 
7501da177e4SLinus Torvalds 	/*
7511da177e4SLinus Torvalds 	 * Dispatch the interrupt(s).
7521da177e4SLinus Torvalds 	 */
7532f116cbfSAl Viro 	titan_dispatch_irqs(irqmask);
7541da177e4SLinus Torvalds 
7551da177e4SLinus Torvalds 	/*
7561da177e4SLinus Torvalds 	 * Release the logout frame.
7571da177e4SLinus Torvalds 	 */
7581da177e4SLinus Torvalds 	wrmces(0x7);
7591da177e4SLinus Torvalds 	mb();
7601da177e4SLinus Torvalds }
761