ip22-berr.c 3.5 KB

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