irqpanic.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * panic kernel with dump information
  3. *
  4. * Copyright 2005-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/kernel_stat.h>
  10. #include <linux/sched.h>
  11. #include <asm/blackfin.h>
  12. #define L1_ICACHE_START 0xffa10000
  13. #define L1_ICACHE_END 0xffa13fff
  14. /*
  15. * irq_panic - calls panic with string setup
  16. */
  17. __attribute__ ((l1_text))
  18. asmlinkage void irq_panic(int reason, struct pt_regs *regs)
  19. {
  20. unsigned int cmd, tag, ca, cache_hi, cache_lo, *pa;
  21. unsigned short i, j, die;
  22. unsigned int bad[10][6];
  23. /* check entire cache for coherency
  24. * Since printk is in cacheable memory,
  25. * don't call it until you have checked everything
  26. */
  27. die = 0;
  28. i = 0;
  29. /* check icache */
  30. for (ca = L1_ICACHE_START; ca <= L1_ICACHE_END && i < 10; ca += 32) {
  31. /* Grab various address bits for the itest_cmd fields */
  32. cmd = (((ca & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
  33. ((ca & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
  34. ((ca & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
  35. 0); /* Access Tag, Read access */
  36. SSYNC();
  37. bfin_write_ITEST_COMMAND(cmd);
  38. SSYNC();
  39. tag = bfin_read_ITEST_DATA0();
  40. SSYNC();
  41. /* if tag is marked as valid, check it */
  42. if (tag & 1) {
  43. /* The icache is arranged in 4 groups of 64-bits */
  44. for (j = 0; j < 32; j += 8) {
  45. cmd = ((((ca + j) & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
  46. (((ca + j) & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
  47. (((ca + j) & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
  48. 4); /* Access Data, Read access */
  49. SSYNC();
  50. bfin_write_ITEST_COMMAND(cmd);
  51. SSYNC();
  52. cache_hi = bfin_read_ITEST_DATA1();
  53. cache_lo = bfin_read_ITEST_DATA0();
  54. pa = ((unsigned int *)((tag & 0xffffcc00) |
  55. ((ca + j) & ~(0xffffcc00))));
  56. /*
  57. * Debugging this, enable
  58. *
  59. * printk("addr: %08x %08x%08x | %08x%08x\n",
  60. * ((unsigned int *)((tag & 0xffffcc00) | ((ca+j) & ~(0xffffcc00)))),
  61. * cache_hi, cache_lo, *(pa+1), *pa);
  62. */
  63. if (cache_hi != *(pa + 1) || cache_lo != *pa) {
  64. /* Since icache is not working, stay out of it, by not printing */
  65. die = 1;
  66. bad[i][0] = (ca + j);
  67. bad[i][1] = cache_hi;
  68. bad[i][2] = cache_lo;
  69. bad[i][3] = ((tag & 0xffffcc00) |
  70. ((ca + j) & ~(0xffffcc00)));
  71. bad[i][4] = *(pa + 1);
  72. bad[i][5] = *(pa);
  73. i++;
  74. }
  75. }
  76. }
  77. }
  78. if (die) {
  79. printk(KERN_EMERG "icache coherency error\n");
  80. for (j = 0; j <= i; j++) {
  81. printk(KERN_EMERG
  82. "cache address : %08x cache value : %08x%08x\n",
  83. bad[j][0], bad[j][1], bad[j][2]);
  84. printk(KERN_EMERG
  85. "physical address: %08x SDRAM value : %08x%08x\n",
  86. bad[j][3], bad[j][4], bad[j][5]);
  87. }
  88. panic("icache coherency error");
  89. } else
  90. printk(KERN_EMERG "icache checked, and OK\n");
  91. }