Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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