irqpanic.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #ifdef CONFIG_DEBUG_ICACHE_CHECK
  46. unsigned int cmd, tag, ca, cache_hi, cache_lo, *pa;
  47. unsigned short i, j, die;
  48. unsigned int bad[10][6];
  49. /* check entire cache for coherency
  50. * Since printk is in cacheable memory,
  51. * don't call it until you have checked everything
  52. */
  53. die = 0;
  54. i = 0;
  55. /* check icache */
  56. for (ca = L1_ICACHE_START; ca <= L1_ICACHE_END && i < 10; ca += 32) {
  57. /* Grab various address bits for the itest_cmd fields */
  58. cmd = (((ca & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
  59. ((ca & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
  60. ((ca & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
  61. 0); /* Access Tag, Read access */
  62. SSYNC();
  63. bfin_write_ITEST_COMMAND(cmd);
  64. SSYNC();
  65. tag = bfin_read_ITEST_DATA0();
  66. SSYNC();
  67. /* if tag is marked as valid, check it */
  68. if (tag & 1) {
  69. /* The icache is arranged in 4 groups of 64-bits */
  70. for (j = 0; j < 32; j += 8) {
  71. cmd = ((((ca + j) & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
  72. (((ca + j) & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
  73. (((ca + j) & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
  74. 4); /* Access Data, Read access */
  75. SSYNC();
  76. bfin_write_ITEST_COMMAND(cmd);
  77. SSYNC();
  78. cache_hi = bfin_read_ITEST_DATA1();
  79. cache_lo = bfin_read_ITEST_DATA0();
  80. pa = ((unsigned int *)((tag & 0xffffcc00) |
  81. ((ca + j) & ~(0xffffcc00))));
  82. /*
  83. * Debugging this, enable
  84. *
  85. * printk("addr: %08x %08x%08x | %08x%08x\n",
  86. * ((unsigned int *)((tag & 0xffffcc00) | ((ca+j) & ~(0xffffcc00)))),
  87. * cache_hi, cache_lo, *(pa+1), *pa);
  88. */
  89. if (cache_hi != *(pa + 1) || cache_lo != *pa) {
  90. /* Since icache is not working, stay out of it, by not printing */
  91. die = 1;
  92. bad[i][0] = (ca + j);
  93. bad[i][1] = cache_hi;
  94. bad[i][2] = cache_lo;
  95. bad[i][3] = ((tag & 0xffffcc00) |
  96. ((ca + j) & ~(0xffffcc00)));
  97. bad[i][4] = *(pa + 1);
  98. bad[i][5] = *(pa);
  99. i++;
  100. }
  101. }
  102. }
  103. }
  104. if (die) {
  105. printk(KERN_EMERG "icache coherency error\n");
  106. for (j = 0; j <= i; j++) {
  107. printk(KERN_EMERG
  108. "cache address : %08x cache value : %08x%08x\n",
  109. bad[j][0], bad[j][1], bad[j][2]);
  110. printk(KERN_EMERG
  111. "physical address: %08x SDRAM value : %08x%08x\n",
  112. bad[j][3], bad[j][4], bad[j][5]);
  113. }
  114. panic("icache coherency error");
  115. } else {
  116. printk(KERN_EMERG "icache checked, and OK\n");
  117. }
  118. #endif
  119. }
  120. #ifdef CONFIG_HARDWARE_PM
  121. /*
  122. * call the handler of Performance overflow
  123. */
  124. asmlinkage void pm_overflow(int irq, struct pt_regs *regs)
  125. {
  126. pm_overflow_handler(irq, regs);
  127. }
  128. #endif