162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 362306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 462306a36Sopenharmony_ci * for more details. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 1994, 1995, 1996, 1999, 2000 by Ralf Baechle 762306a36Sopenharmony_ci * Copyright (C) 1999, 2000 by Silicon Graphics 862306a36Sopenharmony_ci * Copyright (C) 2002 Maciej W. Rozycki 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci#include <linux/init.h> 1162306a36Sopenharmony_ci#include <linux/kernel.h> 1262306a36Sopenharmony_ci#include <linux/signal.h> /* for SIGBUS */ 1362306a36Sopenharmony_ci#include <linux/sched.h> /* schow_regs(), force_sig() */ 1462306a36Sopenharmony_ci#include <linux/sched/debug.h> 1562306a36Sopenharmony_ci#include <linux/sched/signal.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#include <asm/ptrace.h> 1862306a36Sopenharmony_ci#include <asm/sn/addrs.h> 1962306a36Sopenharmony_ci#include <asm/sn/agent.h> 2062306a36Sopenharmony_ci#include <asm/sn/arch.h> 2162306a36Sopenharmony_ci#include <asm/tlbdebug.h> 2262306a36Sopenharmony_ci#include <asm/traps.h> 2362306a36Sopenharmony_ci#include <linux/uaccess.h> 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistatic void dump_hub_information(unsigned long errst0, unsigned long errst1) 2662306a36Sopenharmony_ci{ 2762306a36Sopenharmony_ci static char *err_type[2][8] = { 2862306a36Sopenharmony_ci { NULL, "Uncached Partial Read PRERR", "DERR", "Read Timeout", 2962306a36Sopenharmony_ci NULL, NULL, NULL, NULL }, 3062306a36Sopenharmony_ci { "WERR", "Uncached Partial Write", "PWERR", "Write Timeout", 3162306a36Sopenharmony_ci NULL, NULL, NULL, NULL } 3262306a36Sopenharmony_ci }; 3362306a36Sopenharmony_ci union pi_err_stat0 st0; 3462306a36Sopenharmony_ci union pi_err_stat1 st1; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci st0.pi_stat0_word = errst0; 3762306a36Sopenharmony_ci st1.pi_stat1_word = errst1; 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci if (!st0.pi_stat0_fmt.s0_valid) { 4062306a36Sopenharmony_ci pr_info("Hub does not contain valid error information\n"); 4162306a36Sopenharmony_ci return; 4262306a36Sopenharmony_ci } 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci pr_info("Hub has valid error information:\n"); 4562306a36Sopenharmony_ci if (st0.pi_stat0_fmt.s0_ovr_run) 4662306a36Sopenharmony_ci pr_info("Overrun is set. Error stack may contain additional " 4762306a36Sopenharmony_ci "information.\n"); 4862306a36Sopenharmony_ci pr_info("Hub error address is %08lx\n", 4962306a36Sopenharmony_ci (unsigned long)st0.pi_stat0_fmt.s0_addr); 5062306a36Sopenharmony_ci pr_info("Incoming message command 0x%lx\n", 5162306a36Sopenharmony_ci (unsigned long)st0.pi_stat0_fmt.s0_cmd); 5262306a36Sopenharmony_ci pr_info("Supplemental field of incoming message is 0x%lx\n", 5362306a36Sopenharmony_ci (unsigned long)st0.pi_stat0_fmt.s0_supl); 5462306a36Sopenharmony_ci pr_info("T5 Rn (for RRB only) is 0x%lx\n", 5562306a36Sopenharmony_ci (unsigned long)st0.pi_stat0_fmt.s0_t5_req); 5662306a36Sopenharmony_ci pr_info("Error type is %s\n", err_type[st1.pi_stat1_fmt.s1_rw_rb] 5762306a36Sopenharmony_ci [st0.pi_stat0_fmt.s0_err_type] ? : "invalid"); 5862306a36Sopenharmony_ci} 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ciint ip27_be_handler(struct pt_regs *regs, int is_fixup) 6162306a36Sopenharmony_ci{ 6262306a36Sopenharmony_ci unsigned long errst0, errst1; 6362306a36Sopenharmony_ci int data = regs->cp0_cause & 4; 6462306a36Sopenharmony_ci int cpu = LOCAL_HUB_L(PI_CPU_NUM); 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci if (is_fixup) 6762306a36Sopenharmony_ci return MIPS_BE_FIXUP; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci printk("Slice %c got %cbe at 0x%lx\n", 'A' + cpu, data ? 'd' : 'i', 7062306a36Sopenharmony_ci regs->cp0_epc); 7162306a36Sopenharmony_ci printk("Hub information:\n"); 7262306a36Sopenharmony_ci printk("ERR_INT_PEND = 0x%06llx\n", LOCAL_HUB_L(PI_ERR_INT_PEND)); 7362306a36Sopenharmony_ci errst0 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS0_B : PI_ERR_STATUS0_A); 7462306a36Sopenharmony_ci errst1 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS1_B : PI_ERR_STATUS1_A); 7562306a36Sopenharmony_ci dump_hub_information(errst0, errst1); 7662306a36Sopenharmony_ci show_regs(regs); 7762306a36Sopenharmony_ci dump_tlb_all(); 7862306a36Sopenharmony_ci while(1); 7962306a36Sopenharmony_ci force_sig(SIGBUS); 8062306a36Sopenharmony_ci} 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_civoid __init ip27_be_init(void) 8362306a36Sopenharmony_ci{ 8462306a36Sopenharmony_ci /* XXX Initialize all the Hub & Bridge error handling here. */ 8562306a36Sopenharmony_ci int cpu = LOCAL_HUB_L(PI_CPU_NUM); 8662306a36Sopenharmony_ci int cpuoff = cpu << 8; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci mips_set_be_handler(ip27_be_handler); 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci LOCAL_HUB_S(PI_ERR_INT_PEND, 9162306a36Sopenharmony_ci cpu ? PI_ERR_CLEAR_ALL_B : PI_ERR_CLEAR_ALL_A); 9262306a36Sopenharmony_ci LOCAL_HUB_S(PI_ERR_INT_MASK_A + cpuoff, 0); 9362306a36Sopenharmony_ci LOCAL_HUB_S(PI_ERR_STACK_ADDR_A + cpuoff, 0); 9462306a36Sopenharmony_ci LOCAL_HUB_S(PI_ERR_STACK_SIZE, 0); /* Disable error stack */ 9562306a36Sopenharmony_ci LOCAL_HUB_S(PI_SYSAD_ERRCHK_EN, PI_SYSAD_CHECK_ALL); 9662306a36Sopenharmony_ci} 97