kn02xa-berr.c 3.9 KB

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