irqpanic.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * File: arch/blackfin/mach-common/irqpanic.c
  3. * Based on:
  4. * Author:
  5. *
  6. * Created: ?
  7. * Description: panic kernel with dump information
  8. *
  9. * Modified: rgetz - added cache checking code 14Feb06
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/module.h>
  30. #include <linux/kernel_stat.h>
  31. #include <linux/sched.h>
  32. #include <asm/traps.h>
  33. #include <asm/blackfin.h>
  34. #include "../oprofile/op_blackfin.h"
  35. #ifdef CONFIG_DEBUG_ICACHE_CHECK
  36. #define L1_ICACHE_START 0xffa10000
  37. #define L1_ICACHE_END 0xffa13fff
  38. void irq_panic(int reason, struct pt_regs *regs) __attribute__ ((l1_text));
  39. #endif
  40. /*
  41. * irq_panic - calls panic with string setup
  42. */
  43. asmlinkage void irq_panic(int reason, struct pt_regs *regs)
  44. {
  45. int sig = 0;
  46. siginfo_t info;
  47. #ifdef CONFIG_DEBUG_ICACHE_CHECK
  48. unsigned int cmd, tag, ca, cache_hi, cache_lo, *pa;
  49. unsigned short i, j, die;
  50. unsigned int bad[10][6];
  51. /* check entire cache for coherency
  52. * Since printk is in cacheable memory,
  53. * don't call it until you have checked everything
  54. */
  55. die = 0;
  56. i = 0;
  57. /* check icache */
  58. for (ca = L1_ICACHE_START; ca <= L1_ICACHE_END && i < 10; ca += 32) {
  59. /* Grab various address bits for the itest_cmd fields */
  60. cmd = (((ca & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
  61. ((ca & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
  62. ((ca & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
  63. 0); /* Access Tag, Read access */
  64. SSYNC();
  65. bfin_write_ITEST_COMMAND(cmd);
  66. SSYNC();
  67. tag = bfin_read_ITEST_DATA0();
  68. SSYNC();
  69. /* if tag is marked as valid, check it */
  70. if (tag & 1) {
  71. /* The icache is arranged in 4 groups of 64-bits */
  72. for (j = 0; j < 32; j += 8) {
  73. cmd = ((((ca + j) & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
  74. (((ca + j) & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
  75. (((ca + j) & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
  76. 4); /* Access Data, Read access */
  77. SSYNC();
  78. bfin_write_ITEST_COMMAND(cmd);
  79. SSYNC();
  80. cache_hi = bfin_read_ITEST_DATA1();
  81. cache_lo = bfin_read_ITEST_DATA0();
  82. pa = ((unsigned int *)((tag & 0xffffcc00) |
  83. ((ca + j) & ~(0xffffcc00))));
  84. /*
  85. * Debugging this, enable
  86. *
  87. * printk("addr: %08x %08x%08x | %08x%08x\n",
  88. * ((unsigned int *)((tag & 0xffffcc00) | ((ca+j) & ~(0xffffcc00)))),
  89. * cache_hi, cache_lo, *(pa+1), *pa);
  90. */
  91. if (cache_hi != *(pa + 1) || cache_lo != *pa) {
  92. /* Since icache is not working, stay out of it, by not printing */
  93. die = 1;
  94. bad[i][0] = (ca + j);
  95. bad[i][1] = cache_hi;
  96. bad[i][2] = cache_lo;
  97. bad[i][3] = ((tag & 0xffffcc00) |
  98. ((ca + j) & ~(0xffffcc00)));
  99. bad[i][4] = *(pa + 1);
  100. bad[i][5] = *(pa);
  101. i++;
  102. }
  103. }
  104. }
  105. }
  106. if (die) {
  107. printk(KERN_EMERG "icache coherency error\n");
  108. for (j = 0; j <= i; j++) {
  109. printk(KERN_EMERG
  110. "cache address : %08x cache value : %08x%08x\n",
  111. bad[j][0], bad[j][1], bad[j][2]);
  112. printk(KERN_EMERG
  113. "physical address: %08x SDRAM value : %08x%08x\n",
  114. bad[j][3], bad[j][4], bad[j][5]);
  115. }
  116. panic("icache coherency error");
  117. } else {
  118. printk(KERN_EMERG "icache checked, and OK\n");
  119. }
  120. #endif
  121. printk(KERN_EMERG "\n");
  122. printk(KERN_EMERG "Exception: IRQ 0x%x entered\n", reason);
  123. printk(KERN_EMERG " code=[0x%08lx], stack frame=0x%08lx, "
  124. " bad PC=0x%08lx\n",
  125. (unsigned long)regs->seqstat,
  126. (unsigned long)regs,
  127. (unsigned long)regs->pc);
  128. if (reason == 0x5) {
  129. printk(KERN_EMERG "----------- HARDWARE ERROR -----------\n");
  130. /* There is only need to check for Hardware Errors, since other
  131. * EXCEPTIONS are handled in TRAPS.c (MH)
  132. */
  133. switch (regs->seqstat & SEQSTAT_HWERRCAUSE) {
  134. case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR): /* System MMR Error */
  135. info.si_code = BUS_ADRALN;
  136. sig = SIGBUS;
  137. printk(KERN_EMERG HWC_x2(KERN_EMERG));
  138. break;
  139. case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR): /* External Memory Addressing Error */
  140. info.si_code = BUS_ADRERR;
  141. sig = SIGBUS;
  142. printk(KERN_EMERG HWC_x3(KERN_EMERG));
  143. break;
  144. case (SEQSTAT_HWERRCAUSE_PERF_FLOW): /* Performance Monitor Overflow */
  145. printk(KERN_EMERG HWC_x12(KERN_EMERG));
  146. break;
  147. case (SEQSTAT_HWERRCAUSE_RAISE_5): /* RAISE 5 instruction */
  148. printk(KERN_EMERG HWC_x18(KERN_EMERG));
  149. break;
  150. default: /* Reserved */
  151. printk(KERN_EMERG HWC_default(KERN_EMERG));
  152. break;
  153. }
  154. }
  155. regs->ipend = bfin_read_IPEND();
  156. dump_bfin_process(regs);
  157. dump_bfin_mem((void *)regs->pc);
  158. show_regs(regs);
  159. if (0 == (info.si_signo = sig) || 0 == user_mode(regs)) /* in kernelspace */
  160. panic("Unhandled IRQ or exceptions!\n");
  161. else { /* in userspace */
  162. info.si_errno = 0;
  163. info.si_addr = (void *)regs->pc;
  164. force_sig_info(sig, &info, current);
  165. }
  166. }
  167. #ifdef CONFIG_HARDWARE_PM
  168. /*
  169. * call the handler of Performance overflow
  170. */
  171. asmlinkage void pm_overflow(int irq, struct pt_regs *regs)
  172. {
  173. pm_overflow_handler(irq, regs);
  174. }
  175. #endif