kn02xa-berr.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Bus error event handling code for 5000-series systems equipped
  3. * with parity error detection logic, i.e. DECstation/DECsystem
  4. * 5000/120, /125, /133 (KN02-BA), 5000/150 (KN04-BA) and Personal
  5. * DECstation/DECsystem 5000/20, /25, /33 (KN02-CA), 5000/50
  6. * (KN04-CA) systems.
  7. *
  8. * Copyright (c) 2005 Maciej W. Rozycki
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/kernel.h>
  18. #include <linux/types.h>
  19. #include <asm/addrspace.h>
  20. #include <asm/cpu-type.h>
  21. #include <asm/irq_regs.h>
  22. #include <asm/ptrace.h>
  23. #include <asm/traps.h>
  24. #include <asm/dec/kn02ca.h>
  25. #include <asm/dec/kn02xa.h>
  26. #include <asm/dec/kn05.h>
  27. static inline void dec_kn02xa_be_ack(void)
  28. {
  29. volatile u32 *mer = (void *)CKSEG1ADDR(KN02XA_MER);
  30. volatile u32 *mem_intr = (void *)CKSEG1ADDR(KN02XA_MEM_INTR);
  31. *mer = KN02CA_MER_INTR; /* Clear errors; keep the ARC IRQ. */
  32. *mem_intr = 0; /* Any write clears the bus IRQ. */
  33. iob();
  34. }
  35. static int dec_kn02xa_be_backend(struct pt_regs *regs, int is_fixup,
  36. int invoker)
  37. {
  38. volatile u32 *kn02xa_mer = (void *)CKSEG1ADDR(KN02XA_MER);
  39. volatile u32 *kn02xa_ear = (void *)CKSEG1ADDR(KN02XA_EAR);
  40. static const char excstr[] = "exception";
  41. static const char intstr[] = "interrupt";
  42. static const char cpustr[] = "CPU";
  43. static const char mreadstr[] = "memory read";
  44. static const char readstr[] = "read";
  45. static const char writestr[] = "write";
  46. static const char timestr[] = "timeout";
  47. static const char paritystr[] = "parity error";
  48. static const char lanestat[][4] = { " OK", "BAD" };
  49. const char *kind, *agent, *cycle, *event;
  50. unsigned long address;
  51. u32 mer = *kn02xa_mer;
  52. u32 ear = *kn02xa_ear;
  53. int action = MIPS_BE_FATAL;
  54. /* Ack ASAP, so that any subsequent errors get caught. */
  55. dec_kn02xa_be_ack();
  56. kind = invoker ? intstr : excstr;
  57. /* No DMA errors? */
  58. agent = cpustr;
  59. address = ear & KN02XA_EAR_ADDRESS;
  60. /* Low 256MB is decoded as memory, high -- as TC. */
  61. if (address < 0x10000000) {
  62. cycle = mreadstr;
  63. event = paritystr;
  64. } else {
  65. cycle = invoker ? writestr : readstr;
  66. event = timestr;
  67. }
  68. if (is_fixup)
  69. action = MIPS_BE_FIXUP;
  70. if (action != MIPS_BE_FIXUP)
  71. printk(KERN_ALERT "Bus error %s: %s %s %s at %#010lx\n",
  72. kind, agent, cycle, event, address);
  73. if (action != MIPS_BE_FIXUP && address < 0x10000000)
  74. printk(KERN_ALERT " Byte lane status %#3x -- "
  75. "#3: %s, #2: %s, #1: %s, #0: %s\n",
  76. (mer & KN02XA_MER_BYTERR) >> 8,
  77. lanestat[(mer & KN02XA_MER_BYTERR_3) != 0],
  78. lanestat[(mer & KN02XA_MER_BYTERR_2) != 0],
  79. lanestat[(mer & KN02XA_MER_BYTERR_1) != 0],
  80. lanestat[(mer & KN02XA_MER_BYTERR_0) != 0]);
  81. return action;
  82. }
  83. int dec_kn02xa_be_handler(struct pt_regs *regs, int is_fixup)
  84. {
  85. return dec_kn02xa_be_backend(regs, is_fixup, 0);
  86. }
  87. irqreturn_t dec_kn02xa_be_interrupt(int irq, void *dev_id)
  88. {
  89. struct pt_regs *regs = get_irq_regs();
  90. int action = dec_kn02xa_be_backend(regs, 0, 1);
  91. if (action == MIPS_BE_DISCARD)
  92. return IRQ_HANDLED;
  93. /*
  94. * FIXME: Find the affected processes and kill them, otherwise
  95. * we must die.
  96. *
  97. * The interrupt is asynchronously delivered thus EPC and RA
  98. * may be irrelevant, but are printed for a reference.
  99. */
  100. printk(KERN_ALERT "Fatal bus interrupt, epc == %08lx, ra == %08lx\n",
  101. regs->cp0_epc, regs->regs[31]);
  102. die("Unrecoverable bus error", regs);
  103. }
  104. void __init dec_kn02xa_be_init(void)
  105. {
  106. volatile u32 *mbcs = (void *)CKSEG1ADDR(KN4K_SLOT_BASE + KN4K_MB_CSR);
  107. /* For KN04 we need to make sure EE (?) is enabled in the MB. */
  108. if (current_cpu_type() == CPU_R4000SC)
  109. *mbcs |= KN4K_MB_CSR_EE;
  110. fast_iob();
  111. /* Clear any leftover errors from the firmware. */
  112. dec_kn02xa_be_ack();
  113. }