huberror.c 5.8 KB

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