huberror.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1992 - 1997, 2000,2002-2005 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #include <linux/types.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/pci.h>
  11. #include <asm/delay.h>
  12. #include <asm/sn/sn_sal.h>
  13. #include "ioerror.h"
  14. #include <asm/sn/addrs.h>
  15. #include <asm/sn/shubio.h>
  16. #include <asm/sn/geo.h>
  17. #include "xtalk/xwidgetdev.h"
  18. #include "xtalk/hubdev.h"
  19. #include <asm/sn/bte.h>
  20. void hubiio_crb_error_handler(struct hubdev_info *hubdev_info);
  21. extern void bte_crb_error_handler(cnodeid_t, int, int, ioerror_t *,
  22. int);
  23. static irqreturn_t hub_eint_handler(int irq, void *arg, struct pt_regs *ep)
  24. {
  25. struct hubdev_info *hubdev_info;
  26. struct ia64_sal_retval ret_stuff;
  27. nasid_t nasid;
  28. ret_stuff.status = 0;
  29. ret_stuff.v0 = 0;
  30. hubdev_info = (struct hubdev_info *)arg;
  31. nasid = hubdev_info->hdi_nasid;
  32. if (is_shub1()) {
  33. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_HUB_ERROR_INTERRUPT,
  34. (u64) nasid, 0, 0, 0, 0, 0, 0);
  35. if ((int)ret_stuff.v0)
  36. panic("hubii_eint_handler(): Fatal TIO Error");
  37. if (!(nasid & 1)) /* Not a TIO, handle CRB errors */
  38. (void)hubiio_crb_error_handler(hubdev_info);
  39. } else
  40. bte_error_handler((unsigned long)NODEPDA(nasid_to_cnodeid(nasid)));
  41. return IRQ_HANDLED;
  42. }
  43. /*
  44. * Free the hub CRB "crbnum" which encountered an error.
  45. * Assumption is, error handling was successfully done,
  46. * and we now want to return the CRB back to Hub for normal usage.
  47. *
  48. * In order to free the CRB, all that's needed is to de-allocate it
  49. *
  50. * Assumption:
  51. * No other processor is mucking around with the hub control register.
  52. * So, upper layer has to single thread this.
  53. */
  54. void hubiio_crb_free(struct hubdev_info *hubdev_info, int crbnum)
  55. {
  56. ii_icrb0_b_u_t icrbb;
  57. /*
  58. * The hardware does NOT clear the mark bit, so it must get cleared
  59. * here to be sure the error is not processed twice.
  60. */
  61. icrbb.ii_icrb0_b_regval = REMOTE_HUB_L(hubdev_info->hdi_nasid,
  62. IIO_ICRB_B(crbnum));
  63. icrbb.b_mark = 0;
  64. REMOTE_HUB_S(hubdev_info->hdi_nasid, IIO_ICRB_B(crbnum),
  65. icrbb.ii_icrb0_b_regval);
  66. /*
  67. * Deallocate the register wait till hub indicates it's done.
  68. */
  69. REMOTE_HUB_S(hubdev_info->hdi_nasid, IIO_ICDR, (IIO_ICDR_PND | crbnum));
  70. while (REMOTE_HUB_L(hubdev_info->hdi_nasid, IIO_ICDR) & IIO_ICDR_PND)
  71. cpu_relax();
  72. }
  73. /*
  74. * hubiio_crb_error_handler
  75. *
  76. * This routine gets invoked when a hub gets an error
  77. * interrupt. So, the routine is running in interrupt context
  78. * at error interrupt level.
  79. * Action:
  80. * It's responsible for identifying ALL the CRBs that are marked
  81. * with error, and process them.
  82. *
  83. * If you find the CRB that's marked with error, map this to the
  84. * reason it caused error, and invoke appropriate error handler.
  85. *
  86. * XXX Be aware of the information in the context register.
  87. *
  88. * NOTE:
  89. * Use REMOTE_HUB_* macro instead of LOCAL_HUB_* so that the interrupt
  90. * handler can be run on any node. (not necessarily the node
  91. * corresponding to the hub that encountered error).
  92. */
  93. void hubiio_crb_error_handler(struct hubdev_info *hubdev_info)
  94. {
  95. nasid_t nasid;
  96. ii_icrb0_a_u_t icrba; /* II CRB Register A */
  97. ii_icrb0_b_u_t icrbb; /* II CRB Register B */
  98. ii_icrb0_c_u_t icrbc; /* II CRB Register C */
  99. ii_icrb0_d_u_t icrbd; /* II CRB Register D */
  100. ii_icrb0_e_u_t icrbe; /* II CRB Register D */
  101. int i;
  102. int num_errors = 0; /* Num of errors handled */
  103. ioerror_t ioerror;
  104. nasid = hubdev_info->hdi_nasid;
  105. /*
  106. * XXX - Add locking for any recovery actions
  107. */
  108. /*
  109. * Scan through all CRBs in the Hub, and handle the errors
  110. * in any of the CRBs marked.
  111. */
  112. for (i = 0; i < IIO_NUM_CRBS; i++) {
  113. /* Check this crb entry to see if it is in error. */
  114. icrbb.ii_icrb0_b_regval = REMOTE_HUB_L(nasid, IIO_ICRB_B(i));
  115. if (icrbb.b_mark == 0) {
  116. continue;
  117. }
  118. icrba.ii_icrb0_a_regval = REMOTE_HUB_L(nasid, IIO_ICRB_A(i));
  119. IOERROR_INIT(&ioerror);
  120. /* read other CRB error registers. */
  121. icrbc.ii_icrb0_c_regval = REMOTE_HUB_L(nasid, IIO_ICRB_C(i));
  122. icrbd.ii_icrb0_d_regval = REMOTE_HUB_L(nasid, IIO_ICRB_D(i));
  123. icrbe.ii_icrb0_e_regval = REMOTE_HUB_L(nasid, IIO_ICRB_E(i));
  124. IOERROR_SETVALUE(&ioerror, errortype, icrbb.b_ecode);
  125. /* Check if this error is due to BTE operation,
  126. * and handle it separately.
  127. */
  128. if (icrbd.d_bteop ||
  129. ((icrbb.b_initiator == IIO_ICRB_INIT_BTE0 ||
  130. icrbb.b_initiator == IIO_ICRB_INIT_BTE1) &&
  131. (icrbb.b_imsgtype == IIO_ICRB_IMSGT_BTE ||
  132. icrbb.b_imsgtype == IIO_ICRB_IMSGT_SN1NET))) {
  133. int bte_num;
  134. if (icrbd.d_bteop)
  135. bte_num = icrbc.c_btenum;
  136. else /* b_initiator bit 2 gives BTE number */
  137. bte_num = (icrbb.b_initiator & 0x4) >> 2;
  138. hubiio_crb_free(hubdev_info, i);
  139. bte_crb_error_handler(nasid_to_cnodeid(nasid), bte_num,
  140. i, &ioerror, icrbd.d_bteop);
  141. num_errors++;
  142. continue;
  143. }
  144. }
  145. }
  146. /*
  147. * Function : hub_error_init
  148. * Purpose : initialize the error handling requirements for a given hub.
  149. * Parameters : cnode, the compact nodeid.
  150. * Assumptions : Called only once per hub, either by a local cpu. Or by a
  151. * remote cpu, when this hub is headless.(cpuless)
  152. * Returns : None
  153. */
  154. void hub_error_init(struct hubdev_info *hubdev_info)
  155. {
  156. if (request_irq(SGI_II_ERROR, (void *)hub_eint_handler, SA_SHIRQ,
  157. "SN_hub_error", (void *)hubdev_info))
  158. printk("hub_error_init: Failed to request_irq for 0x%p\n",
  159. hubdev_info);
  160. return;
  161. }
  162. /*
  163. * Function : ice_error_init
  164. * Purpose : initialize the error handling requirements for a given tio.
  165. * Parameters : cnode, the compact nodeid.
  166. * Assumptions : Called only once per tio.
  167. * Returns : None
  168. */
  169. void ice_error_init(struct hubdev_info *hubdev_info)
  170. {
  171. if (request_irq
  172. (SGI_TIO_ERROR, (void *)hub_eint_handler, SA_SHIRQ, "SN_TIO_error",
  173. (void *)hubdev_info))
  174. printk("ice_error_init: request_irq() error hubdev_info 0x%p\n",
  175. hubdev_info);
  176. return;
  177. }