1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * linux/arch/alpha/kernel/err_ev7.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/init.h>
111da177e4SLinus Torvalds #include <linux/sched.h>
121da177e4SLinus Torvalds
131da177e4SLinus Torvalds #include <asm/io.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_ev7.h>
181da177e4SLinus Torvalds
191da177e4SLinus Torvalds #include "err_impl.h"
201da177e4SLinus Torvalds #include "proto.h"
211da177e4SLinus Torvalds
221da177e4SLinus Torvalds struct ev7_lf_subpackets *
ev7_collect_logout_frame_subpackets(struct el_subpacket * el_ptr,struct ev7_lf_subpackets * lf_subpackets)231da177e4SLinus Torvalds ev7_collect_logout_frame_subpackets(struct el_subpacket *el_ptr,
241da177e4SLinus Torvalds struct ev7_lf_subpackets *lf_subpackets)
251da177e4SLinus Torvalds {
261da177e4SLinus Torvalds struct el_subpacket *subpacket;
271da177e4SLinus Torvalds int i;
281da177e4SLinus Torvalds
291da177e4SLinus Torvalds /*
301da177e4SLinus Torvalds * A Marvel machine check frame is always packaged in an
311da177e4SLinus Torvalds * el_subpacket of class HEADER, type LOGOUT_FRAME.
321da177e4SLinus Torvalds */
331da177e4SLinus Torvalds if (el_ptr->class != EL_CLASS__HEADER ||
341da177e4SLinus Torvalds el_ptr->type != EL_TYPE__HEADER__LOGOUT_FRAME)
351da177e4SLinus Torvalds return NULL;
361da177e4SLinus Torvalds
371da177e4SLinus Torvalds /*
381da177e4SLinus Torvalds * It is a logout frame header. Look at the one subpacket.
391da177e4SLinus Torvalds */
401da177e4SLinus Torvalds el_ptr = (struct el_subpacket *)
411da177e4SLinus Torvalds ((unsigned long)el_ptr + el_ptr->length);
421da177e4SLinus Torvalds
431da177e4SLinus Torvalds /*
441da177e4SLinus Torvalds * It has to be class PAL, type LOGOUT_FRAME.
451da177e4SLinus Torvalds */
461da177e4SLinus Torvalds if (el_ptr->class != EL_CLASS__PAL ||
471da177e4SLinus Torvalds el_ptr->type != EL_TYPE__PAL__LOGOUT_FRAME)
481da177e4SLinus Torvalds return NULL;
491da177e4SLinus Torvalds
501da177e4SLinus Torvalds lf_subpackets->logout = (struct ev7_pal_logout_subpacket *)
511da177e4SLinus Torvalds el_ptr->by_type.raw.data_start;
521da177e4SLinus Torvalds
531da177e4SLinus Torvalds /*
541da177e4SLinus Torvalds * Process the subpackets.
551da177e4SLinus Torvalds */
561da177e4SLinus Torvalds subpacket = (struct el_subpacket *)
571da177e4SLinus Torvalds ((unsigned long)el_ptr + el_ptr->length);
581da177e4SLinus Torvalds for (i = 0;
591da177e4SLinus Torvalds subpacket && i < lf_subpackets->logout->subpacket_count;
601da177e4SLinus Torvalds subpacket = (struct el_subpacket *)
611da177e4SLinus Torvalds ((unsigned long)subpacket + subpacket->length), i++) {
621da177e4SLinus Torvalds /*
631da177e4SLinus Torvalds * All subpackets should be class PAL.
641da177e4SLinus Torvalds */
651da177e4SLinus Torvalds if (subpacket->class != EL_CLASS__PAL) {
661da177e4SLinus Torvalds printk("%s**UNEXPECTED SUBPACKET CLASS %d "
671da177e4SLinus Torvalds "IN LOGOUT FRAME (packet %d\n",
681da177e4SLinus Torvalds err_print_prefix, subpacket->class, i);
691da177e4SLinus Torvalds return NULL;
701da177e4SLinus Torvalds }
711da177e4SLinus Torvalds
721da177e4SLinus Torvalds /*
731da177e4SLinus Torvalds * Remember the subpacket.
741da177e4SLinus Torvalds */
751da177e4SLinus Torvalds switch(subpacket->type) {
761da177e4SLinus Torvalds case EL_TYPE__PAL__EV7_PROCESSOR:
771da177e4SLinus Torvalds lf_subpackets->ev7 =
781da177e4SLinus Torvalds (struct ev7_pal_processor_subpacket *)
791da177e4SLinus Torvalds subpacket->by_type.raw.data_start;
801da177e4SLinus Torvalds break;
811da177e4SLinus Torvalds
821da177e4SLinus Torvalds case EL_TYPE__PAL__EV7_RBOX:
831da177e4SLinus Torvalds lf_subpackets->rbox = (struct ev7_pal_rbox_subpacket *)
841da177e4SLinus Torvalds subpacket->by_type.raw.data_start;
851da177e4SLinus Torvalds break;
861da177e4SLinus Torvalds
871da177e4SLinus Torvalds case EL_TYPE__PAL__EV7_ZBOX:
881da177e4SLinus Torvalds lf_subpackets->zbox = (struct ev7_pal_zbox_subpacket *)
891da177e4SLinus Torvalds subpacket->by_type.raw.data_start;
901da177e4SLinus Torvalds break;
911da177e4SLinus Torvalds
921da177e4SLinus Torvalds case EL_TYPE__PAL__EV7_IO:
931da177e4SLinus Torvalds lf_subpackets->io = (struct ev7_pal_io_subpacket *)
941da177e4SLinus Torvalds subpacket->by_type.raw.data_start;
951da177e4SLinus Torvalds break;
961da177e4SLinus Torvalds
971da177e4SLinus Torvalds case EL_TYPE__PAL__ENV__AMBIENT_TEMPERATURE:
981da177e4SLinus Torvalds case EL_TYPE__PAL__ENV__AIRMOVER_FAN:
991da177e4SLinus Torvalds case EL_TYPE__PAL__ENV__VOLTAGE:
1001da177e4SLinus Torvalds case EL_TYPE__PAL__ENV__INTRUSION:
1011da177e4SLinus Torvalds case EL_TYPE__PAL__ENV__POWER_SUPPLY:
1021da177e4SLinus Torvalds case EL_TYPE__PAL__ENV__LAN:
1031da177e4SLinus Torvalds case EL_TYPE__PAL__ENV__HOT_PLUG:
1041da177e4SLinus Torvalds lf_subpackets->env[ev7_lf_env_index(subpacket->type)] =
1051da177e4SLinus Torvalds (struct ev7_pal_environmental_subpacket *)
1061da177e4SLinus Torvalds subpacket->by_type.raw.data_start;
1071da177e4SLinus Torvalds break;
1081da177e4SLinus Torvalds
1091da177e4SLinus Torvalds default:
1101da177e4SLinus Torvalds /*
1111da177e4SLinus Torvalds * Don't know what kind of frame this is.
1121da177e4SLinus Torvalds */
1131da177e4SLinus Torvalds return NULL;
1141da177e4SLinus Torvalds }
1151da177e4SLinus Torvalds }
1161da177e4SLinus Torvalds
1171da177e4SLinus Torvalds return lf_subpackets;
1181da177e4SLinus Torvalds }
1191da177e4SLinus Torvalds
1201da177e4SLinus Torvalds void
ev7_machine_check(unsigned long vector,unsigned long la_ptr)1211ffb1c0cSIvan Kokshaysky ev7_machine_check(unsigned long vector, unsigned long la_ptr)
1221da177e4SLinus Torvalds {
1231da177e4SLinus Torvalds struct el_subpacket *el_ptr = (struct el_subpacket *)la_ptr;
1241da177e4SLinus Torvalds char *saved_err_prefix = err_print_prefix;
1251da177e4SLinus Torvalds
1261da177e4SLinus Torvalds /*
1271da177e4SLinus Torvalds * Sync the processor
1281da177e4SLinus Torvalds */
1291da177e4SLinus Torvalds mb();
1301da177e4SLinus Torvalds draina();
1311da177e4SLinus Torvalds
1321da177e4SLinus Torvalds err_print_prefix = KERN_CRIT;
1331da177e4SLinus Torvalds printk("%s*CPU %s Error (Vector 0x%x) reported on CPU %d\n",
1341da177e4SLinus Torvalds err_print_prefix,
1351da177e4SLinus Torvalds (vector == SCB_Q_PROCERR) ? "Correctable" : "Uncorrectable",
1361da177e4SLinus Torvalds (unsigned int)vector, (int)smp_processor_id());
1371da177e4SLinus Torvalds el_process_subpacket(el_ptr);
1381da177e4SLinus Torvalds err_print_prefix = saved_err_prefix;
1391da177e4SLinus Torvalds
1401da177e4SLinus Torvalds /*
1411da177e4SLinus Torvalds * Release the logout frame
1421da177e4SLinus Torvalds */
1431da177e4SLinus Torvalds wrmces(0x7);
1441da177e4SLinus Torvalds mb();
1451da177e4SLinus Torvalds }
1461da177e4SLinus Torvalds
1471da177e4SLinus Torvalds static char *el_ev7_processor_subpacket_annotation[] = {
1481da177e4SLinus Torvalds "Subpacket Header", "I_STAT", "DC_STAT",
1491da177e4SLinus Torvalds "C_ADDR", "C_SYNDROME_1", "C_SYNDROME_0",
1501da177e4SLinus Torvalds "C_STAT", "C_STS", "MM_STAT",
1511da177e4SLinus Torvalds "EXC_ADDR", "IER_CM", "ISUM",
1521da177e4SLinus Torvalds "PAL_BASE", "I_CTL", "PROCESS_CONTEXT",
1531da177e4SLinus Torvalds "CBOX_CTL", "CBOX_STP_CTL", "CBOX_ACC_CTL",
1541da177e4SLinus Torvalds "CBOX_LCL_SET", "CBOX_GLB_SET", "BBOX_CTL",
1551da177e4SLinus Torvalds "BBOX_ERR_STS", "BBOX_ERR_IDX", "CBOX_DDP_ERR_STS",
1561da177e4SLinus Torvalds "BBOX_DAT_RMP", NULL
1571da177e4SLinus Torvalds };
1581da177e4SLinus Torvalds
1591da177e4SLinus Torvalds static char *el_ev7_zbox_subpacket_annotation[] = {
1601da177e4SLinus Torvalds "Subpacket Header",
1611da177e4SLinus Torvalds "ZBOX(0): DRAM_ERR_STATUS_2 / DRAM_ERR_STATUS_1",
1621da177e4SLinus Torvalds "ZBOX(0): DRAM_ERROR_CTL / DRAM_ERR_STATUS_3",
1631da177e4SLinus Torvalds "ZBOX(0): DIFT_TIMEOUT / DRAM_ERR_ADR",
1641da177e4SLinus Torvalds "ZBOX(0): FRC_ERR_ADR / DRAM_MAPPER_CTL",
1651da177e4SLinus Torvalds "ZBOX(0): reserved / DIFT_ERR_STATUS",
1661da177e4SLinus Torvalds "ZBOX(1): DRAM_ERR_STATUS_2 / DRAM_ERR_STATUS_1",
1671da177e4SLinus Torvalds "ZBOX(1): DRAM_ERROR_CTL / DRAM_ERR_STATUS_3",
1681da177e4SLinus Torvalds "ZBOX(1): DIFT_TIMEOUT / DRAM_ERR_ADR",
1691da177e4SLinus Torvalds "ZBOX(1): FRC_ERR_ADR / DRAM_MAPPER_CTL",
1701da177e4SLinus Torvalds "ZBOX(1): reserved / DIFT_ERR_STATUS",
1711da177e4SLinus Torvalds "CBOX_CTL", "CBOX_STP_CTL",
1721da177e4SLinus Torvalds "ZBOX(0)_ERROR_PA", "ZBOX(1)_ERROR_PA",
1731da177e4SLinus Torvalds "ZBOX(0)_ORED_SYNDROME","ZBOX(1)_ORED_SYNDROME",
1741da177e4SLinus Torvalds NULL
1751da177e4SLinus Torvalds };
1761da177e4SLinus Torvalds
1771da177e4SLinus Torvalds static char *el_ev7_rbox_subpacket_annotation[] = {
1781da177e4SLinus Torvalds "Subpacket Header", "RBOX_CFG", "RBOX_N_CFG",
1791da177e4SLinus Torvalds "RBOX_S_CFG", "RBOX_E_CFG", "RBOX_W_CFG",
1801da177e4SLinus Torvalds "RBOX_N_ERR", "RBOX_S_ERR", "RBOX_E_ERR",
1811da177e4SLinus Torvalds "RBOX_W_ERR", "RBOX_IO_CFG", "RBOX_IO_ERR",
1821da177e4SLinus Torvalds "RBOX_L_ERR", "RBOX_WHOAMI", "RBOX_IMASL",
1831da177e4SLinus Torvalds "RBOX_INTQ", "RBOX_INT", NULL
1841da177e4SLinus Torvalds };
1851da177e4SLinus Torvalds
1861da177e4SLinus Torvalds static char *el_ev7_io_subpacket_annotation[] = {
1871da177e4SLinus Torvalds "Subpacket Header", "IO_ASIC_REV", "IO_SYS_REV",
1881da177e4SLinus Torvalds "IO7_UPH", "HPI_CTL", "CRD_CTL",
1891da177e4SLinus Torvalds "HEI_CTL", "PO7_ERROR_SUM","PO7_UNCRR_SYM",
1901da177e4SLinus Torvalds "PO7_CRRCT_SYM", "PO7_UGBGE_SYM","PO7_ERR_PKT0",
1911da177e4SLinus Torvalds "PO7_ERR_PKT1", "reserved", "reserved",
1921da177e4SLinus Torvalds "PO0_ERR_SUM", "PO0_TLB_ERR", "PO0_SPL_COMPLT",
1931da177e4SLinus Torvalds "PO0_TRANS_SUM", "PO0_FIRST_ERR","PO0_MULT_ERR",
1941da177e4SLinus Torvalds "DM CSR PH", "DM CSR PH", "DM CSR PH",
1951da177e4SLinus Torvalds "DM CSR PH", "reserved",
1961da177e4SLinus Torvalds "PO1_ERR_SUM", "PO1_TLB_ERR", "PO1_SPL_COMPLT",
1971da177e4SLinus Torvalds "PO1_TRANS_SUM", "PO1_FIRST_ERR","PO1_MULT_ERR",
1981da177e4SLinus Torvalds "DM CSR PH", "DM CSR PH", "DM CSR PH",
1991da177e4SLinus Torvalds "DM CSR PH", "reserved",
2001da177e4SLinus Torvalds "PO2_ERR_SUM", "PO2_TLB_ERR", "PO2_SPL_COMPLT",
2011da177e4SLinus Torvalds "PO2_TRANS_SUM", "PO2_FIRST_ERR","PO2_MULT_ERR",
2021da177e4SLinus Torvalds "DM CSR PH", "DM CSR PH", "DM CSR PH",
2031da177e4SLinus Torvalds "DM CSR PH", "reserved",
2041da177e4SLinus Torvalds "PO3_ERR_SUM", "PO3_TLB_ERR", "PO3_SPL_COMPLT",
2051da177e4SLinus Torvalds "PO3_TRANS_SUM", "PO3_FIRST_ERR","PO3_MULT_ERR",
2061da177e4SLinus Torvalds "DM CSR PH", "DM CSR PH", "DM CSR PH",
2071da177e4SLinus Torvalds "DM CSR PH", "reserved",
2081da177e4SLinus Torvalds NULL
2091da177e4SLinus Torvalds };
2101da177e4SLinus Torvalds
2111da177e4SLinus Torvalds static struct el_subpacket_annotation el_ev7_pal_annotations[] = {
2121da177e4SLinus Torvalds SUBPACKET_ANNOTATION(EL_CLASS__PAL,
2131da177e4SLinus Torvalds EL_TYPE__PAL__EV7_PROCESSOR,
2141da177e4SLinus Torvalds 1,
2151da177e4SLinus Torvalds "EV7 Processor Subpacket",
2161da177e4SLinus Torvalds el_ev7_processor_subpacket_annotation),
2171da177e4SLinus Torvalds SUBPACKET_ANNOTATION(EL_CLASS__PAL,
2181da177e4SLinus Torvalds EL_TYPE__PAL__EV7_ZBOX,
2191da177e4SLinus Torvalds 1,
2201da177e4SLinus Torvalds "EV7 ZBOX Subpacket",
2211da177e4SLinus Torvalds el_ev7_zbox_subpacket_annotation),
2221da177e4SLinus Torvalds SUBPACKET_ANNOTATION(EL_CLASS__PAL,
2231da177e4SLinus Torvalds EL_TYPE__PAL__EV7_RBOX,
2241da177e4SLinus Torvalds 1,
2251da177e4SLinus Torvalds "EV7 RBOX Subpacket",
2261da177e4SLinus Torvalds el_ev7_rbox_subpacket_annotation),
2271da177e4SLinus Torvalds SUBPACKET_ANNOTATION(EL_CLASS__PAL,
2281da177e4SLinus Torvalds EL_TYPE__PAL__EV7_IO,
2291da177e4SLinus Torvalds 1,
2301da177e4SLinus Torvalds "EV7 IO Subpacket",
2311da177e4SLinus Torvalds el_ev7_io_subpacket_annotation)
2321da177e4SLinus Torvalds };
2331da177e4SLinus Torvalds
2341da177e4SLinus Torvalds static struct el_subpacket *
ev7_process_pal_subpacket(struct el_subpacket * header)2351da177e4SLinus Torvalds ev7_process_pal_subpacket(struct el_subpacket *header)
2361da177e4SLinus Torvalds {
2371da177e4SLinus Torvalds struct ev7_pal_subpacket *packet;
2381da177e4SLinus Torvalds
2391da177e4SLinus Torvalds if (header->class != EL_CLASS__PAL) {
2401da177e4SLinus Torvalds printk("%s ** Unexpected header CLASS %d TYPE %d, aborting\n",
2411da177e4SLinus Torvalds err_print_prefix,
2421da177e4SLinus Torvalds header->class, header->type);
2431da177e4SLinus Torvalds return NULL;
2441da177e4SLinus Torvalds }
2451da177e4SLinus Torvalds
2461da177e4SLinus Torvalds packet = (struct ev7_pal_subpacket *)header->by_type.raw.data_start;
2471da177e4SLinus Torvalds
2481da177e4SLinus Torvalds switch(header->type) {
2491da177e4SLinus Torvalds case EL_TYPE__PAL__LOGOUT_FRAME:
2501ffb1c0cSIvan Kokshaysky printk("%s*** MCHK occurred on LPID %lld (RBOX %llx)\n",
2511da177e4SLinus Torvalds err_print_prefix,
2521da177e4SLinus Torvalds packet->by_type.logout.whami,
2531da177e4SLinus Torvalds packet->by_type.logout.rbox_whami);
2541da177e4SLinus Torvalds el_print_timestamp(&packet->by_type.logout.timestamp);
2555f0e3da6SRandy Dunlap printk("%s EXC_ADDR: %016llx\n"
2565f0e3da6SRandy Dunlap " HALT_CODE: %llx\n",
2571da177e4SLinus Torvalds err_print_prefix,
2581da177e4SLinus Torvalds packet->by_type.logout.exc_addr,
2591da177e4SLinus Torvalds packet->by_type.logout.halt_code);
2601da177e4SLinus Torvalds el_process_subpackets(header,
2611da177e4SLinus Torvalds packet->by_type.logout.subpacket_count);
2621da177e4SLinus Torvalds break;
2631da177e4SLinus Torvalds default:
2641da177e4SLinus Torvalds printk("%s ** PAL TYPE %d SUBPACKET\n",
2651da177e4SLinus Torvalds err_print_prefix,
2661da177e4SLinus Torvalds header->type);
2671da177e4SLinus Torvalds el_annotate_subpacket(header);
2681da177e4SLinus Torvalds break;
2691da177e4SLinus Torvalds }
2701da177e4SLinus Torvalds
2711da177e4SLinus Torvalds return (struct el_subpacket *)((unsigned long)header + header->length);
2721da177e4SLinus Torvalds }
2731da177e4SLinus Torvalds
2741da177e4SLinus Torvalds struct el_subpacket_handler ev7_pal_subpacket_handler =
2751da177e4SLinus Torvalds SUBPACKET_HANDLER_INIT(EL_CLASS__PAL, ev7_process_pal_subpacket);
2761da177e4SLinus Torvalds
2779548b209SIvan Kokshaysky void __init
ev7_register_error_handlers(void)2781da177e4SLinus Torvalds ev7_register_error_handlers(void)
2791da177e4SLinus Torvalds {
2801da177e4SLinus Torvalds int i;
2811da177e4SLinus Torvalds
28225c8716cSTobias Klauser for (i = 0; i < ARRAY_SIZE(el_ev7_pal_annotations); i++)
2831da177e4SLinus Torvalds cdl_register_subpacket_annotation(&el_ev7_pal_annotations[i]);
28425c8716cSTobias Klauser
2851da177e4SLinus Torvalds cdl_register_subpacket_handler(&ev7_pal_subpacket_handler);
2861da177e4SLinus Torvalds }
2871da177e4SLinus Torvalds
288