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
6 * Copyright (C) 1992 - 1997, 2000,2002-2007 Silicon Graphics, Inc. All rights reserved.
9 #include <linux/types.h>
10 #include <linux/interrupt.h>
11 #include <asm/delay.h>
12 #include <asm/sn/sn_sal.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>
21 void hubiio_crb_error_handler(struct hubdev_info
*hubdev_info
);
22 extern void bte_crb_error_handler(cnodeid_t
, int, int, ioerror_t
*,
24 static irqreturn_t
hub_eint_handler(int irq
, void *arg
)
26 struct hubdev_info
*hubdev_info
;
27 struct ia64_sal_retval ret_stuff
;
32 hubdev_info
= (struct hubdev_info
*)arg
;
33 nasid
= hubdev_info
->hdi_nasid
;
36 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_HUB_ERROR_INTERRUPT
,
37 (u64
) nasid
, 0, 0, 0, 0, 0, 0);
39 if ((int)ret_stuff
.v0
)
40 panic("%s: Fatal %s Error", __func__
,
41 ((nasid
& 1) ? "TIO" : "HUBII"));
43 if (!(nasid
& 1)) /* Not a TIO, handle CRB errors */
44 (void)hubiio_crb_error_handler(hubdev_info
);
46 if (nasid
& 1) { /* TIO errors */
47 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_HUB_ERROR_INTERRUPT
,
48 (u64
) nasid
, 0, 0, 0, 0, 0, 0);
50 if ((int)ret_stuff
.v0
)
51 panic("%s: Fatal TIO Error", __func__
);
53 bte_error_handler((unsigned long)NODEPDA(nasid_to_cnodeid(nasid
)));
59 * Free the hub CRB "crbnum" which encountered an error.
60 * Assumption is, error handling was successfully done,
61 * and we now want to return the CRB back to Hub for normal usage.
63 * In order to free the CRB, all that's needed is to de-allocate it
66 * No other processor is mucking around with the hub control register.
67 * So, upper layer has to single thread this.
69 void hubiio_crb_free(struct hubdev_info
*hubdev_info
, int crbnum
)
74 * The hardware does NOT clear the mark bit, so it must get cleared
75 * here to be sure the error is not processed twice.
77 icrbb
.ii_icrb0_b_regval
= REMOTE_HUB_L(hubdev_info
->hdi_nasid
,
80 REMOTE_HUB_S(hubdev_info
->hdi_nasid
, IIO_ICRB_B(crbnum
),
81 icrbb
.ii_icrb0_b_regval
);
83 * Deallocate the register wait till hub indicates it's done.
85 REMOTE_HUB_S(hubdev_info
->hdi_nasid
, IIO_ICDR
, (IIO_ICDR_PND
| crbnum
));
86 while (REMOTE_HUB_L(hubdev_info
->hdi_nasid
, IIO_ICDR
) & IIO_ICDR_PND
)
92 void hubiio_crb_error_handler(struct hubdev_info
*hubdev_info
)
95 ii_icrb0_a_u_t icrba
; /* II CRB Register A */
96 ii_icrb0_b_u_t icrbb
; /* II CRB Register B */
97 ii_icrb0_c_u_t icrbc
; /* II CRB Register C */
98 ii_icrb0_d_u_t icrbd
; /* II CRB Register D */
99 ii_icrb0_e_u_t icrbe
; /* II CRB Register D */
101 int num_errors
= 0; /* Num of errors handled */
104 nasid
= hubdev_info
->hdi_nasid
;
107 * Scan through all CRBs in the Hub, and handle the errors
108 * in any of the CRBs marked.
110 for (i
= 0; i
< IIO_NUM_CRBS
; i
++) {
111 /* Check this crb entry to see if it is in error. */
112 icrbb
.ii_icrb0_b_regval
= REMOTE_HUB_L(nasid
, IIO_ICRB_B(i
));
114 if (icrbb
.b_mark
== 0) {
118 icrba
.ii_icrb0_a_regval
= REMOTE_HUB_L(nasid
, IIO_ICRB_A(i
));
120 IOERROR_INIT(&ioerror
);
122 /* read other CRB error registers. */
123 icrbc
.ii_icrb0_c_regval
= REMOTE_HUB_L(nasid
, IIO_ICRB_C(i
));
124 icrbd
.ii_icrb0_d_regval
= REMOTE_HUB_L(nasid
, IIO_ICRB_D(i
));
125 icrbe
.ii_icrb0_e_regval
= REMOTE_HUB_L(nasid
, IIO_ICRB_E(i
));
127 IOERROR_SETVALUE(&ioerror
, errortype
, icrbb
.b_ecode
);
129 /* Check if this error is due to BTE operation,
130 * and handle it separately.
133 ((icrbb
.b_initiator
== IIO_ICRB_INIT_BTE0
||
134 icrbb
.b_initiator
== IIO_ICRB_INIT_BTE1
) &&
135 (icrbb
.b_imsgtype
== IIO_ICRB_IMSGT_BTE
||
136 icrbb
.b_imsgtype
== IIO_ICRB_IMSGT_SN1NET
))) {
141 bte_num
= icrbc
.c_btenum
;
142 else /* b_initiator bit 2 gives BTE number */
143 bte_num
= (icrbb
.b_initiator
& 0x4) >> 2;
145 hubiio_crb_free(hubdev_info
, i
);
147 bte_crb_error_handler(nasid_to_cnodeid(nasid
), bte_num
,
148 i
, &ioerror
, icrbd
.d_bteop
);
156 * Function : hub_error_init
157 * Purpose : initialize the error handling requirements for a given hub.
158 * Parameters : cnode, the compact nodeid.
159 * Assumptions : Called only once per hub, either by a local cpu. Or by a
160 * remote cpu, when this hub is headless.(cpuless)
163 void hub_error_init(struct hubdev_info
*hubdev_info
)
166 if (request_irq(SGI_II_ERROR
, hub_eint_handler
, IRQF_SHARED
,
167 "SN_hub_error", hubdev_info
)) {
168 printk(KERN_ERR
"hub_error_init: Failed to request_irq for 0x%p\n",
172 sn_set_err_irq_affinity(SGI_II_ERROR
);
177 * Function : ice_error_init
178 * Purpose : initialize the error handling requirements for a given tio.
179 * Parameters : cnode, the compact nodeid.
180 * Assumptions : Called only once per tio.
183 void ice_error_init(struct hubdev_info
*hubdev_info
)
187 (SGI_TIO_ERROR
, (void *)hub_eint_handler
, IRQF_SHARED
, "SN_TIO_error",
188 (void *)hubdev_info
)) {
189 printk("ice_error_init: request_irq() error hubdev_info 0x%p\n",
193 sn_set_err_irq_affinity(SGI_TIO_ERROR
);