blob: 83efe03d5c600f695d073279c1d594a7ca60b471 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 1995, 1996, 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 by Silicon Graphics
8 * Copyright (C) 2002 Maciej W. Rozycki
9 */
10#include <linux/init.h>
11#include <linux/kernel.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080012#include <linux/signal.h> /* for SIGBUS */
Tim Schmielaude259682006-01-08 01:02:05 -080013#include <linux/sched.h> /* schow_regs(), force_sig() */
Ingo Molnarb17b0152017-02-08 18:51:35 +010014#include <linux/sched/debug.h>
Arnd Bergmannfc699102017-03-08 08:29:31 +010015#include <linux/sched/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Arnd Bergmannfc699102017-03-08 08:29:31 +010017#include <asm/ptrace.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/sn/addrs.h>
19#include <asm/sn/arch.h>
20#include <asm/sn/sn0/hub.h>
21#include <asm/tlbdebug.h>
22#include <asm/traps.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080023#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Linus Torvalds1da177e2005-04-16 15:20:36 -070025static void dump_hub_information(unsigned long errst0, unsigned long errst1)
26{
27 static char *err_type[2][8] = {
28 { NULL, "Uncached Partial Read PRERR", "DERR", "Read Timeout",
29 NULL, NULL, NULL, NULL },
30 { "WERR", "Uncached Partial Write", "PWERR", "Write Timeout",
31 NULL, NULL, NULL, NULL }
32 };
33 int wrb = errst1 & PI_ERR_ST1_WRBRRB_MASK;
34
35 if (!(errst0 & PI_ERR_ST0_VALID_MASK)) {
36 printk("Hub does not contain valid error information\n");
37 return;
38 }
39
40
41 printk("Hub has valid error information:\n");
42 if (errst0 & PI_ERR_ST0_OVERRUN_MASK)
Ralf Baechle70342282013-01-22 12:59:30 +010043 printk("Overrun is set. Error stack may contain additional "
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 "information.\n");
45 printk("Hub error address is %08lx\n",
46 (errst0 & PI_ERR_ST0_ADDR_MASK) >> (PI_ERR_ST0_ADDR_SHFT - 3));
47 printk("Incoming message command 0x%lx\n",
48 (errst0 & PI_ERR_ST0_CMD_MASK) >> PI_ERR_ST0_CMD_SHFT);
49 printk("Supplemental field of incoming message is 0x%lx\n",
50 (errst0 & PI_ERR_ST0_SUPPL_MASK) >> PI_ERR_ST0_SUPPL_SHFT);
51 printk("T5 Rn (for RRB only) is 0x%lx\n",
52 (errst0 & PI_ERR_ST0_REQNUM_MASK) >> PI_ERR_ST0_REQNUM_SHFT);
53 printk("Error type is %s\n", err_type[wrb]
54 [(errst0 & PI_ERR_ST0_TYPE_MASK) >> PI_ERR_ST0_TYPE_SHFT]
55 ? : "invalid");
56}
57
58int ip27_be_handler(struct pt_regs *regs, int is_fixup)
59{
60 unsigned long errst0, errst1;
61 int data = regs->cp0_cause & 4;
62 int cpu = LOCAL_HUB_L(PI_CPU_NUM);
63
64 if (is_fixup)
65 return MIPS_BE_FIXUP;
66
67 printk("Slice %c got %cbe at 0x%lx\n", 'A' + cpu, data ? 'd' : 'i',
68 regs->cp0_epc);
69 printk("Hub information:\n");
Ralf Baechle12e22e82009-03-30 14:49:41 +020070 printk("ERR_INT_PEND = 0x%06llx\n", LOCAL_HUB_L(PI_ERR_INT_PEND));
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 errst0 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS0_B : PI_ERR_STATUS0_A);
72 errst1 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS1_B : PI_ERR_STATUS1_A);
73 dump_hub_information(errst0, errst1);
74 show_regs(regs);
75 dump_tlb_all();
76 while(1);
77 force_sig(SIGBUS, current);
78}
79
80void __init ip27_be_init(void)
81{
82 /* XXX Initialize all the Hub & Bridge error handling here. */
83 int cpu = LOCAL_HUB_L(PI_CPU_NUM);
84 int cpuoff = cpu << 8;
85
86 board_be_handler = ip27_be_handler;
87
88 LOCAL_HUB_S(PI_ERR_INT_PEND,
Ralf Baechle70342282013-01-22 12:59:30 +010089 cpu ? PI_ERR_CLEAR_ALL_B : PI_ERR_CLEAR_ALL_A);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 LOCAL_HUB_S(PI_ERR_INT_MASK_A + cpuoff, 0);
91 LOCAL_HUB_S(PI_ERR_STACK_ADDR_A + cpuoff, 0);
92 LOCAL_HUB_S(PI_ERR_STACK_SIZE, 0); /* Disable error stack */
93 LOCAL_HUB_S(PI_SYSAD_ERRCHK_EN, PI_SYSAD_CHECK_ALL);
94}