3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
7 * Copyright (C) 2001-2003 Silicon Graphics, Inc. All rights reserved.
10 #include <linux/types.h>
11 #include <linux/slab.h>
12 #include <linux/module.h>
13 #include <asm/sn/sgi.h>
14 #include <asm/sn/sn_cpuid.h>
15 #include <asm/sn/addrs.h>
16 #include <asm/sn/arch.h>
17 #include <asm/sn/iograph.h>
18 #include <asm/sn/invent.h>
19 #include <asm/sn/hcl.h>
20 #include <asm/sn/labelcl.h>
21 #include <asm/sn/xtalk/xwidget.h>
22 #include <asm/sn/pci/bridge.h>
23 #include <asm/sn/pci/pciio.h>
24 #include <asm/sn/pci/pcibr.h>
25 #include <asm/sn/pci/pcibr_private.h>
26 #include <asm/sn/pci/pci_defs.h>
27 #include <asm/sn/prio.h>
28 #include <asm/sn/xtalk/xbow.h>
29 #include <asm/sn/ioc3.h>
30 #include <asm/sn/io.h>
31 #include <asm/sn/sn_private.h>
33 extern int hubii_check_widget_disabled(nasid_t
, int);
36 /* =====================================================================
42 #define BRIDGE_PIOERR_TIMEOUT 100 /* Timeout with ERROR_DEBUG defined */
44 #define BRIDGE_PIOERR_TIMEOUT 40 /* Timeout in debug mode */
47 #define BRIDGE_PIOERR_TIMEOUT 1 /* Timeout in non-debug mode */
50 /* PIC has 64bit interrupt error registers, but BRIDGE has 32bit registers.
51 * Thus 'bridge_errors_to_dump needs' to default to the larger of the two.
55 uint64_t bridge_errors_to_dump
= ~BRIDGE_ISR_INT_MSK
;
57 uint64_t bridge_errors_to_dump
= BRIDGE_ISR_ERROR_DUMP
;
60 uint64_t bridge_errors_to_dump
= BRIDGE_ISR_ERROR_FATAL
|
61 BRIDGE_ISR_PCIBUS_PIOERR
;
64 int pcibr_llp_control_war_cnt
; /* PCIBR_LLP_CONTROL_WAR */
66 static struct reg_values xio_cmd_pactyp
[] =
70 {0x2, "WrReqWithResp"},
87 static struct reg_desc xio_cmd_bits
[] =
89 {WIDGET_DIDN
, -28, "DIDN", "%x"},
90 {WIDGET_SIDN
, -24, "SIDN", "%x"},
91 {WIDGET_PACTYP
, -20, "PACTYP", 0, xio_cmd_pactyp
},
92 {WIDGET_TNUM
, -15, "TNUM", "%x"},
93 {WIDGET_COHERENT
, 0, "COHERENT"},
95 {WIDGET_GBR
, 0, "GBR"},
96 {WIDGET_VBPM
, 0, "VBPM"},
97 {WIDGET_ERROR
, 0, "ERROR"},
98 {WIDGET_BARRIER
, 0, "BARRIER"},
102 #define F(s,n) { 1l<<(s),-(s), n }
104 static struct reg_values space_v
[] =
106 {PCIIO_SPACE_NONE
, "none"},
107 {PCIIO_SPACE_ROM
, "ROM"},
108 {PCIIO_SPACE_IO
, "I/O"},
109 {PCIIO_SPACE_MEM
, "MEM"},
110 {PCIIO_SPACE_MEM32
, "MEM(32)"},
111 {PCIIO_SPACE_MEM64
, "MEM(64)"},
112 {PCIIO_SPACE_CFG
, "CFG"},
113 {PCIIO_SPACE_WIN(0), "WIN(0)"},
114 {PCIIO_SPACE_WIN(1), "WIN(1)"},
115 {PCIIO_SPACE_WIN(2), "WIN(2)"},
116 {PCIIO_SPACE_WIN(3), "WIN(3)"},
117 {PCIIO_SPACE_WIN(4), "WIN(4)"},
118 {PCIIO_SPACE_WIN(5), "WIN(5)"},
119 {PCIIO_SPACE_BAD
, "BAD"},
122 static struct reg_desc space_desc
[] =
124 {0xFF, 0, "space", 0, space_v
},
127 #define device_desc device_bits
128 static struct reg_desc device_bits
[] =
130 {BRIDGE_DEV_ERR_LOCK_EN
, 0, "ERR_LOCK_EN"},
131 {BRIDGE_DEV_PAGE_CHK_DIS
, 0, "PAGE_CHK_DIS"},
132 {BRIDGE_DEV_FORCE_PCI_PAR
, 0, "FORCE_PCI_PAR"},
133 {BRIDGE_DEV_VIRTUAL_EN
, 0, "VIRTUAL_EN"},
134 {BRIDGE_DEV_PMU_WRGA_EN
, 0, "PMU_WRGA_EN"},
135 {BRIDGE_DEV_DIR_WRGA_EN
, 0, "DIR_WRGA_EN"},
136 {BRIDGE_DEV_DEV_SIZE
, 0, "DEV_SIZE"},
137 {BRIDGE_DEV_RT
, 0, "RT"},
138 {BRIDGE_DEV_SWAP_PMU
, 0, "SWAP_PMU"},
139 {BRIDGE_DEV_SWAP_DIR
, 0, "SWAP_DIR"},
140 {BRIDGE_DEV_PREF
, 0, "PREF"},
141 {BRIDGE_DEV_PRECISE
, 0, "PRECISE"},
142 {BRIDGE_DEV_COH
, 0, "COH"},
143 {BRIDGE_DEV_BARRIER
, 0, "BARRIER"},
144 {BRIDGE_DEV_GBR
, 0, "GBR"},
145 {BRIDGE_DEV_DEV_SWAP
, 0, "DEV_SWAP"},
146 {BRIDGE_DEV_DEV_IO_MEM
, 0, "DEV_IO_MEM"},
147 {BRIDGE_DEV_OFF_MASK
, BRIDGE_DEV_OFF_ADDR_SHFT
, "DEV_OFF", "%x"},
152 print_bridge_errcmd(uint32_t cmdword
, char *errtype
)
154 printk("\t Bridge %s Error Command Word Register ", errtype
);
155 print_register(cmdword
, xio_cmd_bits
);
158 static char *pcibr_isr_errs
[] =
160 "", "", "", "", "", "", "", "",
161 "08: GIO non-contiguous byte enable in crosstalk packet", /* BRIDGE ONLY */
162 "09: PCI to Crosstalk read request timeout",
163 "10: PCI retry operation count exhausted.",
164 "11: PCI bus device select timeout",
165 "12: PCI device reported parity error",
166 "13: PCI Address/Cmd parity error ",
167 "14: PCI Bridge detected parity error",
168 "15: PCI abort condition",
169 "16: SSRAM parity error", /* BRIDGE ONLY */
170 "17: LLP Transmitter Retry count wrapped",
171 "18: LLP Transmitter side required Retry",
172 "19: LLP Receiver retry count wrapped",
173 "20: LLP Receiver check bit error",
174 "21: LLP Receiver sequence number error",
175 "22: Request packet overflow",
176 "23: Request operation not supported by bridge",
177 "24: Request packet has invalid address for bridge widget",
178 "25: Incoming request xtalk command word error bit set or invalid sideband",
179 "26: Incoming response xtalk command word error bit set or invalid sideband",
180 "27: Framing error, request cmd data size does not match actual",
181 "28: Framing error, response cmd data size does not match actual",
182 "29: Unexpected response arrived",
183 "30: PMU Access Fault",
184 "31: Multiple errors occurred", /* BRIDGE ONLY */
186 /* bits 32-45 are PIC ONLY */
187 "32: PCI-X address or attribute cycle parity error",
188 "33: PCI-X data cycle parity error",
189 "34: PCI-X master timeout (ie. master abort)",
190 "35: PCI-X pio retry counter exhausted",
193 "38: PCI-X target abort",
194 "39: PCI-X read request timeout",
195 "40: PCI / PCI-X device requestin arbitration error",
196 "41: internal RAM parity error",
197 "42: PCI-X unexpected completion cycle to master",
198 "43: PCI-X split completion timeout",
199 "44: PCI-X split completion error message",
200 "45: PCI-X split completion message parity error",
203 #define BEM_ADD_STR(s) printk("%s", (s))
204 #define BEM_ADD_VAR(v) printk("\t%20s: 0x%llx\n", #v, ((unsigned long long)v))
205 #define BEM_ADD_REG(r) printk("\t%20s: ", #r); print_register((r), r ## _desc)
206 #define BEM_ADD_NSPC(n,s) printk("\t%20s: ", n); print_register(s, space_desc)
207 #define BEM_ADD_SPC(s) BEM_ADD_NSPC(#s, s)
210 * display memory directory state
213 pcibr_show_dir_state(paddr_t paddr
, char *prefix
)
219 extern char *dir_state_str
[];
220 extern void get_dir_ent(paddr_t
, int *, uint64_t *, hubreg_t
*);
222 get_dir_ent(paddr
, &state
, &vec_ptr
, &elo
);
224 printk("%saddr 0x%lx: state 0x%x owner 0x%lx (%s)\n",
225 prefix
, paddr
, state
, vec_ptr
, dir_state_str
[state
]);
231 * Dump relevant error information for Bridge error interrupts.
235 pcibr_error_dump(pcibr_soft_t pcibr_soft
)
237 bridge_t
*bridge
= pcibr_soft
->bs_base
;
239 bridgereg_t int_status_32
;
240 picreg_t int_status_64
;
242 bridgereg_t mult_int_32
;
243 picreg_t mult_int_64
;
248 paddr_t addr
= (paddr_t
)0;
250 /* We read the INT_STATUS register as a 64bit picreg_t for PIC and a
251 * 32bit bridgereg_t for BRIDGE, but always process the result as a
252 * 64bit value so the code can be "common" for both PIC and BRIDGE...
254 if (IS_PIC_SOFT(pcibr_soft
)) {
255 int_status_64
= (bridge
->p_int_status_64
& ~BRIDGE_ISR_INT_MSK
);
256 int_status
= (uint64_t)int_status_64
;
257 number_bits
= PCIBR_ISR_MAX_ERRS_PIC
;
259 int_status_32
= (bridge
->b_int_status
& ~BRIDGE_ISR_INT_MSK
);
260 int_status
= ((uint64_t)int_status_32
) & 0xffffffff;
261 number_bits
= PCIBR_ISR_MAX_ERRS_BRIDGE
;
265 /* No error bits set */
269 /* Check if dumping the same error information multiple times */
270 if ( pcibr_soft
->bs_errinfo
.bserr_intstat
== int_status
)
272 pcibr_soft
->bs_errinfo
.bserr_intstat
= int_status
;
274 printk(KERN_ALERT
"PCI BRIDGE ERROR: int_status is 0x%lx for %s\n"
275 " Dumping relevant %s registers for each bit set...\n",
276 int_status
, pcibr_soft
->bs_name
,
277 (IS_PIC_SOFT(pcibr_soft
) ? "PIC" :
278 (IS_BRIDGE_SOFT(pcibr_soft
) ? "BRIDGE" : "XBRIDGE")));
280 for (i
= PCIBR_ISR_ERR_START
; i
< number_bits
; i
++) {
284 * A number of int_status bits are only defined for Bridge.
285 * Ignore them in the case of an XBridge or PIC.
287 if ((IS_XBRIDGE_SOFT(pcibr_soft
) || IS_PIC_SOFT(pcibr_soft
)) &&
288 ((bit
== BRIDGE_ISR_MULTI_ERR
) ||
289 (bit
== BRIDGE_ISR_SSRAM_PERR
) ||
290 (bit
== BRIDGE_ISR_GIO_B_ENBL_ERR
))) {
294 /* A number of int_status bits are only valid for PIC's bus0 */
295 if ((IS_PIC_SOFT(pcibr_soft
) && (pcibr_soft
->bs_busnum
!= 0)) &&
296 ((bit
== BRIDGE_ISR_UNSUPPORTED_XOP
) ||
297 (bit
== BRIDGE_ISR_LLP_REC_SNERR
) ||
298 (bit
== BRIDGE_ISR_LLP_REC_CBERR
) ||
299 (bit
== BRIDGE_ISR_LLP_RCTY
) ||
300 (bit
== BRIDGE_ISR_LLP_TX_RETRY
) ||
301 (bit
== BRIDGE_ISR_LLP_TCTY
))) {
305 if (int_status
& bit
) {
306 printk("\t%s\n", pcibr_isr_errs
[i
]);
310 case PIC_ISR_INT_RAM_PERR
: /* bit41 INT_RAM_PERR */
311 /* XXX: should breakdown meaning of bits in reg */
312 printk( "\t Internal RAM Parity Error: 0x%lx\n",
313 bridge
->p_ate_parity_err_64
);
316 case PIC_ISR_PCIX_ARB_ERR
: /* bit40 PCI_X_ARB_ERR */
317 /* XXX: should breakdown meaning of bits in reg */
318 printk( "\t Arbitration Reg: 0x%x\n",
322 case PIC_ISR_PCIX_REQ_TOUT
: /* bit39 PCI_X_REQ_TOUT */
323 /* XXX: should breakdown meaning of attribute bit */
325 "\t PCI-X DMA Request Error Address Reg: 0x%lx\n"
326 "\t PCI-X DMA Request Error Attribute Reg: 0x%lx\n",
327 bridge
->p_pcix_dma_req_err_addr_64
,
328 bridge
->p_pcix_dma_req_err_attr_64
);
331 case PIC_ISR_PCIX_SPLIT_MSG_PE
: /* bit45 PCI_X_SPLIT_MES_PE */
332 case PIC_ISR_PCIX_SPLIT_EMSG
: /* bit44 PCI_X_SPLIT_EMESS */
333 case PIC_ISR_PCIX_SPLIT_TO
: /* bit43 PCI_X_SPLIT_TO */
334 /* XXX: should breakdown meaning of attribute bit */
336 "\t PCI-X Split Request Address Reg: 0x%lx\n"
337 "\t PCI-X Split Request Attribute Reg: 0x%lx\n",
338 bridge
->p_pcix_pio_split_addr_64
,
339 bridge
->p_pcix_pio_split_attr_64
);
342 case PIC_ISR_PCIX_UNEX_COMP
: /* bit42 PCI_X_UNEX_COMP */
343 case PIC_ISR_PCIX_TABORT
: /* bit38 PCI_X_TABORT */
344 case PIC_ISR_PCIX_PERR
: /* bit37 PCI_X_PERR */
345 case PIC_ISR_PCIX_SERR
: /* bit36 PCI_X_SERR */
346 case PIC_ISR_PCIX_MRETRY
: /* bit35 PCI_X_MRETRY */
347 case PIC_ISR_PCIX_MTOUT
: /* bit34 PCI_X_MTOUT */
348 case PIC_ISR_PCIX_DA_PARITY
: /* bit33 PCI_X_DA_PARITY */
349 case PIC_ISR_PCIX_AD_PARITY
: /* bit32 PCI_X_AD_PARITY */
350 /* XXX: should breakdown meaning of attribute bit */
352 "\t PCI-X Bus Error Address Reg: 0x%lx\n"
353 "\t PCI-X Bus Error Attribute Reg: 0x%lx\n"
354 "\t PCI-X Bus Error Data Reg: 0x%lx\n",
355 bridge
->p_pcix_bus_err_addr_64
,
356 bridge
->p_pcix_bus_err_attr_64
,
357 bridge
->p_pcix_bus_err_data_64
);
360 case BRIDGE_ISR_PAGE_FAULT
: /* bit30 PMU_PAGE_FAULT */
361 if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft
))
362 reg_desc
= "Map Fault Address";
364 reg_desc
= "SSRAM Parity Error";
366 printk( "\t %s Register: 0x%x\n", reg_desc
,
367 bridge
->b_ram_perr_or_map_fault
);
370 case BRIDGE_ISR_UNEXP_RESP
: /* bit29 UNEXPECTED_RESP */
371 print_bridge_errcmd(bridge
->b_wid_aux_err
, "Aux ");
373 /* PIC in PCI-X mode, dump the PCIX DMA Request registers */
374 if (IS_PIC_SOFT(pcibr_soft
) && IS_PCIX(pcibr_soft
)) {
375 /* XXX: should breakdown meaning of attr bit */
377 "\t PCI-X DMA Request Error Addr Reg: 0x%lx\n"
378 "\t PCI-X DMA Request Error Attr Reg: 0x%lx\n",
379 bridge
->p_pcix_dma_req_err_addr_64
,
380 bridge
->p_pcix_dma_req_err_attr_64
);
384 case BRIDGE_ISR_BAD_XRESP_PKT
: /* bit28 BAD_RESP_PACKET */
385 case BRIDGE_ISR_RESP_XTLK_ERR
: /* bit26 RESP_XTALK_ERROR */
386 if (IS_PIC_SOFT(pcibr_soft
)) {
387 print_bridge_errcmd(bridge
->b_wid_aux_err
, "Aux ");
390 /* If PIC in PCI-X mode, DMA Request Error registers are
391 * valid. But PIC in PCI mode, Response Buffer Address
392 * register are valid.
394 if (IS_PCIX(pcibr_soft
)) {
395 /* XXX: should breakdown meaning of attribute bit */
397 "\t PCI-X DMA Request Error Addr Reg: 0x%lx\n"
398 "\t PCI-X DMA Request Error Attribute Reg: 0x%lx\n",
399 bridge
->p_pcix_dma_req_err_addr_64
,
400 bridge
->p_pcix_dma_req_err_attr_64
);
402 addr
= (((uint64_t)(bridge
->b_wid_resp_upper
& 0xFFFF)<<32)
403 | bridge
->b_wid_resp_lower
);
404 printk("\t Bridge Response Buf Error Upper Addr Reg: 0x%x\n"
405 "\t Bridge Response Buf Error Lower Addr Reg: 0x%x\n"
406 "\t dev-num %d buff-num %d addr 0x%lx\n",
407 bridge
->b_wid_resp_upper
, bridge
->b_wid_resp_lower
,
408 ((bridge
->b_wid_resp_upper
>> 20) & 0x3),
409 ((bridge
->b_wid_resp_upper
>> 16) & 0xF),
412 if (bit
== BRIDGE_ISR_RESP_XTLK_ERR
) {
413 /* display memory directory associated with cacheline */
414 pcibr_show_dir_state(addr
, "\t ");
418 case BRIDGE_ISR_BAD_XREQ_PKT
: /* bit27 BAD_XREQ_PACKET */
419 case BRIDGE_ISR_REQ_XTLK_ERR
: /* bit25 REQ_XTALK_ERROR */
420 case BRIDGE_ISR_INVLD_ADDR
: /* bit24 INVALID_ADDRESS */
421 print_bridge_errcmd(bridge
->b_wid_err_cmdword
, "");
423 "\t Bridge Error Upper Address Register: 0x%lx\n"
424 "\t Bridge Error Lower Address Register: 0x%lx\n"
425 "\t Bridge Error Address: 0x%lx\n",
426 (uint64_t) bridge
->b_wid_err_upper
,
427 (uint64_t) bridge
->b_wid_err_lower
,
428 (((uint64_t) bridge
->b_wid_err_upper
<< 32) |
429 bridge
->b_wid_err_lower
));
432 case BRIDGE_ISR_UNSUPPORTED_XOP
:/* bit23 UNSUPPORTED_XOP */
433 if (IS_PIC_SOFT(pcibr_soft
)) {
434 print_bridge_errcmd(bridge
->b_wid_aux_err
, "Aux ");
436 "\t Address Holding Link Side Error Reg: 0x%lx\n",
437 bridge
->p_addr_lkerr_64
);
439 print_bridge_errcmd(bridge
->b_wid_err_cmdword
, "");
441 "\t Bridge Error Upper Address Register: 0x%lx\n"
442 "\t Bridge Error Lower Address Register: 0x%lx\n"
443 "\t Bridge Error Address: 0x%lx\n",
444 (uint64_t) bridge
->b_wid_err_upper
,
445 (uint64_t) bridge
->b_wid_err_lower
,
446 (((uint64_t) bridge
->b_wid_err_upper
<< 32) |
447 bridge
->b_wid_err_lower
));
451 case BRIDGE_ISR_XREQ_FIFO_OFLOW
:/* bit22 XREQ_FIFO_OFLOW */
452 /* Link side error registers are only valid for PIC */
453 if (IS_PIC_SOFT(pcibr_soft
)) {
454 print_bridge_errcmd(bridge
->b_wid_aux_err
, "Aux ");
456 "\t Address Holding Link Side Error Reg: 0x%lx\n",
457 bridge
->p_addr_lkerr_64
);
461 case BRIDGE_ISR_SSRAM_PERR
: /* bit16 SSRAM_PERR */
462 if (IS_BRIDGE_SOFT(pcibr_soft
)) {
464 "\t Bridge SSRAM Parity Error Register: 0x%x\n",
469 case BRIDGE_ISR_PCI_ABORT
: /* bit15 PCI_ABORT */
470 case BRIDGE_ISR_PCI_PARITY
: /* bit14 PCI_PARITY */
471 case BRIDGE_ISR_PCI_SERR
: /* bit13 PCI_SERR */
472 case BRIDGE_ISR_PCI_PERR
: /* bit12 PCI_PERR */
473 case BRIDGE_ISR_PCI_MST_TIMEOUT
:/* bit11 PCI_MASTER_TOUT */
474 case BRIDGE_ISR_PCI_RETRY_CNT
: /* bit10 PCI_RETRY_CNT */
475 case BRIDGE_ISR_GIO_B_ENBL_ERR
: /* bit08 GIO BENABLE_ERR */
477 "\t PCI Error Upper Address Register: 0x%lx\n"
478 "\t PCI Error Lower Address Register: 0x%lx\n"
479 "\t PCI Error Address: 0x%lx\n",
480 (uint64_t) bridge
->b_pci_err_upper
,
481 (uint64_t) bridge
->b_pci_err_lower
,
482 (((uint64_t) bridge
->b_pci_err_upper
<< 32) |
483 bridge
->b_pci_err_lower
));
486 case BRIDGE_ISR_XREAD_REQ_TIMEOUT
: /* bit09 XREAD_REQ_TOUT */
487 addr
= (((uint64_t)(bridge
->b_wid_resp_upper
& 0xFFFF) << 32)
488 | bridge
->b_wid_resp_lower
);
490 "\t Bridge Response Buf Error Upper Addr Reg: 0x%x\n"
491 "\t Bridge Response Buf Error Lower Addr Reg: 0x%x\n"
492 "\t dev-num %d buff-num %d addr 0x%lx\n",
493 bridge
->b_wid_resp_upper
, bridge
->b_wid_resp_lower
,
494 ((bridge
->b_wid_resp_upper
>> 20) & 0x3),
495 ((bridge
->b_wid_resp_upper
>> 16) & 0xF),
502 /* We read the INT_MULT register as a 64bit picreg_t for PIC and a
503 * 32bit bridgereg_t for BRIDGE, but always process the result as a
504 * 64bit value so the code can be "common" for both PIC and BRIDGE...
506 if (IS_PIC_SOFT(pcibr_soft
)) {
507 mult_int_64
= (bridge
->p_mult_int_64
& ~BRIDGE_ISR_INT_MSK
);
508 mult_int
= (uint64_t)mult_int_64
;
509 number_bits
= PCIBR_ISR_MAX_ERRS_PIC
;
511 mult_int_32
= (bridge
->b_mult_int
& ~BRIDGE_ISR_INT_MSK
);
512 mult_int
= ((uint64_t)mult_int_32
) & 0xffffffff;
513 number_bits
= PCIBR_ISR_MAX_ERRS_BRIDGE
;
516 if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft
)&&(mult_int
& ~BRIDGE_ISR_INT_MSK
)) {
517 printk( " %s Multiple Interrupt Register is 0x%lx\n",
518 IS_PIC_SOFT(pcibr_soft
) ? "PIC" : "XBridge", mult_int
);
519 for (i
= PCIBR_ISR_ERR_START
; i
< number_bits
; i
++) {
520 if (mult_int
& (1ull << i
))
521 printk( "\t%s\n", pcibr_isr_errs
[i
]);
527 pcibr_errintr_group(uint32_t error
)
529 uint32_t group
= BRIDGE_IRR_MULTI_CLR
;
531 if (error
& BRIDGE_IRR_PCI_GRP
)
532 group
|= BRIDGE_IRR_PCI_GRP_CLR
;
533 if (error
& BRIDGE_IRR_SSRAM_GRP
)
534 group
|= BRIDGE_IRR_SSRAM_GRP_CLR
;
535 if (error
& BRIDGE_IRR_LLP_GRP
)
536 group
|= BRIDGE_IRR_LLP_GRP_CLR
;
537 if (error
& BRIDGE_IRR_REQ_DSP_GRP
)
538 group
|= BRIDGE_IRR_REQ_DSP_GRP_CLR
;
539 if (error
& BRIDGE_IRR_RESP_BUF_GRP
)
540 group
|= BRIDGE_IRR_RESP_BUF_GRP_CLR
;
541 if (error
& BRIDGE_IRR_CRP_GRP
)
542 group
|= BRIDGE_IRR_CRP_GRP_CLR
;
549 /* pcibr_pioerr_check():
550 * Check to see if this pcibr has a PCI PIO
551 * TIMEOUT error; if so, bump the timeout-count
552 * on any piomaps that could cover the address.
555 pcibr_pioerr_check(pcibr_soft_t soft
)
559 bridgereg_t int_status_32
;
560 picreg_t int_status_64
;
561 bridgereg_t pci_err_lower
;
562 bridgereg_t pci_err_upper
;
571 bridge
= soft
->bs_base
;
573 /* We read the INT_STATUS register as a 64bit picreg_t for PIC and a
574 * 32bit bridgereg_t for BRIDGE, but always process the result as a
575 * 64bit value so the code can be "common" for both PIC and BRIDGE...
577 if (IS_PIC_SOFT(soft
)) {
578 int_status_64
= (bridge
->p_int_status_64
& ~BRIDGE_ISR_INT_MSK
);
579 int_status
= (uint64_t)int_status_64
;
581 int_status_32
= (bridge
->b_int_status
& ~BRIDGE_ISR_INT_MSK
);
582 int_status
= ((uint64_t)int_status_32
) & 0xffffffff;
585 if (int_status
& BRIDGE_ISR_PCIBUS_PIOERR
) {
586 pci_err_lower
= bridge
->b_pci_err_lower
;
587 pci_err_upper
= bridge
->b_pci_err_upper
;
589 pci_addr
= pci_err_upper
& BRIDGE_ERRUPPR_ADDRMASK
;
590 pci_addr
= (pci_addr
<< 32) | pci_err_lower
;
592 slot
= PCIBR_NUM_SLOTS(soft
);
594 int nfunc
= soft
->bs_slot
[slot
].bss_ninfo
;
595 pcibr_info_h pcibr_infoh
= soft
->bs_slot
[slot
].bss_infos
;
597 for (func
= 0; func
< nfunc
; func
++) {
598 pcibr_info_t pcibr_info
= pcibr_infoh
[func
];
603 for (map
= pcibr_info
->f_piomap
;
604 map
!= NULL
; map
= map
->bp_next
) {
605 base
= map
->bp_pciaddr
;
606 size
= map
->bp_mapsz
;
607 win
= map
->bp_space
- PCIIO_SPACE_WIN(0);
609 base
+= soft
->bs_slot
[slot
].bss_window
[win
].bssw_base
;
610 else if (map
->bp_space
== PCIIO_SPACE_ROM
)
611 base
+= pcibr_info
->f_rbase
;
612 if ((pci_addr
>= base
) && (pci_addr
< (base
+ size
)))
613 atomic_inc(&map
->bp_toc
[0]);
621 * PCI Bridge Error interrupt handler.
622 * This gets invoked, whenever a PCI bridge sends an error interrupt.
623 * Primarily this servers two purposes.
624 * - If an error can be handled (typically a PIO read/write
625 * error, we try to do it silently.
626 * - If an error cannot be handled, we die violently.
627 * Interrupt due to PIO errors:
628 * - Bridge sends an interrupt, whenever a PCI operation
629 * done by the bridge as the master fails. Operations could
630 * be either a PIO read or a PIO write.
631 * PIO Read operation also triggers a bus error, and it's
632 * We primarily ignore this interrupt in that context..
633 * For PIO write errors, this is the only indication.
634 * and we have to handle with the info from here.
636 * So, there is no way to distinguish if an interrupt is
637 * due to read or write error!.
641 pcibr_error_intr_handler(int irq
, void *arg
, struct pt_regs
*ep
)
643 pcibr_soft_t pcibr_soft
;
647 bridgereg_t int_status_32
;
648 picreg_t int_status_64
;
651 uint64_t disable_errintr_mask
= 0;
657 * Defensive code for linked pcibr_soft structs
660 extern pcibr_list_p pcibr_list
;
666 PRINT_PANIC("pcibr_error_intr_handler:\tmy parameter (0x%p) is not a pcibr_soft!", arg
);
668 if ((intr_arg_t
) entry
->bl_soft
== arg
)
670 entry
= entry
->bl_next
;
673 #endif /* PCIBR_SOFT_LIST */
674 pcibr_soft
= (pcibr_soft_t
) arg
;
675 bridge
= pcibr_soft
->bs_base
;
678 * pcibr_error_intr_handler gets invoked whenever bridge encounters
679 * an error situation, and the interrupt for that error is enabled.
680 * This routine decides if the error is fatal or not, and takes
681 * action accordingly.
683 * In the case of PIO read/write timeouts, there is no way
684 * to know if it was a read or write request that timed out.
685 * If the error was due to a "read", a bus error will also occur
686 * and the bus error handling code takes care of it.
687 * If the error is due to a "write", the error is currently logged
688 * by this routine. For SN1 and SN0, if fire-and-forget mode is
689 * disabled, a write error response xtalk packet will be sent to
690 * the II, which will cause an II error interrupt. No write error
691 * recovery actions of any kind currently take place at the pcibr
692 * layer! (e.g., no panic on unrecovered write error)
694 * Prior to reading the Bridge int_status register we need to ensure
695 * that there are no error bits set in the lower layers (hubii)
696 * that have disabled PIO access to the widget. If so, there is nothing
697 * we can do until the bits clear, so we setup a timeout and try again
701 nasid
= NASID_GET(bridge
);
702 if (hubii_check_widget_disabled(nasid
, pcibr_soft
->bs_xid
)) {
703 DECLARE_WAIT_QUEUE_HEAD(wq
);
704 sleep_on_timeout(&wq
, BRIDGE_PIOERR_TIMEOUT
*HZ
); /* sleep */
705 pcibr_soft
->bs_errinfo
.bserr_toutcnt
++;
706 /* Let's go recursive */
707 return(pcibr_error_intr_handler(irq
, arg
, ep
));
710 /* We read the INT_STATUS register as a 64bit picreg_t for PIC and a
711 * 32bit bridgereg_t for BRIDGE, but always process the result as a
712 * 64bit value so the code can be "common" for both PIC and BRIDGE...
714 if (IS_PIC_SOFT(pcibr_soft
)) {
715 int_status_64
= (bridge
->p_int_status_64
& ~BRIDGE_ISR_INT_MSK
);
716 int_status
= (uint64_t)int_status_64
;
717 number_bits
= PCIBR_ISR_MAX_ERRS_PIC
;
719 int_status_32
= (bridge
->b_int_status
& ~BRIDGE_ISR_INT_MSK
);
720 int_status
= ((uint64_t)int_status_32
) & 0xffffffff;
721 number_bits
= PCIBR_ISR_MAX_ERRS_BRIDGE
;
724 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ERROR
, pcibr_soft
->bs_conn
,
725 "pcibr_error_intr_handler: int_status=0x%x\n", int_status
));
727 /* int_status is which bits we have to clear;
728 * err_status is the bits we haven't handled yet.
730 err_status
= int_status
& ~BRIDGE_ISR_MULTI_ERR
;
732 if (!(int_status
& ~BRIDGE_ISR_INT_MSK
)) {
734 * No error bit set!!.
739 * If we have a PCIBUS_PIOERR, hand it to the logger.
741 if (int_status
& BRIDGE_ISR_PCIBUS_PIOERR
) {
742 pcibr_pioerr_check(pcibr_soft
);
746 struct bs_errintr_stat_s
*bs_estat
= pcibr_soft
->bs_errintr_stat
;
748 for (i
= PCIBR_ISR_ERR_START
; i
< number_bits
; i
++, bs_estat
++) {
749 if (err_status
& (1ull << i
)) {
750 uint32_t errrate
= 0;
751 uint32_t errcount
= 0;
752 uint32_t errinterval
= 0, current_tick
= 0;
753 int llp_tx_retry_errors
= 0;
754 int is_llp_tx_retry_intr
= 0;
756 bs_estat
->bs_errcount_total
++;
758 current_tick
= jiffies
;
759 errinterval
= (current_tick
- bs_estat
->bs_lasterr_timestamp
);
760 errcount
= (bs_estat
->bs_errcount_total
-
761 bs_estat
->bs_lasterr_snapshot
);
763 /* LLP interrrupt errors are only valid on BUS0 of the PIC */
764 if (pcibr_soft
->bs_busnum
== 0)
765 is_llp_tx_retry_intr
= (BRIDGE_ISR_LLP_TX_RETRY
==(1ull << i
));
767 /* Check for the divide by zero condition while
768 * calculating the error rates.
772 errrate
= errcount
/ errinterval
;
773 /* If able to calculate error rate
774 * on a LLP transmitter retry interrupt, check
775 * if the error rate is nonzero and we have seen
776 * a certain minimum number of errors.
778 * NOTE : errcount is being compared to
779 * PCIBR_ERRTIME_THRESHOLD to make sure that we are not
780 * seeing cases like x error interrupts per y ticks for
781 * very low x ,y (x > y ) which could result in a
784 if (is_llp_tx_retry_intr
&&
786 (errcount
>= PCIBR_ERRTIME_THRESHOLD
)) {
787 llp_tx_retry_errors
= 1;
791 /* Since we are not able to calculate the
792 * error rate check if we exceeded a certain
793 * minimum number of errors for LLP transmitter
794 * retries. Note that this can only happen
795 * within the first tick after the last snapshot.
797 if (is_llp_tx_retry_intr
&&
798 (errcount
>= PCIBR_ERRINTR_DISABLE_LEVEL
)) {
799 llp_tx_retry_errors
= 1;
804 * If a non-zero error rate (which is equivalent to
805 * to 100 errors/tick at least) for the LLP transmitter
806 * retry interrupt was seen, check if we should print
810 if (llp_tx_retry_errors
) {
811 static uint32_t last_printed_rate
;
813 if (errrate
> last_printed_rate
) {
814 last_printed_rate
= errrate
;
815 /* Print the warning only if the error rate
816 * for the transmitter retry interrupt
817 * exceeded the previously printed rate.
820 "%s: %s, Excessive error interrupts : %d/tick\n",
827 * Update snapshot, and time
829 bs_estat
->bs_lasterr_timestamp
= current_tick
;
830 bs_estat
->bs_lasterr_snapshot
=
831 bs_estat
->bs_errcount_total
;
835 * If the error rate is high enough, print the error rate.
837 if (errinterval
> PCIBR_ERRTIME_THRESHOLD
) {
839 if (errrate
> PCIBR_ERRRATE_THRESHOLD
) {
840 printk(KERN_NOTICE
"%s: %s, Error rate %d/tick",
845 * Update snapshot, and time
847 bs_estat
->bs_lasterr_timestamp
= current_tick
;
848 bs_estat
->bs_lasterr_snapshot
=
849 bs_estat
->bs_errcount_total
;
852 /* PIC BRINGUP WAR (PV# 856155):
853 * Dont disable PCI_X_ARB_ERR interrupts, we need the
854 * interrupt inorder to clear the DEV_BROKE bits in
855 * b_arb register to re-enable the device.
857 if (IS_PIC_SOFT(pcibr_soft
) &&
858 !(err_status
& PIC_ISR_PCIX_ARB_ERR
) &&
859 PCIBR_WAR_ENABLED(PV856155
, pcibr_soft
)) {
861 if (bs_estat
->bs_errcount_total
> PCIBR_ERRINTR_DISABLE_LEVEL
) {
863 * We have seen a fairly large number of errors of
864 * this type. Let's disable the interrupt. But flash
865 * a message about the interrupt being disabled.
868 "%s Disabling error interrupt type %s. Error count %d",
871 bs_estat
->bs_errcount_total
);
872 disable_errintr_mask
|= (1ull << i
);
874 } /* PIC: WAR for PV 856155 end-of-if */
879 if (disable_errintr_mask
) {
882 * Disable some high frequency errors as they
883 * could eat up too much cpu time.
885 s
= pcibr_lock(pcibr_soft
);
886 if (IS_PIC_SOFT(pcibr_soft
)) {
887 bridge
->p_int_enable_64
&= (picreg_t
)(~disable_errintr_mask
);
889 bridge
->b_int_enable
&= (bridgereg_t
)(~disable_errintr_mask
);
891 pcibr_unlock(pcibr_soft
, s
);
894 * If we leave the PROM cacheable, T5 might
895 * try to do a cache line sized writeback to it,
896 * which will cause a BRIDGE_ISR_INVLD_ADDR.
898 if ((err_status
& BRIDGE_ISR_INVLD_ADDR
) &&
899 (0x00000000 == bridge
->b_wid_err_upper
) &&
900 (0x00C00000 == (0xFFC00000 & bridge
->b_wid_err_lower
)) &&
901 (0x00402000 == (0x00F07F00 & bridge
->b_wid_err_cmdword
))) {
902 err_status
&= ~BRIDGE_ISR_INVLD_ADDR
;
905 * The bridge bug (PCIBR_LLP_CONTROL_WAR), where the llp_config or control registers
906 * need to be read back after being written, affects an MP
907 * system since there could be small windows between writing
908 * the register and reading it back on one cpu while another
909 * cpu is fielding an interrupt. If we run into this scenario,
910 * workaround the problem by ignoring the error. (bug 454474)
911 * pcibr_llp_control_war_cnt keeps an approximate number of
912 * times we saw this problem on a system.
915 if ((err_status
& BRIDGE_ISR_INVLD_ADDR
) &&
916 ((((uint64_t) bridge
->b_wid_err_upper
<< 32) | (bridge
->b_wid_err_lower
))
917 == (BRIDGE_INT_RST_STAT
& 0xff0))) {
918 pcibr_llp_control_war_cnt
++;
919 err_status
&= ~BRIDGE_ISR_INVLD_ADDR
;
922 bridge_errors_to_dump
|= BRIDGE_ISR_PCIBUS_PIOERR
;
924 /* Dump/Log Bridge error interrupt info */
925 if (err_status
& bridge_errors_to_dump
) {
926 printk("BRIDGE ERR_STATUS 0x%lx\n", err_status
);
927 pcibr_error_dump(pcibr_soft
);
930 /* PIC BRINGUP WAR (PV# 867308):
931 * Make BRIDGE_ISR_LLP_REC_SNERR & BRIDGE_ISR_LLP_REC_CBERR fatal errors
932 * so we know we've hit the problem defined in PV 867308 that we believe
933 * has only been seen in simulation
935 if (IS_PIC_SOFT(pcibr_soft
) && PCIBR_WAR_ENABLED(PV867308
, pcibr_soft
) &&
936 (err_status
& (BRIDGE_ISR_LLP_REC_SNERR
| BRIDGE_ISR_LLP_REC_CBERR
))) {
937 printk("BRIDGE ERR_STATUS 0x%lx\n", err_status
);
938 pcibr_error_dump(pcibr_soft
);
939 PRINT_PANIC("PCI Bridge Error interrupt killed the system");
942 if (err_status
& BRIDGE_ISR_ERROR_FATAL
) {
943 PRINT_PANIC("PCI Bridge Error interrupt killed the system");
949 * We can't return without re-enabling the interrupt, since
950 * it would cause problems for devices like IOC3 (Lost
951 * interrupts ?.). So, just cleanup the interrupt, and
952 * use saved values later..
954 * PIC doesn't require groups of interrupts to be cleared...
956 if (IS_PIC_SOFT(pcibr_soft
)) {
957 bridge
->p_int_rst_stat_64
= (picreg_t
)(int_status
| BRIDGE_IRR_MULTI_CLR
);
959 bridge
->b_int_rst_stat
= (bridgereg_t
)pcibr_errintr_group(int_status
);
962 /* PIC BRINGUP WAR (PV# 856155):
963 * On a PCI_X_ARB_ERR error interrupt clear the DEV_BROKE bits from
964 * the b_arb register to re-enable the device.
966 if (IS_PIC_SOFT(pcibr_soft
) &&
967 (err_status
& PIC_ISR_PCIX_ARB_ERR
) &&
968 PCIBR_WAR_ENABLED(PV856155
, pcibr_soft
)) {
969 bridge
->b_arb
|= (0xf << 20);
972 /* Zero out bserr_intstat field */
973 pcibr_soft
->bs_errinfo
.bserr_intstat
= 0;
977 pcibr_error_cleanup(pcibr_soft_t pcibr_soft
, int error_code
)
979 bridge_t
*bridge
= pcibr_soft
->bs_base
;
981 ASSERT(error_code
& IOECODE_PIO
);
982 error_code
= error_code
;
984 if (IS_PIC_SOFT(pcibr_soft
)) {
985 bridge
->p_int_rst_stat_64
= BRIDGE_IRR_PCI_GRP_CLR
|
987 BRIDGE_IRR_MULTI_CLR
;
989 bridge
->b_int_rst_stat
= BRIDGE_IRR_PCI_GRP_CLR
| BRIDGE_IRR_MULTI_CLR
;
992 (void) bridge
->b_wid_tflush
; /* flushbus */
997 pcibr_device_disable(pcibr_soft_t pcibr_soft
, int devnum
)
1001 * Device failed to handle error. Take steps to
1002 * disable this device ? HOW TO DO IT ?
1004 * If there are any Read response buffers associated
1005 * with this device, it's time to get them back!!
1007 * We can disassociate any interrupt level associated
1008 * with this device, and disable that interrupt level
1010 * For now it's just a place holder
1016 * Handle PIO error that happened at the bridge pointed by pcibr_soft.
1018 * Queries the Bus interface attached to see if the device driver
1019 * mapping the device-number that caused error can handle the
1020 * situation. If so, it will clean up any error, and return
1021 * indicating the error was handled. If the device driver is unable
1022 * to handle the error, it expects the bus-interface to disable that
1023 * device, and takes any steps needed here to take away any resources
1024 * associated with this device.
1027 /* BEM_ADD_IOE doesn't dump the whole ioerror, it just
1028 * decodes the PCI specific portions -- we count on our
1029 * callers to dump the raw IOE data.
1031 #define BEM_ADD_IOE(ioe) \
1033 if (IOERROR_FIELDVALID(ioe, busspace)) { \
1037 iopaddr_t busaddr; \
1039 IOERROR_GETVALUE(spc, ioe, busspace); \
1040 win = spc - PCIIO_SPACE_WIN(0); \
1041 IOERROR_GETVALUE(busaddr, ioe, busaddr); \
1042 IOERROR_GETVALUE(widdev, ioe, widgetdev); \
1045 case PCIIO_SPACE_CFG: \
1046 printk("\tPCI Slot %d Func %d CFG space Offset 0x%lx\n",\
1047 pciio_widgetdev_slot_get(widdev), \
1048 pciio_widgetdev_func_get(widdev), \
1051 case PCIIO_SPACE_IO: \
1052 printk("\tPCI I/O space Offset 0x%lx\n", busaddr); \
1054 case PCIIO_SPACE_MEM: \
1055 case PCIIO_SPACE_MEM32: \
1056 case PCIIO_SPACE_MEM64: \
1057 printk("\tPCI MEM space Offset 0x%lx\n", busaddr); \
1061 printk("\tPCI Slot %d Func %d Window %ld Offset 0x%lx\n",\
1062 pciio_widgetdev_slot_get(widdev), \
1063 pciio_widgetdev_func_get(widdev), \
1075 pcibr_soft_t pcibr_soft
,
1077 ioerror_mode_t mode
,
1080 int retval
= IOERROR_HANDLED
;
1082 vertex_hdl_t pcibr_vhdl
= pcibr_soft
->bs_vhdl
;
1083 bridge_t
*bridge
= pcibr_soft
->bs_base
;
1085 iopaddr_t bad_xaddr
;
1087 pciio_space_t raw_space
; /* raw PCI space */
1088 iopaddr_t raw_paddr
; /* raw PCI address */
1090 pciio_space_t space
; /* final PCI space */
1091 pciio_slot_t slot
; /* final PCI slot, if appropriate */
1092 pciio_function_t func
; /* final PCI func, if appropriate */
1093 iopaddr_t offset
; /* final PCI offset */
1103 * We expect to have an "xtalkaddr" coming in,
1104 * and need to construct the slot/space/offset.
1107 IOERROR_GETVALUE(bad_xaddr
, ioe
, xtalkaddr
);
1109 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR
, pcibr_soft
->bs_conn
,
1110 "pcibr_pioerror: pcibr_soft=0x%x, bad_xaddr=0x%x\n",
1111 pcibr_soft
, bad_xaddr
));
1113 slot
= PCIIO_SLOT_NONE
;
1114 func
= PCIIO_FUNC_NONE
;
1115 raw_space
= PCIIO_SPACE_NONE
;
1118 if ((bad_xaddr
>= PCIBR_BUS_TYPE0_CFG_DEV0(pcibr_soft
)) &&
1119 (bad_xaddr
< PCIBR_TYPE1_CFG(pcibr_soft
))) {
1120 raw_paddr
= bad_xaddr
- PCIBR_BUS_TYPE0_CFG_DEV0(pcibr_soft
);
1121 slot
= raw_paddr
/ BRIDGE_TYPE0_CFG_SLOT_OFF
;
1122 raw_paddr
= raw_paddr
% BRIDGE_TYPE0_CFG_SLOT_OFF
;
1123 raw_space
= PCIIO_SPACE_CFG
;
1125 if ((bad_xaddr
>= PCIBR_TYPE1_CFG(pcibr_soft
)) &&
1126 (bad_xaddr
< (PCIBR_TYPE1_CFG(pcibr_soft
) + 0x1000))) {
1127 /* Type 1 config space:
1128 * slot and function numbers not known.
1129 * Perhaps we can read them back?
1131 raw_paddr
= bad_xaddr
- PCIBR_TYPE1_CFG(pcibr_soft
);
1132 raw_space
= PCIIO_SPACE_CFG
;
1134 if ((bad_xaddr
>= PCIBR_BRIDGE_DEVIO0(pcibr_soft
)) &&
1135 (bad_xaddr
< PCIBR_BRIDGE_DEVIO(pcibr_soft
, BRIDGE_DEV_CNT
))) {
1138 raw_paddr
= bad_xaddr
- PCIBR_BRIDGE_DEVIO0(pcibr_soft
);
1139 x
= raw_paddr
/ BRIDGE_DEVIO_OFF
;
1140 raw_paddr
%= BRIDGE_DEVIO_OFF
;
1141 /* first two devio windows are double-sized */
1142 if ((x
== 1) || (x
== 3))
1143 raw_paddr
+= BRIDGE_DEVIO_OFF
;
1148 /* x is which devio reg; no guarantee
1149 * PCI slot x will be responding.
1150 * still need to figure out who decodes
1151 * space/offset on the bus.
1153 raw_space
= pcibr_soft
->bs_slot
[x
].bss_devio
.bssd_space
;
1154 if (raw_space
== PCIIO_SPACE_NONE
) {
1155 /* Someone got an error because they
1156 * accessed the PCI bus via a DevIO(x)
1157 * window that pcibr has not yet assigned
1158 * to any specific PCI address. It is
1159 * quite possible that the Device(x)
1160 * register has been changed since they
1161 * made their access, but we will give it
1162 * our best decode shot.
1164 raw_space
= pcibr_soft
->bs_slot
[x
].bss_device
1165 & BRIDGE_DEV_DEV_IO_MEM
1169 (pcibr_soft
->bs_slot
[x
].bss_device
&
1170 BRIDGE_DEV_OFF_MASK
) <<
1171 BRIDGE_DEV_OFF_ADDR_SHFT
;
1173 raw_paddr
+= pcibr_soft
->bs_slot
[x
].bss_devio
.bssd_base
;
1175 if ((bad_xaddr
>= BRIDGE_PCI_MEM32_BASE
) &&
1176 (bad_xaddr
<= BRIDGE_PCI_MEM32_LIMIT
)) {
1177 raw_space
= PCIIO_SPACE_MEM32
;
1178 raw_paddr
= bad_xaddr
- BRIDGE_PCI_MEM32_BASE
;
1180 if ((bad_xaddr
>= BRIDGE_PCI_MEM64_BASE
) &&
1181 (bad_xaddr
<= BRIDGE_PCI_MEM64_LIMIT
)) {
1182 raw_space
= PCIIO_SPACE_MEM64
;
1183 raw_paddr
= bad_xaddr
- BRIDGE_PCI_MEM64_BASE
;
1185 if ((bad_xaddr
>= BRIDGE_PCI_IO_BASE
) &&
1186 (bad_xaddr
<= BRIDGE_PCI_IO_LIMIT
)) {
1187 raw_space
= PCIIO_SPACE_IO
;
1188 raw_paddr
= bad_xaddr
- BRIDGE_PCI_IO_BASE
;
1193 if ((slot
== PCIIO_SLOT_NONE
) && (space
!= PCIIO_SPACE_NONE
)) {
1194 /* we've got a space/offset but not which
1195 * PCI slot decodes it. Check through our
1196 * notions of which devices decode where.
1198 * Yes, this "duplicates" some logic in
1199 * pcibr_addr_toslot; the difference is,
1200 * this code knows which space we are in,
1201 * and can really really tell what is
1202 * going on (no guessing).
1205 for (cs
= pcibr_soft
->bs_min_slot
;
1206 (cs
< PCIBR_NUM_SLOTS(pcibr_soft
)) &&
1207 (slot
== PCIIO_SLOT_NONE
); cs
++) {
1208 int nf
= pcibr_soft
->bs_slot
[cs
].bss_ninfo
;
1209 pcibr_info_h pcibr_infoh
= pcibr_soft
->bs_slot
[cs
].bss_infos
;
1211 for (cf
= 0; (cf
< nf
) && (slot
== PCIIO_SLOT_NONE
); cf
++) {
1212 pcibr_info_t pcibr_info
= pcibr_infoh
[cf
];
1216 for (cw
= 0; (cw
< 6) && (slot
== PCIIO_SLOT_NONE
); ++cw
) {
1217 if (((wx
= pcibr_info
->f_window
[cw
].w_space
) != PCIIO_SPACE_NONE
) &&
1218 ((wb
= pcibr_info
->f_window
[cw
].w_base
) != 0) &&
1219 ((ws
= pcibr_info
->f_window
[cw
].w_size
) != 0) &&
1220 ((wl
= wb
+ ws
) > wb
) &&
1221 ((wb
<= offset
) && (wl
> offset
))) {
1222 /* MEM, MEM32 and MEM64 need to
1223 * compare as equal ...
1225 if ((wx
== space
) ||
1226 (((wx
== PCIIO_SPACE_MEM
) ||
1227 (wx
== PCIIO_SPACE_MEM32
) ||
1228 (wx
== PCIIO_SPACE_MEM64
)) &&
1229 ((space
== PCIIO_SPACE_MEM
) ||
1230 (space
== PCIIO_SPACE_MEM32
) ||
1231 (space
== PCIIO_SPACE_MEM64
)))) {
1234 space
= PCIIO_SPACE_WIN(cw
);
1236 } /* endif window space match */
1237 } /* endif window valid and addr match */
1238 } /* next window unless slot set */
1239 } /* next func unless slot set */
1240 } /* next slot unless slot set */
1241 /* XXX- if slot is still -1, no PCI devices are
1242 * decoding here using their standard PCI BASE
1243 * registers. This would be a really good place
1244 * to cross-coordinate with the pciio PCI
1245 * address space allocation routines, to find
1246 * out if this address is "allocated" by any of
1247 * our subsidiary devices.
1250 /* Scan all piomap records on this PCI bus to update
1251 * the TimeOut Counters on all matching maps. If we
1252 * don't already know the slot number, take it from
1253 * the first matching piomap. Note that we have to
1254 * compare maps against raw_space and raw_paddr
1255 * since space and offset could already be
1258 * There is a chance that one CPU could update
1259 * through this path, and another CPU could also
1260 * update due to an interrupt. Closing this hole
1261 * would only result in the possibility of some
1262 * errors never getting logged at all, and since the
1263 * use for bp_toc is as a logical test rather than a
1264 * strict count, the excess counts are not a
1267 for (cs
= pcibr_soft
->bs_min_slot
;
1268 cs
< PCIBR_NUM_SLOTS(pcibr_soft
); ++cs
) {
1269 int nf
= pcibr_soft
->bs_slot
[cs
].bss_ninfo
;
1270 pcibr_info_h pcibr_infoh
= pcibr_soft
->bs_slot
[cs
].bss_infos
;
1272 for (cf
= 0; cf
< nf
; cf
++) {
1273 pcibr_info_t pcibr_info
= pcibr_infoh
[cf
];
1279 for (map
= pcibr_info
->f_piomap
;
1280 map
!= NULL
; map
= map
->bp_next
) {
1282 wb
= map
->bp_pciaddr
;
1284 cw
= wx
- PCIIO_SPACE_WIN(0);
1286 wb
+= pcibr_soft
->bs_slot
[cs
].bss_window
[cw
].bssw_base
;
1287 wx
= pcibr_soft
->bs_slot
[cs
].bss_window
[cw
].bssw_space
;
1289 if (wx
== PCIIO_SPACE_ROM
) {
1290 wb
+= pcibr_info
->f_rbase
;
1291 wx
= PCIIO_SPACE_MEM
;
1293 if ((wx
== PCIIO_SPACE_MEM32
) ||
1294 (wx
== PCIIO_SPACE_MEM64
))
1295 wx
= PCIIO_SPACE_MEM
;
1297 if ((wx
== raw_space
) && (raw_paddr
>= wb
) && (raw_paddr
< wl
)) {
1298 atomic_inc(&map
->bp_toc
[0]);
1299 if (slot
== PCIIO_SLOT_NONE
) {
1301 space
= map
->bp_space
;
1303 offset
-= pcibr_soft
->bs_slot
[cs
].bss_window
[cw
].bssw_base
;
1310 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR
, pcibr_soft
->bs_conn
,
1311 "pcibr_pioerror: offset=0x%x, slot=0x%x, func=0x%x\n",
1312 offset
, slot
, func
));
1314 if (space
!= PCIIO_SPACE_NONE
) {
1315 if (slot
!= PCIIO_SLOT_NONE
) {
1316 if (func
!= PCIIO_FUNC_NONE
) {
1317 IOERROR_SETVALUE(ioe
, widgetdev
,
1318 pciio_widgetdev_create(slot
,func
));
1321 IOERROR_SETVALUE(ioe
, widgetdev
,
1322 pciio_widgetdev_create(slot
,0));
1325 IOERROR_SETVALUE(ioe
, busspace
, space
);
1326 IOERROR_SETVALUE(ioe
, busaddr
, offset
);
1328 if (mode
== MODE_DEVPROBE
) {
1330 * During probing, we don't really care what the
1331 * error is. Clean up the error in Bridge, notify
1332 * subsidiary devices, and return success.
1334 pcibr_error_cleanup(pcibr_soft
, error_code
);
1336 /* if appropriate, give the error handler for this slot
1337 * a shot at this probe access as well.
1339 return (slot
== PCIIO_SLOT_NONE
) ? IOERROR_HANDLED
:
1340 pciio_error_handler(pcibr_vhdl
, error_code
, mode
, ioe
);
1343 * If we don't know what "PCI SPACE" the access
1344 * was targeting, we may have problems at the
1345 * Bridge itself. Don't touch any bridge registers,
1346 * and do complain loudly.
1349 if (space
== PCIIO_SPACE_NONE
) {
1350 printk("XIO Bus Error at %s\n"
1351 "\taccess to XIO bus offset 0x%lx\n"
1352 "\tdoes not correspond to any PCI address\n",
1353 pcibr_soft
->bs_name
, bad_xaddr
);
1355 /* caller will dump contents of ioe struct */
1356 return IOERROR_XTALKLEVEL
;
1360 * Actual PCI Error handling situation.
1361 * Typically happens when a user level process accesses
1362 * PCI space, and it causes some error.
1364 * Due to PCI Bridge implementation, we get two indication
1365 * for a read error: an interrupt and a Bus error.
1366 * We like to handle read error in the bus error context.
1367 * But the interrupt comes and goes before bus error
1368 * could make much progress. (NOTE: interrupd does
1369 * come in _after_ bus error processing starts. But it's
1370 * completed by the time bus error code reaches PCI PIO
1372 * Similarly write error results in just an interrupt,
1373 * and error handling has to be done at interrupt level.
1374 * There is no way to distinguish at interrupt time, if an
1375 * error interrupt is due to read/write error..
1378 /* We know the xtalk addr, the raw PCI bus space,
1379 * the raw PCI bus address, the decoded PCI bus
1380 * space, the offset within that space, and the
1381 * decoded PCI slot (which may be "PCIIO_SLOT_NONE" if no slot
1382 * is known to be involved).
1386 * Hand the error off to the handler registered
1387 * for the slot that should have decoded the error,
1388 * or to generic PCI handling (if pciio decides that
1389 * such is appropriate).
1391 retval
= pciio_error_handler(pcibr_vhdl
, error_code
, mode
, ioe
);
1393 if (retval
!= IOERROR_HANDLED
) {
1395 /* Generate a generic message for IOERROR_UNHANDLED
1396 * since the subsidiary handlers were silent, and
1399 if (retval
== IOERROR_UNHANDLED
) {
1400 retval
= IOERROR_PANIC
;
1402 /* we may or may not want to print some of this,
1403 * depending on debug level and which error code.
1407 "PIO Error on PCI Bus %s",
1408 pcibr_soft
->bs_name
);
1409 /* this decodes part of the ioe; our caller
1410 * will dump the raw details in DEBUG and
1415 #if defined(FORCE_ERRORS)
1421 * Dump raw data from Bridge/PCI layer.
1424 BEM_ADD_STR("Raw info from Bridge/PCI layer:\n");
1425 if (IS_PIC_SOFT(pcibr_soft
)) {
1426 if (bridge
->p_int_status_64
& (picreg_t
)BRIDGE_ISR_PCIBUS_PIOERR
)
1427 pcibr_error_dump(pcibr_soft
);
1429 if (bridge
->b_int_status
& (bridgereg_t
)BRIDGE_ISR_PCIBUS_PIOERR
)
1430 pcibr_error_dump(pcibr_soft
);
1432 BEM_ADD_SPC(raw_space
);
1433 BEM_ADD_VAR(raw_paddr
);
1434 if (IOERROR_FIELDVALID(ioe
, widgetdev
)) {
1436 IOERROR_GETVALUE(widdev
, ioe
, widgetdev
);
1437 slot
= pciio_widgetdev_slot_get(widdev
);
1438 func
= pciio_widgetdev_func_get(widdev
);
1439 if (slot
< PCIBR_NUM_SLOTS(pcibr_soft
)) {
1440 bridgereg_t device
= bridge
->b_device
[slot
].reg
;
1444 BEM_ADD_REG(device
);
1447 #if !DEBUG || defined(FORCE_ERRORS)
1452 * Since error could not be handled at lower level,
1453 * error data logged has not been cleared.
1454 * Clean up errors, and
1455 * re-enable bridge to interrupt on error conditions.
1456 * NOTE: Wheather we get the interrupt on PCI_ABORT or not is
1457 * dependent on INT_ENABLE register. This write just makes sure
1458 * that if the interrupt was enabled, we do get the interrupt.
1460 * CAUTION: Resetting bit BRIDGE_IRR_PCI_GRP_CLR, acknowledges
1461 * a group of interrupts. If while handling this error,
1462 * some other error has occurred, that would be
1463 * implicitly cleared by this write.
1464 * Need a way to ensure we don't inadvertently clear some
1467 if (IOERROR_FIELDVALID(ioe
, widgetdev
)) {
1469 IOERROR_GETVALUE(widdev
, ioe
, widgetdev
);
1470 pcibr_device_disable(pcibr_soft
,
1471 pciio_widgetdev_slot_get(widdev
));
1473 if (mode
== MODE_DEVUSERERROR
)
1474 pcibr_error_cleanup(pcibr_soft
, error_code
);
1481 * Some error was identified in a DMA transaction.
1482 * This routine will identify the <device, address> that caused the error,
1483 * and try to invoke the appropriate bus service to handle this.
1488 pcibr_soft_t pcibr_soft
,
1490 ioerror_mode_t mode
,
1493 vertex_hdl_t pcibr_vhdl
= pcibr_soft
->bs_vhdl
;
1494 bridge_t
*bridge
= pcibr_soft
->bs_base
;
1495 bridgereg_t bus_lowaddr
, bus_uppraddr
;
1500 * In case of DMA errors, bridge should have logged the
1501 * address that caused the error.
1502 * Look up the address, in the bridge error registers, and
1503 * take appropriate action
1507 IOERROR_GETVALUE(tmp
, ioe
, widgetnum
);
1508 ASSERT(tmp
== pcibr_soft
->bs_xid
);
1513 * read error log registers
1515 bus_lowaddr
= bridge
->b_wid_resp_lower
;
1516 bus_uppraddr
= bridge
->b_wid_resp_upper
;
1518 bufnum
= BRIDGE_RESP_ERRUPPR_BUFNUM(bus_uppraddr
);
1519 IOERROR_SETVALUE(ioe
, widgetdev
,
1520 pciio_widgetdev_create(
1521 BRIDGE_RESP_ERRUPPR_DEVICE(bus_uppraddr
),
1523 IOERROR_SETVALUE(ioe
, busaddr
,
1527 BRIDGE_ERRUPPR_ADDRMASK
) << 32)));
1530 * need to ensure that the xtalk address in ioe
1531 * maps to PCI error address read from bridge.
1532 * How to convert PCI address back to Xtalk address ?
1533 * (better idea: convert XTalk address to PCI address
1534 * and then do the compare!)
1537 retval
= pciio_error_handler(pcibr_vhdl
, error_code
, mode
, ioe
);
1538 if (retval
!= IOERROR_HANDLED
) {
1540 IOERROR_GETVALUE(tmp
, ioe
, widgetdev
);
1541 pcibr_device_disable(pcibr_soft
, pciio_widgetdev_slot_get(tmp
));
1545 * Re-enable bridge to interrupt on BRIDGE_IRR_RESP_BUF_GRP_CLR
1546 * NOTE: Wheather we get the interrupt on BRIDGE_IRR_RESP_BUF_GRP_CLR or
1547 * not is dependent on INT_ENABLE register. This write just makes sure
1548 * that if the interrupt was enabled, we do get the interrupt.
1550 bridge
->b_int_rst_stat
= BRIDGE_IRR_RESP_BUF_GRP_CLR
;
1553 * Also, release the "bufnum" back to buffer pool that could be re-used.
1554 * This is done by "disabling" the buffer for a moment, then restoring
1555 * the original assignment.
1564 ? &bridge
->b_odd_resp
1565 : &bridge
->b_even_resp
;
1567 mask
= 0xF << ((bufnum
>> 1) * 4);
1570 *regp
= regv
& ~mask
;
1578 * pcibr_dmawr_error:
1579 * Handle a dma write error caused by a device attached to this bridge.
1581 * ioe has the widgetnum, widgetdev, and memaddr fields updated
1582 * But we don't know the PCI address that corresponds to "memaddr"
1583 * nor do we know which device driver is generating this address.
1585 * There is no easy way to find out the PCI address(es) that map
1586 * to a specific system memory address. Bus handling code is also
1587 * of not much help, since they don't keep track of the DMA mapping
1588 * that have been handed out.
1589 * So it's a dead-end at this time.
1591 * If translation is available, we could invoke the error handling
1592 * interface of the device driver.
1597 pcibr_soft_t pcibr_soft
,
1599 ioerror_mode_t mode
,
1602 vertex_hdl_t pcibr_vhdl
= pcibr_soft
->bs_vhdl
;
1605 retval
= pciio_error_handler(pcibr_vhdl
, error_code
, mode
, ioe
);
1607 if (retval
!= IOERROR_HANDLED
) {
1610 IOERROR_GETVALUE(tmp
, ioe
, widgetdev
);
1611 pcibr_device_disable(pcibr_soft
, pciio_widgetdev_slot_get(tmp
));
1617 * Bridge error handler.
1618 * Interface to handle all errors that involve bridge in some way.
1620 * This normally gets called from xtalk error handler.
1621 * ioe has different set of fields set depending on the error that
1622 * was encountered. So, we have a bit field indicating which of the
1625 * NOTE: This routine could be operating in interrupt context. So,
1626 * don't try to sleep here (till interrupt threads work!!)
1629 pcibr_error_handler(
1630 error_handler_arg_t einfo
,
1632 ioerror_mode_t mode
,
1635 pcibr_soft_t pcibr_soft
;
1636 int retval
= IOERROR_BADERRORCODE
;
1638 pcibr_soft
= (pcibr_soft_t
) einfo
;
1640 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR
, pcibr_soft
->bs_conn
,
1641 "pcibr_error_handler: pcibr_soft=0x%x, error_code=0x%x\n",
1642 pcibr_soft
, error_code
));
1644 #if DEBUG && ERROR_DEBUG
1645 printk( "%s: pcibr_error_handler\n", pcibr_soft
->bs_name
);
1648 ASSERT(pcibr_soft
!= NULL
);
1650 if (error_code
& IOECODE_PIO
)
1651 retval
= pcibr_pioerror(pcibr_soft
, error_code
, mode
, ioe
);
1653 if (error_code
& IOECODE_DMA
) {
1654 if (error_code
& IOECODE_READ
) {
1656 * DMA read error occurs when a device attached to the bridge
1657 * tries to read some data from system memory, and this
1658 * either results in a timeout or access error.
1659 * First case is indicated by the bit "XREAD_REQ_TOUT"
1660 * and second case by "RESP_XTALK_ERROR" bit in bridge error
1661 * interrupt status register.
1663 * pcibr_error_intr_handler would get invoked first, and it has
1664 * the responsibility of calling pcibr_error_handler with
1665 * suitable parameters.
1668 retval
= pcibr_dmard_error(pcibr_soft
, error_code
, MODE_DEVERROR
, ioe
);
1670 if (error_code
& IOECODE_WRITE
) {
1672 * A device attached to this bridge has been generating
1673 * bad DMA writes. Find out the device attached, and
1674 * slap on it's wrist.
1677 retval
= pcibr_dmawr_error(pcibr_soft
, error_code
, MODE_DEVERROR
, ioe
);
1685 * PIC has 2 busses under a single widget so pcibr_attach2 registers this
1686 * wrapper function rather than pcibr_error_handler() for PIC. It's upto
1687 * this wrapper to call pcibr_error_handler() with the correct pcibr_soft
1688 * struct (ie. the pcibr_soft struct for the bus that saw the error).
1690 * NOTE: this wrapper function is only registered for PIC ASICs and will
1691 * only be called for a PIC
1694 pcibr_error_handler_wrapper(
1695 error_handler_arg_t einfo
,
1697 ioerror_mode_t mode
,
1700 pcibr_soft_t pcibr_soft
= (pcibr_soft_t
) einfo
;
1701 int pio_retval
= -1;
1702 int dma_retval
= -1;
1704 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR
, pcibr_soft
->bs_conn
,
1705 "pcibr_error_handler_wrapper: pcibr_soft=0x%x, "
1706 "error_code=0x%x\n", pcibr_soft
, error_code
));
1709 * It is possible that both a IOECODE_PIO and a IOECODE_DMA, and both
1710 * IOECODE_READ and IOECODE_WRITE could be set in error_code so we must
1711 * process all. Since we are a wrapper for pcibr_error_handler(), and
1712 * will be calling it several times within this routine, we turn off the
1713 * error_code bits we don't want it to be processing during that call.
1716 * If the error was a result of a PIO, we tell what bus on the PIC saw
1717 * the error from the PIO address.
1720 if (error_code
& IOECODE_PIO
) {
1721 iopaddr_t bad_xaddr
;
1723 * PIC bus0 PIO space 0x000000 - 0x7fffff or 0x40000000 - 0xbfffffff
1724 * bus1 PIO space 0x800000 - 0xffffff or 0xc0000000 - 0x13fffffff
1726 IOERROR_GETVALUE(bad_xaddr
, ioe
, xtalkaddr
);
1727 if ((bad_xaddr
<= 0x7fffff) ||
1728 ((bad_xaddr
>= 0x40000000) && (bad_xaddr
<= 0xbfffffff))) {
1729 /* bus 0 saw the error */
1730 pio_retval
= pcibr_error_handler((error_handler_arg_t
)pcibr_soft
,
1731 (error_code
& ~IOECODE_DMA
), mode
, ioe
);
1732 } else if (((bad_xaddr
>= 0x800000) && (bad_xaddr
<= 0xffffff)) ||
1733 ((bad_xaddr
>= 0xc0000000) && (bad_xaddr
<= 0x13fffffff))) {
1734 /* bus 1 saw the error */
1735 pcibr_soft
= pcibr_soft
->bs_peers_soft
;
1738 printk(KERN_WARNING
"pcibr_error_handler: "
1739 "bs_peers_soft==NULL. bad_xaddr= 0x%x mode= 0x%x\n",
1742 pio_retval
= IOERROR_HANDLED
;
1744 pio_retval
= pcibr_error_handler((error_handler_arg_t
)pcibr_soft
,
1745 (error_code
& ~IOECODE_DMA
), mode
, ioe
);
1747 printk(KERN_WARNING
"pcibr_error_handler_wrapper(): IOECODE_PIO: "
1748 "saw an invalid pio address: 0x%lx\n", bad_xaddr
);
1749 pio_retval
= IOERROR_UNHANDLED
;
1754 * If the error was a result of a DMA Write, we tell what bus on the PIC
1755 * saw the error by looking at tnum.
1757 if ((error_code
& IOECODE_DMA
) && (error_code
& IOECODE_WRITE
)) {
1760 * For DMA writes [X]Bridge encodes the TNUM field of a Xtalk
1766 * BUT PIC needs the bus number so it does this:
1772 * Pull out the bus number from `tnum' and reset the `widgetdev'
1773 * since when hubiio_crb_error_handler() set `widgetdev' it had
1774 * no idea if it was a PIC or a BRIDGE ASIC so it set it based
1777 IOERROR_GETVALUE(tmp
, ioe
, tnum
);
1778 IOERROR_SETVALUE(ioe
, widgetdev
, (tmp
& 0x3));
1779 if ((tmp
& 0x4) == 0) {
1780 /* bus 0 saw the error. */
1781 dma_retval
= pcibr_error_handler((error_handler_arg_t
)pcibr_soft
,
1782 (error_code
& ~(IOECODE_PIO
|IOECODE_READ
)), mode
, ioe
);
1784 /* bus 1 saw the error */
1785 pcibr_soft
= pcibr_soft
->bs_peers_soft
;
1786 dma_retval
= pcibr_error_handler((error_handler_arg_t
)pcibr_soft
,
1787 (error_code
& ~(IOECODE_PIO
|IOECODE_READ
)), mode
, ioe
);
1792 * If the error was a result of a DMA READ, XXX ???
1794 if ((error_code
& IOECODE_DMA
) && (error_code
& IOECODE_READ
)) {
1796 * A DMA Read error will result in a BRIDGE_ISR_RESP_XTLK_ERR
1797 * or BRIDGE_ISR_BAD_XRESP_PKT bridge error interrupt which
1798 * are fatal interrupts (ie. BRIDGE_ISR_ERROR_FATAL) causing
1799 * pcibr_error_intr_handler() to panic the system. So is the
1800 * error handler even going to get called??? It appears that
1801 * the pcibr_dmard_error() attempts to clear the interrupts
1802 * so pcibr_error_intr_handler() won't see them, but there
1803 * appears to be nothing to prevent pcibr_error_intr_handler()
1804 * from running before pcibr_dmard_error() has a chance to
1805 * clear the interrupt.
1807 * Since we'll be panicing anyways, don't bother handling the
1808 * error for now until we can fix this race condition mentioned
1811 dma_retval
= IOERROR_UNHANDLED
;
1814 /* XXX: pcibr_error_handler() should probably do the same thing, it over-
1815 * write it's return value as it processes the different "error_code"s.
1817 if ((pio_retval
== -1) && (dma_retval
== -1)) {
1818 return IOERROR_BADERRORCODE
;
1819 } else if (dma_retval
!= IOERROR_HANDLED
) {
1821 } else if (pio_retval
!= IOERROR_HANDLED
) {
1824 return IOERROR_HANDLED
;