1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * linux/arch/alpha/kernel/err_ev6.c
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds * Copyright (C) 2000 Jeff Wiedemeier (Compaq Computer Corporation)
61da177e4SLinus Torvalds *
71da177e4SLinus Torvalds * Error handling code supporting Alpha systems
81da177e4SLinus Torvalds */
91da177e4SLinus Torvalds
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
ev6_parse_ibox(u64 i_stat,int print)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
ev6_parse_mbox(u64 mm_stat,u64 d_stat,u64 c_stat,int print)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
ev6_parse_cbox(u64 c_addr,u64 c1_syn,u64 c2_syn,u64 c_stat,u64 c_sts,int print)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 {
9331019075SJoe Perches static const char * const sourcename[] = {
9431019075SJoe Perches "UNKNOWN", "UNKNOWN", "UNKNOWN",
951da177e4SLinus Torvalds "MEMORY", "BCACHE", "DCACHE",
9631019075SJoe Perches "BCACHE PROBE", "BCACHE PROBE"
9731019075SJoe Perches };
9831019075SJoe Perches static const char * const streamname[] = { "D", "I" };
9931019075SJoe Perches static const char * const bitsname[] = { "SINGLE", "DOUBLE" };
1001da177e4SLinus Torvalds int status = MCHK_DISPOSITION_REPORT;
1011da177e4SLinus Torvalds int source = -1, stream = -1, bits = -1;
1021da177e4SLinus Torvalds
1031da177e4SLinus Torvalds #define EV6__C_STAT__BC_PERR (0x01)
1041da177e4SLinus Torvalds #define EV6__C_STAT__DC_PERR (0x02)
1051da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_MEM_ERR (0x03)
1061da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_BC_ERR (0x04)
1071da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_DC_ERR (0x05)
1081da177e4SLinus Torvalds #define EV6__C_STAT__PROBE_BC_ERR0 (0x06) /* both 6 and 7 indicate... */
1091da177e4SLinus Torvalds #define EV6__C_STAT__PROBE_BC_ERR1 (0x07) /* ...probe bc error. */
1101da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_MEM_ERR (0x0B)
1111da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_BC_ERR (0x0C)
1121da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_MEM_DBL (0x13)
1131da177e4SLinus Torvalds #define EV6__C_STAT__DSTREAM_BC_DBL (0x14)
1141da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_MEM_DBL (0x1B)
1151da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM_BC_DBL (0x1C)
1161da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE_MEMORY (0x03)
1171da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE_BCACHE (0x04)
1181da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE__S (0)
1191da177e4SLinus Torvalds #define EV6__C_STAT__SOURCE__M (0x07)
1201da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM__S (3)
1211da177e4SLinus Torvalds #define EV6__C_STAT__ISTREAM__M (0x01)
1221da177e4SLinus Torvalds #define EV6__C_STAT__DOUBLE__S (4)
1231da177e4SLinus Torvalds #define EV6__C_STAT__DOUBLE__M (0x01)
1241da177e4SLinus Torvalds #define EV6__C_STAT__ERRMASK (0x1F)
1251da177e4SLinus Torvalds #define EV6__C_STS__SHARED (1 << 0)
1261da177e4SLinus Torvalds #define EV6__C_STS__DIRTY (1 << 1)
1271da177e4SLinus Torvalds #define EV6__C_STS__VALID (1 << 2)
1281da177e4SLinus Torvalds #define EV6__C_STS__PARITY (1 << 3)
1291da177e4SLinus Torvalds
1301da177e4SLinus Torvalds if (!(c_stat & EV6__C_STAT__ERRMASK))
1311da177e4SLinus Torvalds return MCHK_DISPOSITION_UNKNOWN_ERROR;
1321da177e4SLinus Torvalds
1331da177e4SLinus Torvalds if (!print)
1341da177e4SLinus Torvalds return status;
1351da177e4SLinus Torvalds
1361da177e4SLinus Torvalds source = EXTRACT(c_stat, EV6__C_STAT__SOURCE);
1371da177e4SLinus Torvalds stream = EXTRACT(c_stat, EV6__C_STAT__ISTREAM);
1381da177e4SLinus Torvalds bits = EXTRACT(c_stat, EV6__C_STAT__DOUBLE);
1391da177e4SLinus Torvalds
1401da177e4SLinus Torvalds if (c_stat & EV6__C_STAT__BC_PERR) {
1411da177e4SLinus Torvalds printk("%s Bcache tag parity error\n", err_print_prefix);
1421da177e4SLinus Torvalds source = -1;
1431da177e4SLinus Torvalds }
1441da177e4SLinus Torvalds
1451da177e4SLinus Torvalds if (c_stat & EV6__C_STAT__DC_PERR) {
1461da177e4SLinus Torvalds printk("%s Dcache tag parity error\n", err_print_prefix);
1471da177e4SLinus Torvalds source = -1;
1481da177e4SLinus Torvalds }
1491da177e4SLinus Torvalds
1501da177e4SLinus Torvalds if (c_stat == EV6__C_STAT__PROBE_BC_ERR0 ||
1511da177e4SLinus Torvalds c_stat == EV6__C_STAT__PROBE_BC_ERR1) {
1521da177e4SLinus Torvalds printk("%s Bcache single-bit error on a probe hit\n",
1531da177e4SLinus Torvalds err_print_prefix);
1541da177e4SLinus Torvalds source = -1;
1551da177e4SLinus Torvalds }
1561da177e4SLinus Torvalds
1571da177e4SLinus Torvalds if (source != -1)
1581da177e4SLinus Torvalds printk("%s %s-STREAM %s-BIT ECC error from %s\n",
1591da177e4SLinus Torvalds err_print_prefix,
1601da177e4SLinus Torvalds streamname[stream], bitsname[bits], sourcename[source]);
1611da177e4SLinus Torvalds
1625f0e3da6SRandy Dunlap printk("%s Address: 0x%016llx\n"
1635f0e3da6SRandy Dunlap " Syndrome[upper.lower]: %02llx.%02llx\n",
1641da177e4SLinus Torvalds err_print_prefix,
1651da177e4SLinus Torvalds c_addr,
1661da177e4SLinus Torvalds c2_syn, c1_syn);
1671da177e4SLinus Torvalds
1681da177e4SLinus Torvalds if (source == EV6__C_STAT__SOURCE_MEMORY ||
1691da177e4SLinus Torvalds source == EV6__C_STAT__SOURCE_BCACHE)
1701da177e4SLinus Torvalds printk("%s Block status: %s%s%s%s\n",
1711da177e4SLinus Torvalds err_print_prefix,
1721da177e4SLinus Torvalds (c_sts & EV6__C_STS__SHARED) ? "SHARED " : "",
1731da177e4SLinus Torvalds (c_sts & EV6__C_STS__DIRTY) ? "DIRTY " : "",
1741da177e4SLinus Torvalds (c_sts & EV6__C_STS__VALID) ? "VALID " : "",
1751da177e4SLinus Torvalds (c_sts & EV6__C_STS__PARITY) ? "PARITY " : "");
1761da177e4SLinus Torvalds
1771da177e4SLinus Torvalds return status;
1781da177e4SLinus Torvalds }
1791da177e4SLinus Torvalds
1801da177e4SLinus Torvalds void
ev6_register_error_handlers(void)1811da177e4SLinus Torvalds ev6_register_error_handlers(void)
1821da177e4SLinus Torvalds {
1831da177e4SLinus Torvalds /* None right now. */
1841da177e4SLinus Torvalds }
1851da177e4SLinus Torvalds
1861da177e4SLinus Torvalds int
ev6_process_logout_frame(struct el_common * mchk_header,int print)1871da177e4SLinus Torvalds ev6_process_logout_frame(struct el_common *mchk_header, int print)
1881da177e4SLinus Torvalds {
1891da177e4SLinus Torvalds struct el_common_EV6_mcheck *ev6mchk =
1901da177e4SLinus Torvalds (struct el_common_EV6_mcheck *)mchk_header;
1911da177e4SLinus Torvalds int status = MCHK_DISPOSITION_UNKNOWN_ERROR;
1921da177e4SLinus Torvalds
1931da177e4SLinus Torvalds status |= ev6_parse_ibox(ev6mchk->I_STAT, print);
1941da177e4SLinus Torvalds status |= ev6_parse_mbox(ev6mchk->MM_STAT, ev6mchk->DC_STAT,
1951da177e4SLinus Torvalds ev6mchk->C_STAT, print);
1961da177e4SLinus Torvalds status |= ev6_parse_cbox(ev6mchk->C_ADDR, ev6mchk->DC1_SYNDROME,
1971da177e4SLinus Torvalds ev6mchk->DC0_SYNDROME, ev6mchk->C_STAT,
1981da177e4SLinus Torvalds ev6mchk->C_STS, print);
1991da177e4SLinus Torvalds
2001da177e4SLinus Torvalds if (!print)
2011da177e4SLinus Torvalds return status;
2021da177e4SLinus Torvalds
2031da177e4SLinus Torvalds if (status != MCHK_DISPOSITION_DISMISS) {
2041da177e4SLinus Torvalds char *saved_err_prefix = err_print_prefix;
2051da177e4SLinus Torvalds
2061da177e4SLinus Torvalds /*
2071da177e4SLinus Torvalds * Dump some additional information from the frame
2081da177e4SLinus Torvalds */
2091da177e4SLinus Torvalds printk("%s EXC_ADDR: 0x%016lx IER_CM: 0x%016lx"
2101da177e4SLinus Torvalds " ISUM: 0x%016lx\n"
2111da177e4SLinus Torvalds " PAL_BASE: 0x%016lx I_CTL: 0x%016lx"
2121da177e4SLinus Torvalds " PCTX: 0x%016lx\n",
2131da177e4SLinus Torvalds err_print_prefix,
2141da177e4SLinus Torvalds ev6mchk->EXC_ADDR, ev6mchk->IER_CM, ev6mchk->ISUM,
2151da177e4SLinus Torvalds ev6mchk->PAL_BASE, ev6mchk->I_CTL, ev6mchk->PCTX);
2161da177e4SLinus Torvalds
2171da177e4SLinus Torvalds if (status == MCHK_DISPOSITION_UNKNOWN_ERROR) {
2181da177e4SLinus Torvalds printk("%s UNKNOWN error, frame follows:\n",
2191da177e4SLinus Torvalds err_print_prefix);
2201da177e4SLinus Torvalds } else {
2211da177e4SLinus Torvalds /* had decode -- downgrade print level for frame */
2221da177e4SLinus Torvalds err_print_prefix = KERN_NOTICE;
2231da177e4SLinus Torvalds }
2241da177e4SLinus Torvalds
2251da177e4SLinus Torvalds mchk_dump_logout_frame(mchk_header);
2261da177e4SLinus Torvalds
2271da177e4SLinus Torvalds err_print_prefix = saved_err_prefix;
2281da177e4SLinus Torvalds }
2291da177e4SLinus Torvalds
2301da177e4SLinus Torvalds return status;
2311da177e4SLinus Torvalds }
2321da177e4SLinus Torvalds
2331da177e4SLinus Torvalds void
ev6_machine_check(unsigned long vector,unsigned long la_ptr)2341ffb1c0cSIvan Kokshaysky ev6_machine_check(unsigned long vector, unsigned long la_ptr)
2351da177e4SLinus Torvalds {
2361da177e4SLinus Torvalds struct el_common *mchk_header = (struct el_common *)la_ptr;
2371da177e4SLinus Torvalds
2381da177e4SLinus Torvalds /*
2391da177e4SLinus Torvalds * Sync the processor
2401da177e4SLinus Torvalds */
2411da177e4SLinus Torvalds mb();
2421da177e4SLinus Torvalds draina();
2431da177e4SLinus Torvalds
2441da177e4SLinus Torvalds /*
2451da177e4SLinus Torvalds * Parse the logout frame without printing first. If the only error(s)
2461da177e4SLinus Torvalds * found are have a disposition of "dismiss", then just dismiss them
2471da177e4SLinus Torvalds * and don't print any message
2481da177e4SLinus Torvalds */
2491da177e4SLinus Torvalds if (ev6_process_logout_frame(mchk_header, 0) !=
2501da177e4SLinus Torvalds MCHK_DISPOSITION_DISMISS) {
2511da177e4SLinus Torvalds char *saved_err_prefix = err_print_prefix;
2521da177e4SLinus Torvalds err_print_prefix = KERN_CRIT;
2531da177e4SLinus Torvalds
2541da177e4SLinus Torvalds /*
2551da177e4SLinus Torvalds * Either a nondismissable error was detected or no
2561da177e4SLinus Torvalds * recognized error was detected in the logout frame
2571da177e4SLinus Torvalds * -- report the error in either case
2581da177e4SLinus Torvalds */
2591da177e4SLinus Torvalds printk("%s*CPU %s Error (Vector 0x%x) reported on CPU %d:\n",
2601da177e4SLinus Torvalds err_print_prefix,
2611da177e4SLinus Torvalds (vector == SCB_Q_PROCERR)?"Correctable":"Uncorrectable",
2621da177e4SLinus Torvalds (unsigned int)vector, (int)smp_processor_id());
2631da177e4SLinus Torvalds
2641da177e4SLinus Torvalds ev6_process_logout_frame(mchk_header, 1);
2654fa1970aSAl Viro dik_show_regs(get_irq_regs(), NULL);
2661da177e4SLinus Torvalds
2671da177e4SLinus Torvalds err_print_prefix = saved_err_prefix;
2681da177e4SLinus Torvalds }
2691da177e4SLinus Torvalds
2701da177e4SLinus Torvalds /*
2711da177e4SLinus Torvalds * Release the logout frame
2721da177e4SLinus Torvalds */
2731da177e4SLinus Torvalds wrmces(0x7);
2741da177e4SLinus Torvalds mb();
2751da177e4SLinus Torvalds }
2761da177e4SLinus Torvalds
277