ip22-berr.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * ip22-berr.c: Bus error handling.
  4. *
  5. * Copyright (C) 2002, 2003 Ladislav Michl ([email protected])
  6. */
  7. #include <linux/init.h>
  8. #include <linux/kernel.h>
  9. #include <linux/sched/signal.h>
  10. #include <asm/addrspace.h>
  11. #include <asm/traps.h>
  12. #include <asm/branch.h>
  13. #include <asm/irq_regs.h>
  14. #include <asm/sgi/mc.h>
  15. #include <asm/sgi/hpc3.h>
  16. #include <asm/sgi/ioc.h>
  17. #include <asm/sgi/ip22.h>
  18. static unsigned int cpu_err_stat; /* Status reg for CPU */
  19. static unsigned int gio_err_stat; /* Status reg for GIO */
  20. static unsigned int cpu_err_addr; /* Error address reg for CPU */
  21. static unsigned int gio_err_addr; /* Error address reg for GIO */
  22. static unsigned int extio_stat;
  23. static unsigned int hpc3_berr_stat; /* Bus error interrupt status */
  24. static void save_and_clear_buserr(void)
  25. {
  26. /* save status registers */
  27. cpu_err_addr = sgimc->cerr;
  28. cpu_err_stat = sgimc->cstat;
  29. gio_err_addr = sgimc->gerr;
  30. gio_err_stat = sgimc->gstat;
  31. extio_stat = ip22_is_fullhouse() ? sgioc->extio : (sgint->errstat << 4);
  32. hpc3_berr_stat = hpc3c0->bestat;
  33. sgimc->cstat = sgimc->gstat = 0;
  34. }
  35. #define GIO_ERRMASK 0xff00
  36. #define CPU_ERRMASK 0x3f00
  37. static void print_buserr(void)
  38. {
  39. if (extio_stat & EXTIO_MC_BUSERR)
  40. printk(KERN_ERR "MC Bus Error\n");
  41. if (extio_stat & EXTIO_HPC3_BUSERR)
  42. printk(KERN_ERR "HPC3 Bus Error 0x%x:<id=0x%x,%s,lane=0x%x>\n",
  43. hpc3_berr_stat,
  44. (hpc3_berr_stat & HPC3_BESTAT_PIDMASK) >>
  45. HPC3_BESTAT_PIDSHIFT,
  46. (hpc3_berr_stat & HPC3_BESTAT_CTYPE) ? "PIO" : "DMA",
  47. hpc3_berr_stat & HPC3_BESTAT_BLMASK);
  48. if (extio_stat & EXTIO_EISA_BUSERR)
  49. printk(KERN_ERR "EISA Bus Error\n");
  50. if (cpu_err_stat & CPU_ERRMASK)
  51. printk(KERN_ERR "CPU error 0x%x<%s%s%s%s%s%s> @ 0x%08x\n",
  52. cpu_err_stat,
  53. cpu_err_stat & SGIMC_CSTAT_RD ? "RD " : "",
  54. cpu_err_stat & SGIMC_CSTAT_PAR ? "PAR " : "",
  55. cpu_err_stat & SGIMC_CSTAT_ADDR ? "ADDR " : "",
  56. cpu_err_stat & SGIMC_CSTAT_SYSAD_PAR ? "SYSAD " : "",
  57. cpu_err_stat & SGIMC_CSTAT_SYSCMD_PAR ? "SYSCMD " : "",
  58. cpu_err_stat & SGIMC_CSTAT_BAD_DATA ? "BAD_DATA " : "",
  59. cpu_err_addr);
  60. if (gio_err_stat & GIO_ERRMASK)
  61. printk(KERN_ERR "GIO error 0x%x:<%s%s%s%s%s%s%s%s> @ 0x%08x\n",
  62. gio_err_stat,
  63. gio_err_stat & SGIMC_GSTAT_RD ? "RD " : "",
  64. gio_err_stat & SGIMC_GSTAT_WR ? "WR " : "",
  65. gio_err_stat & SGIMC_GSTAT_TIME ? "TIME " : "",
  66. gio_err_stat & SGIMC_GSTAT_PROM ? "PROM " : "",
  67. gio_err_stat & SGIMC_GSTAT_ADDR ? "ADDR " : "",
  68. gio_err_stat & SGIMC_GSTAT_BC ? "BC " : "",
  69. gio_err_stat & SGIMC_GSTAT_PIO_RD ? "PIO_RD " : "",
  70. gio_err_stat & SGIMC_GSTAT_PIO_WR ? "PIO_WR " : "",
  71. gio_err_addr);
  72. }
  73. /*
  74. * MC sends an interrupt whenever bus or parity errors occur. In addition,
  75. * if the error happened during a CPU read, it also asserts the bus error
  76. * pin on the R4K. Code in bus error handler save the MC bus error registers
  77. * and then clear the interrupt when this happens.
  78. */
  79. void ip22_be_interrupt(int irq)
  80. {
  81. const int field = 2 * sizeof(unsigned long);
  82. struct pt_regs *regs = get_irq_regs();
  83. save_and_clear_buserr();
  84. print_buserr();
  85. printk(KERN_ALERT "%s bus error, epc == %0*lx, ra == %0*lx\n",
  86. (regs->cp0_cause & 4) ? "Data" : "Instruction",
  87. field, regs->cp0_epc, field, regs->regs[31]);
  88. /* Assume it would be too dangerous to continue ... */
  89. die_if_kernel("Oops", regs);
  90. force_sig(SIGBUS);
  91. }
  92. static int ip22_be_handler(struct pt_regs *regs, int is_fixup)
  93. {
  94. save_and_clear_buserr();
  95. if (is_fixup)
  96. return MIPS_BE_FIXUP;
  97. print_buserr();
  98. return MIPS_BE_FATAL;
  99. }
  100. void __init ip22_be_init(void)
  101. {
  102. mips_set_be_handler(ip22_be_handler);
  103. }