📄 cerr-sb1.c
字号:
/* * Copyright (C) 2001,2002,2003 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <linux/sched.h>#include <asm/mipsregs.h>#include <asm/sibyte/sb1250.h>#include <asm/sibyte/sb1250_regs.h>#if !defined(CONFIG_SIBYTE_BUS_WATCHER) || defined(CONFIG_SIBYTE_BW_TRACE)#include <asm/io.h>#include <asm/sibyte/sb1250_scd.h>#endif/* * We'd like to dump the L2_ECC_TAG register on errors, but errata make * that unsafe... So for now we don't. (BCM1250/BCM112x erratum SOC-48.) */#undef DUMP_L2_ECC_TAG_ON_ERROR/* SB1 definitions *//* XXX should come from config1 XXX */#define SB1_CACHE_INDEX_MASK 0x1fe0#define CP0_ERRCTL_RECOVERABLE (1 << 31)#define CP0_ERRCTL_DCACHE (1 << 30)#define CP0_ERRCTL_ICACHE (1 << 29)#define CP0_ERRCTL_MULTIBUS (1 << 23)#define CP0_ERRCTL_MC_TLB (1 << 15)#define CP0_ERRCTL_MC_TIMEOUT (1 << 14)#define CP0_CERRI_TAG_PARITY (1 << 29)#define CP0_CERRI_DATA_PARITY (1 << 28)#define CP0_CERRI_EXTERNAL (1 << 26)#define CP0_CERRI_IDX_VALID(c) (!((c) & CP0_CERRI_EXTERNAL))#define CP0_CERRI_DATA (CP0_CERRI_DATA_PARITY)#define CP0_CERRD_MULTIPLE (1 << 31)#define CP0_CERRD_TAG_STATE (1 << 30)#define CP0_CERRD_TAG_ADDRESS (1 << 29)#define CP0_CERRD_DATA_SBE (1 << 28)#define CP0_CERRD_DATA_DBE (1 << 27)#define CP0_CERRD_EXTERNAL (1 << 26)#define CP0_CERRD_LOAD (1 << 25)#define CP0_CERRD_STORE (1 << 24)#define CP0_CERRD_FILLWB (1 << 23)#define CP0_CERRD_COHERENCY (1 << 22)#define CP0_CERRD_DUPTAG (1 << 21)#define CP0_CERRD_DPA_VALID(c) (!((c) & CP0_CERRD_EXTERNAL))#define CP0_CERRD_IDX_VALID(c) \ (((c) & (CP0_CERRD_LOAD | CP0_CERRD_STORE)) ? (!((c) & CP0_CERRD_EXTERNAL)) : 0)#define CP0_CERRD_CAUSES \ (CP0_CERRD_LOAD | CP0_CERRD_STORE | CP0_CERRD_FILLWB | CP0_CERRD_COHERENCY | CP0_CERRD_DUPTAG)#define CP0_CERRD_TYPES \ (CP0_CERRD_TAG_STATE | CP0_CERRD_TAG_ADDRESS | CP0_CERRD_DATA_SBE | CP0_CERRD_DATA_DBE | CP0_CERRD_EXTERNAL)#define CP0_CERRD_DATA (CP0_CERRD_DATA_SBE | CP0_CERRD_DATA_DBE)static uint32_t extract_ic(unsigned short addr, int data);static uint32_t extract_dc(unsigned short addr, int data);static inline void breakout_errctl(unsigned int val){ if (val & CP0_ERRCTL_RECOVERABLE) printk(" recoverable"); if (val & CP0_ERRCTL_DCACHE) printk(" dcache"); if (val & CP0_ERRCTL_ICACHE) printk(" icache"); if (val & CP0_ERRCTL_MULTIBUS) printk(" multiple-buserr"); printk("\n");}static inline void breakout_cerri(unsigned int val){ if (val & CP0_CERRI_TAG_PARITY) printk(" tag-parity"); if (val & CP0_CERRI_DATA_PARITY) printk(" data-parity"); if (val & CP0_CERRI_EXTERNAL) printk(" external"); printk("\n");}static inline void breakout_cerrd(unsigned int val){ switch (val & CP0_CERRD_CAUSES) { case CP0_CERRD_LOAD: printk(" load,"); break; case CP0_CERRD_STORE: printk(" store,"); break; case CP0_CERRD_FILLWB: printk(" fill/wb,"); break; case CP0_CERRD_COHERENCY: printk(" coherency,"); break; case CP0_CERRD_DUPTAG: printk(" duptags,"); break; default: printk(" NO CAUSE,"); break; } if (!(val & CP0_CERRD_TYPES)) printk(" NO TYPE"); else { if (val & CP0_CERRD_MULTIPLE) printk(" multi-err"); if (val & CP0_CERRD_TAG_STATE) printk(" tag-state"); if (val & CP0_CERRD_TAG_ADDRESS) printk(" tag-address"); if (val & CP0_CERRD_DATA_SBE) printk(" data-SBE"); if (val & CP0_CERRD_DATA_DBE) printk(" data-DBE"); if (val & CP0_CERRD_EXTERNAL) printk(" external"); } printk("\n");}#ifndef CONFIG_SIBYTE_BUS_WATCHERstatic void check_bus_watcher(void){ uint32_t status, l2_err, memio_err;#ifdef DUMP_L2_ECC_TAG_ON_ERROR uint64_t l2_tag;#endif /* Destructive read, clears register and interrupt */ status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS)); /* Bit 31 is always on, but there's no #define for that */ if (status & ~(1UL << 31)) { l2_err = csr_in32(IOADDR(A_BUS_L2_ERRORS));#ifdef DUMP_L2_ECC_TAG_ON_ERROR l2_tag = in64(IOADDR(A_L2_ECC_TAG));#endif memio_err = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS)); printk("Bus watcher error counters: %08x %08x\n", l2_err, memio_err); printk("\nLast recorded signature:\n"); printk("Request %02x from %d, answered by %d with Dcode %d\n", (unsigned int)(G_SCD_BERR_TID(status) & 0x3f), (int)(G_SCD_BERR_TID(status) >> 6), (int)G_SCD_BERR_RID(status), (int)G_SCD_BERR_DCODE(status));#ifdef DUMP_L2_ECC_TAG_ON_ERROR printk("Last L2 tag w/ bad ECC: %016llx\n", l2_tag);#endif } else { printk("Bus watcher indicates no error\n"); }}#elseextern void check_bus_watcher(void);#endifasmlinkage void sb1_cache_error(void){ uint32_t errctl, cerr_i, cerr_d, dpalo, dpahi, eepc, res; unsigned long long cerr_dpa;#ifdef CONFIG_SIBYTE_BW_TRACE /* Freeze the trace buffer now */#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) csr_out32(M_BCM1480_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG));#else csr_out32(M_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG));#endif printk("Trace buffer frozen\n");#endif printk("Cache error exception on CPU %x:\n", (read_c0_prid() >> 25) & 0x7); __asm__ __volatile__ ( " .set push\n\t" " .set mips64\n\t" " .set noat\n\t" " mfc0 %0, $26\n\t" " mfc0 %1, $27\n\t" " mfc0 %2, $27, 1\n\t" " dmfc0 $1, $27, 3\n\t" " dsrl32 %3, $1, 0 \n\t" " sll %4, $1, 0 \n\t" " mfc0 %5, $30\n\t" " .set pop" : "=r" (errctl), "=r" (cerr_i), "=r" (cerr_d), "=r" (dpahi), "=r" (dpalo), "=r" (eepc)); cerr_dpa = (((uint64_t)dpahi) << 32) | dpalo; printk(" c0_errorepc == %08x\n", eepc); printk(" c0_errctl == %08x", errctl); breakout_errctl(errctl); if (errctl & CP0_ERRCTL_ICACHE) { printk(" c0_cerr_i == %08x", cerr_i); breakout_cerri(cerr_i); if (CP0_CERRI_IDX_VALID(cerr_i)) { /* Check index of EPC, allowing for delay slot */ if (((eepc & SB1_CACHE_INDEX_MASK) != (cerr_i & SB1_CACHE_INDEX_MASK)) && ((eepc & SB1_CACHE_INDEX_MASK) != ((cerr_i & SB1_CACHE_INDEX_MASK) - 4))) printk(" cerr_i idx doesn't match eepc\n"); else { res = extract_ic(cerr_i & SB1_CACHE_INDEX_MASK, (cerr_i & CP0_CERRI_DATA) != 0); if (!(res & cerr_i)) printk("...didn't see indicated icache problem\n"); } } } if (errctl & CP0_ERRCTL_DCACHE) { printk(" c0_cerr_d == %08x", cerr_d); breakout_cerrd(cerr_d); if (CP0_CERRD_DPA_VALID(cerr_d)) { printk(" c0_cerr_dpa == %010llx\n", cerr_dpa); if (!CP0_CERRD_IDX_VALID(cerr_d)) { res = extract_dc(cerr_dpa & SB1_CACHE_INDEX_MASK, (cerr_d & CP0_CERRD_DATA) != 0); if (!(res & cerr_d)) printk("...didn't see indicated dcache problem\n"); } else { if ((cerr_dpa & SB1_CACHE_INDEX_MASK) != (cerr_d & SB1_CACHE_INDEX_MASK)) printk(" cerr_d idx doesn't match cerr_dpa\n"); else { res = extract_dc(cerr_d & SB1_CACHE_INDEX_MASK, (cerr_d & CP0_CERRD_DATA) != 0); if (!(res & cerr_d)) printk("...didn't see indicated problem\n"); } } } } check_bus_watcher(); /* * Calling panic() when a fatal cache error occurs scrambles the * state of the system (and the cache), making it difficult to * investigate after the fact. However, if you just stall the CPU, * the other CPU may keep on running, which is typically very * undesirable. */#ifdef CONFIG_SB1_CERR_STALL while (1) ;#else panic("unhandled cache error");#endif}/* Parity lookup table. */static const uint8_t parity[256] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0};/* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */static const uint64_t mask_72_64[8] = { 0x0738C808099264FFULL, 0x38C808099264FF07ULL,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -