1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * This file is subject to the terms and conditions of the GNU General Public
3*4882a593Smuzhiyun * License. See the file "COPYING" in the main directory of this archive
4*4882a593Smuzhiyun * for more details.
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Copyright (C) 1994, 1995, 1996, 1999, 2000 by Ralf Baechle
7*4882a593Smuzhiyun * Copyright (C) 1999, 2000 by Silicon Graphics
8*4882a593Smuzhiyun * Copyright (C) 2002 Maciej W. Rozycki
9*4882a593Smuzhiyun */
10*4882a593Smuzhiyun #include <linux/init.h>
11*4882a593Smuzhiyun #include <linux/kernel.h>
12*4882a593Smuzhiyun #include <linux/signal.h> /* for SIGBUS */
13*4882a593Smuzhiyun #include <linux/sched.h> /* schow_regs(), force_sig() */
14*4882a593Smuzhiyun #include <linux/sched/debug.h>
15*4882a593Smuzhiyun #include <linux/sched/signal.h>
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #include <asm/ptrace.h>
18*4882a593Smuzhiyun #include <asm/sn/addrs.h>
19*4882a593Smuzhiyun #include <asm/sn/agent.h>
20*4882a593Smuzhiyun #include <asm/sn/arch.h>
21*4882a593Smuzhiyun #include <asm/tlbdebug.h>
22*4882a593Smuzhiyun #include <asm/traps.h>
23*4882a593Smuzhiyun #include <linux/uaccess.h>
24*4882a593Smuzhiyun
dump_hub_information(unsigned long errst0,unsigned long errst1)25*4882a593Smuzhiyun static void dump_hub_information(unsigned long errst0, unsigned long errst1)
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun static char *err_type[2][8] = {
28*4882a593Smuzhiyun { NULL, "Uncached Partial Read PRERR", "DERR", "Read Timeout",
29*4882a593Smuzhiyun NULL, NULL, NULL, NULL },
30*4882a593Smuzhiyun { "WERR", "Uncached Partial Write", "PWERR", "Write Timeout",
31*4882a593Smuzhiyun NULL, NULL, NULL, NULL }
32*4882a593Smuzhiyun };
33*4882a593Smuzhiyun union pi_err_stat0 st0;
34*4882a593Smuzhiyun union pi_err_stat1 st1;
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun st0.pi_stat0_word = errst0;
37*4882a593Smuzhiyun st1.pi_stat1_word = errst1;
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun if (!st0.pi_stat0_fmt.s0_valid) {
40*4882a593Smuzhiyun pr_info("Hub does not contain valid error information\n");
41*4882a593Smuzhiyun return;
42*4882a593Smuzhiyun }
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun pr_info("Hub has valid error information:\n");
45*4882a593Smuzhiyun if (st0.pi_stat0_fmt.s0_ovr_run)
46*4882a593Smuzhiyun pr_info("Overrun is set. Error stack may contain additional "
47*4882a593Smuzhiyun "information.\n");
48*4882a593Smuzhiyun pr_info("Hub error address is %08lx\n",
49*4882a593Smuzhiyun (unsigned long)st0.pi_stat0_fmt.s0_addr);
50*4882a593Smuzhiyun pr_info("Incoming message command 0x%lx\n",
51*4882a593Smuzhiyun (unsigned long)st0.pi_stat0_fmt.s0_cmd);
52*4882a593Smuzhiyun pr_info("Supplemental field of incoming message is 0x%lx\n",
53*4882a593Smuzhiyun (unsigned long)st0.pi_stat0_fmt.s0_supl);
54*4882a593Smuzhiyun pr_info("T5 Rn (for RRB only) is 0x%lx\n",
55*4882a593Smuzhiyun (unsigned long)st0.pi_stat0_fmt.s0_t5_req);
56*4882a593Smuzhiyun pr_info("Error type is %s\n", err_type[st1.pi_stat1_fmt.s1_rw_rb]
57*4882a593Smuzhiyun [st0.pi_stat0_fmt.s0_err_type] ? : "invalid");
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun
ip27_be_handler(struct pt_regs * regs,int is_fixup)60*4882a593Smuzhiyun int ip27_be_handler(struct pt_regs *regs, int is_fixup)
61*4882a593Smuzhiyun {
62*4882a593Smuzhiyun unsigned long errst0, errst1;
63*4882a593Smuzhiyun int data = regs->cp0_cause & 4;
64*4882a593Smuzhiyun int cpu = LOCAL_HUB_L(PI_CPU_NUM);
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun if (is_fixup)
67*4882a593Smuzhiyun return MIPS_BE_FIXUP;
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun printk("Slice %c got %cbe at 0x%lx\n", 'A' + cpu, data ? 'd' : 'i',
70*4882a593Smuzhiyun regs->cp0_epc);
71*4882a593Smuzhiyun printk("Hub information:\n");
72*4882a593Smuzhiyun printk("ERR_INT_PEND = 0x%06llx\n", LOCAL_HUB_L(PI_ERR_INT_PEND));
73*4882a593Smuzhiyun errst0 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS0_B : PI_ERR_STATUS0_A);
74*4882a593Smuzhiyun errst1 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS1_B : PI_ERR_STATUS1_A);
75*4882a593Smuzhiyun dump_hub_information(errst0, errst1);
76*4882a593Smuzhiyun show_regs(regs);
77*4882a593Smuzhiyun dump_tlb_all();
78*4882a593Smuzhiyun while(1);
79*4882a593Smuzhiyun force_sig(SIGBUS);
80*4882a593Smuzhiyun }
81*4882a593Smuzhiyun
ip27_be_init(void)82*4882a593Smuzhiyun void __init ip27_be_init(void)
83*4882a593Smuzhiyun {
84*4882a593Smuzhiyun /* XXX Initialize all the Hub & Bridge error handling here. */
85*4882a593Smuzhiyun int cpu = LOCAL_HUB_L(PI_CPU_NUM);
86*4882a593Smuzhiyun int cpuoff = cpu << 8;
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun board_be_handler = ip27_be_handler;
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun LOCAL_HUB_S(PI_ERR_INT_PEND,
91*4882a593Smuzhiyun cpu ? PI_ERR_CLEAR_ALL_B : PI_ERR_CLEAR_ALL_A);
92*4882a593Smuzhiyun LOCAL_HUB_S(PI_ERR_INT_MASK_A + cpuoff, 0);
93*4882a593Smuzhiyun LOCAL_HUB_S(PI_ERR_STACK_ADDR_A + cpuoff, 0);
94*4882a593Smuzhiyun LOCAL_HUB_S(PI_ERR_STACK_SIZE, 0); /* Disable error stack */
95*4882a593Smuzhiyun LOCAL_HUB_S(PI_SYSAD_ERRCHK_EN, PI_SYSAD_CHECK_ALL);
96*4882a593Smuzhiyun }
97