kn02xa-berr.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/irq_regs.h>
  21. #include <asm/ptrace.h>
  22. #include <asm/traps.h>
  23. #include <asm/dec/kn02ca.h>
  24. #include <asm/dec/kn02xa.h>
  25. #include <asm/dec/kn05.h>
  26. static inline void dec_kn02xa_be_ack(void)
  27. {
  28. volatile u32 *mer = (void *)CKSEG1ADDR(KN02XA_MER);
  29. volatile u32 *mem_intr = (void *)CKSEG1ADDR(KN02XA_MEM_INTR);
  30. *mer = KN02CA_MER_INTR; /* Clear errors; keep the ARC IRQ. */
  31. *mem_intr = 0; /* Any write clears the bus IRQ. */
  32. iob();
  33. }
  34. static int dec_kn02xa_be_backend(struct pt_regs *regs, int is_fixup,
  35. int invoker)
  36. {
  37. volatile u32 *kn02xa_mer = (void *)CKSEG1ADDR(KN02XA_MER);
  38. volatile u32 *kn02xa_ear = (void *)CKSEG1ADDR(KN02XA_EAR);
  39. static const char excstr[] = "exception";
  40. static const char intstr[] = "interrupt";
  41. static const char cpustr[] = "CPU";
  42. static const char mreadstr[] = "memory read";
  43. static const char readstr[] = "read";
  44. static const char writestr[] = "write";
  45. static const char timestr[] = "timeout";
  46. static const char paritystr[] = "parity error";
  47. static const char lanestat[][4] = { " OK", "BAD" };
  48. const char *kind, *agent, *cycle, *event;
  49. unsigned long address;
  50. u32 mer = *kn02xa_mer;
  51. u32 ear = *kn02xa_ear;
  52. int action = MIPS_BE_FATAL;
  53. /* Ack ASAP, so that any subsequent errors get caught. */
  54. dec_kn02xa_be_ack();
  55. kind = invoker ? intstr : excstr;
  56. /* No DMA errors? */
  57. agent = cpustr;
  58. address = ear & KN02XA_EAR_ADDRESS;
  59. /* Low 256MB is decoded as memory, high -- as TC. */
  60. if (address < 0x10000000) {
  61. cycle = mreadstr;
  62. event = paritystr;
  63. } else {
  64. cycle = invoker ? writestr : readstr;
  65. event = timestr;
  66. }
  67. if (is_fixup)
  68. action = MIPS_BE_FIXUP;
  69. if (action != MIPS_BE_FIXUP)
  70. printk(KERN_ALERT "Bus error %s: %s %s %s at %#010lx\n",
  71. kind, agent, cycle, event, address);
  72. if (action != MIPS_BE_FIXUP && address < 0x10000000)
  73. printk(KERN_ALERT " Byte lane status %#3x -- "
  74. "#3: %s, #2: %s, #1: %s, #0: %s\n",
  75. (mer & KN02XA_MER_BYTERR) >> 8,
  76. lanestat[(mer & KN02XA_MER_BYTERR_3) != 0],
  77. lanestat[(mer & KN02XA_MER_BYTERR_2) != 0],
  78. lanestat[(mer & KN02XA_MER_BYTERR_1) != 0],
  79. lanestat[(mer & KN02XA_MER_BYTERR_0) != 0]);
  80. return action;
  81. }
  82. int dec_kn02xa_be_handler(struct pt_regs *regs, int is_fixup)
  83. {
  84. return dec_kn02xa_be_backend(regs, is_fixup, 0);
  85. }
  86. irqreturn_t dec_kn02xa_be_interrupt(int irq, void *dev_id)
  87. {
  88. struct pt_regs *regs = get_irq_regs();
  89. int action = dec_kn02xa_be_backend(regs, 0, 1);
  90. if (action == MIPS_BE_DISCARD)
  91. return IRQ_HANDLED;
  92. /*
  93. * FIXME: Find the affected processes and kill them, otherwise
  94. * we must die.
  95. *
  96. * The interrupt is asynchronously delivered thus EPC and RA
  97. * may be irrelevant, but are printed for a reference.
  98. */
  99. printk(KERN_ALERT "Fatal bus interrupt, epc == %08lx, ra == %08lx\n",
  100. regs->cp0_epc, regs->regs[31]);
  101. die("Unrecoverable bus error", regs);
  102. }
  103. void __init dec_kn02xa_be_init(void)
  104. {
  105. volatile u32 *mbcs = (void *)CKSEG1ADDR(KN4K_SLOT_BASE + KN4K_MB_CSR);
  106. /* For KN04 we need to make sure EE (?) is enabled in the MB. */
  107. if (current_cpu_type() == CPU_R4000SC)
  108. *mbcs |= KN4K_MB_CSR_EE;
  109. fast_iob();
  110. /* Clear any leftover errors from the firmware. */
  111. dec_kn02xa_be_ack();
  112. }