17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
500d0963fSdilpreet * Common Development and Distribution License (the "License").
600d0963fSdilpreet * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
2200d0963fSdilpreet * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
26*1f4c6dbcSPeter Tribble /*
27*1f4c6dbcSPeter Tribble * Copyright 2019 Peter Tribble.
28*1f4c6dbcSPeter Tribble */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate * PCI PBM implementation:
327c478bd9Sstevel@tonic-gate * initialization
337c478bd9Sstevel@tonic-gate * Bus error interrupt handler
347c478bd9Sstevel@tonic-gate */
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
387c478bd9Sstevel@tonic-gate #include <sys/spl.h>
397c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
407c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
417c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h>
427c478bd9Sstevel@tonic-gate #include <sys/fm/util.h>
437c478bd9Sstevel@tonic-gate #include <sys/machsystm.h> /* ldphysio() */
447c478bd9Sstevel@tonic-gate #include <sys/async.h>
457c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
467c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
477c478bd9Sstevel@tonic-gate #include <sys/pci/pci_obj.h>
487c478bd9Sstevel@tonic-gate #include <sys/membar.h>
497c478bd9Sstevel@tonic-gate #include <sys/ivintr.h>
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate static uint_t pbm_error_intr(caddr_t a);
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate /* The nexus interrupt priority values */
567c478bd9Sstevel@tonic-gate int pci_pil[] = {14, 14, 14, 14, 14, 14};
577c478bd9Sstevel@tonic-gate void
pbm_create(pci_t * pci_p)587c478bd9Sstevel@tonic-gate pbm_create(pci_t *pci_p)
597c478bd9Sstevel@tonic-gate {
607c478bd9Sstevel@tonic-gate pbm_t *pbm_p;
617c478bd9Sstevel@tonic-gate int i, len;
627c478bd9Sstevel@tonic-gate int nrange = pci_p->pci_ranges_length / sizeof (pci_ranges_t);
637c478bd9Sstevel@tonic-gate dev_info_t *dip = pci_p->pci_dip;
647c478bd9Sstevel@tonic-gate pci_ranges_t *rangep = pci_p->pci_ranges;
657c478bd9Sstevel@tonic-gate uint64_t base_addr, last_addr;
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate #ifdef lint
687c478bd9Sstevel@tonic-gate dip = dip;
697c478bd9Sstevel@tonic-gate #endif
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate * Allocate a state structure for the PBM and cross-link it
737c478bd9Sstevel@tonic-gate * to its per pci node state structure.
747c478bd9Sstevel@tonic-gate */
757c478bd9Sstevel@tonic-gate pbm_p = (pbm_t *)kmem_zalloc(sizeof (pbm_t), KM_SLEEP);
767c478bd9Sstevel@tonic-gate pci_p->pci_pbm_p = pbm_p;
777c478bd9Sstevel@tonic-gate pbm_p->pbm_pci_p = pci_p;
787c478bd9Sstevel@tonic-gate
797c478bd9Sstevel@tonic-gate len = snprintf(pbm_p->pbm_nameinst_str,
80*1f4c6dbcSPeter Tribble sizeof (pbm_p->pbm_nameinst_str),
81*1f4c6dbcSPeter Tribble "%s%d", NAMEINST(dip));
827c478bd9Sstevel@tonic-gate pbm_p->pbm_nameaddr_str = pbm_p->pbm_nameinst_str + ++len;
837c478bd9Sstevel@tonic-gate (void) snprintf(pbm_p->pbm_nameaddr_str,
84*1f4c6dbcSPeter Tribble sizeof (pbm_p->pbm_nameinst_str) - len,
85*1f4c6dbcSPeter Tribble "%s@%s", NAMEADDR(dip));
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gate pci_pbm_setup(pbm_p);
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate /*
907c478bd9Sstevel@tonic-gate * Get this pbm's mem32 and mem64 segments to determine whether
917c478bd9Sstevel@tonic-gate * a dma object originates from ths pbm. i.e. dev to dev dma
927c478bd9Sstevel@tonic-gate */
937c478bd9Sstevel@tonic-gate /* Init all of our boundaries */
947c478bd9Sstevel@tonic-gate base_addr = -1ull;
957c478bd9Sstevel@tonic-gate last_addr = 0ull;
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate for (i = 0; i < nrange; i++, rangep++) {
987c478bd9Sstevel@tonic-gate uint32_t rng_type = rangep->child_high & PCI_ADDR_MASK;
997c478bd9Sstevel@tonic-gate if (rng_type == PCI_ADDR_MEM32 || rng_type == PCI_ADDR_MEM64) {
1007c478bd9Sstevel@tonic-gate uint64_t rng_addr, rng_size;
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate rng_addr = (uint64_t)rangep->parent_high << 32;
1037c478bd9Sstevel@tonic-gate rng_addr |= (uint64_t)rangep->parent_low;
1047c478bd9Sstevel@tonic-gate rng_size = (uint64_t)rangep->size_high << 32;
1057c478bd9Sstevel@tonic-gate rng_size |= (uint64_t)rangep->size_low;
1067c478bd9Sstevel@tonic-gate base_addr = MIN(rng_addr, base_addr);
1077c478bd9Sstevel@tonic-gate last_addr = MAX(rng_addr + rng_size, last_addr);
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate }
1107c478bd9Sstevel@tonic-gate pbm_p->pbm_base_pfn = mmu_btop(base_addr);
1117c478bd9Sstevel@tonic-gate pbm_p->pbm_last_pfn = mmu_btop(last_addr);
1127c478bd9Sstevel@tonic-gate
1137c478bd9Sstevel@tonic-gate DEBUG4(DBG_ATTACH, dip,
114*1f4c6dbcSPeter Tribble "pbm_create: ctrl=%x, afsr=%x, afar=%x, diag=%x\n",
115*1f4c6dbcSPeter Tribble pbm_p->pbm_ctrl_reg, pbm_p->pbm_async_flt_status_reg,
116*1f4c6dbcSPeter Tribble pbm_p->pbm_async_flt_addr_reg, pbm_p->pbm_diag_reg);
1177c478bd9Sstevel@tonic-gate DEBUG1(DBG_ATTACH, dip, "pbm_create: conf=%x\n",
118*1f4c6dbcSPeter Tribble pbm_p->pbm_config_header);
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gate /*
1217c478bd9Sstevel@tonic-gate * Register a function to disable pbm error interrupts during a panic.
1227c478bd9Sstevel@tonic-gate */
1237c478bd9Sstevel@tonic-gate bus_func_register(BF_TYPE_ERRDIS,
1247c478bd9Sstevel@tonic-gate (busfunc_t)pbm_disable_pci_errors, pbm_p);
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate * create the interrupt-priorities property if it doesn't
1287c478bd9Sstevel@tonic-gate * already exist to provide a hint as to the PIL level for
1297c478bd9Sstevel@tonic-gate * our interrupt.
1307c478bd9Sstevel@tonic-gate */
1317c478bd9Sstevel@tonic-gate if (ddi_getproplen(DDI_DEV_T_ANY, dip,
1327c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "interrupt-priorities",
1337c478bd9Sstevel@tonic-gate &len) != DDI_PROP_SUCCESS) {
1347c478bd9Sstevel@tonic-gate /* Create the interrupt-priorities property. */
1357c478bd9Sstevel@tonic-gate (void) ddi_prop_create(DDI_DEV_T_NONE, dip,
1367c478bd9Sstevel@tonic-gate DDI_PROP_CANSLEEP, "interrupt-priorities",
1377c478bd9Sstevel@tonic-gate (caddr_t)pci_pil, sizeof (pci_pil));
1387c478bd9Sstevel@tonic-gate }
1397c478bd9Sstevel@tonic-gate
1407c478bd9Sstevel@tonic-gate pbm_configure(pbm_p);
1417c478bd9Sstevel@tonic-gate }
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate int
pbm_register_intr(pbm_t * pbm_p)1447c478bd9Sstevel@tonic-gate pbm_register_intr(pbm_t *pbm_p)
1457c478bd9Sstevel@tonic-gate {
1467c478bd9Sstevel@tonic-gate pci_t *pci_p = pbm_p->pbm_pci_p;
1477c478bd9Sstevel@tonic-gate uint32_t mondo;
1487c478bd9Sstevel@tonic-gate int r = DDI_SUCCESS;
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate ib_nintr_clear(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate * Install the PCI error interrupt handler.
1547c478bd9Sstevel@tonic-gate */
1557c478bd9Sstevel@tonic-gate mondo = IB_INO_TO_MONDO(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
1567c478bd9Sstevel@tonic-gate mondo = CB_MONDO_TO_XMONDO(pci_p->pci_cb_p, mondo);
1577c478bd9Sstevel@tonic-gate
158b0fc0e77Sgovinda VERIFY(add_ivintr(mondo, pci_pil[CBNINTR_PBM], (intrfunc)pbm_error_intr,
159b0fc0e77Sgovinda (caddr_t)pci_p, NULL, NULL) == 0);
1607c478bd9Sstevel@tonic-gate
161f47a9c50Smathue pbm_p->pbm_iblock_cookie = (void *)(uintptr_t)pci_pil[CBNINTR_PBM];
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate * Create the pokefault mutex at the PIL below the error interrupt.
1657c478bd9Sstevel@tonic-gate */
1667c478bd9Sstevel@tonic-gate mutex_init(&pbm_p->pbm_pokefault_mutex, NULL, MUTEX_DRIVER,
167f47a9c50Smathue (void *)(uintptr_t)ipltospl(spltoipl(
168f47a9c50Smathue (int)(uintptr_t)pbm_p->pbm_iblock_cookie) - 1));
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate if (!r)
1717c478bd9Sstevel@tonic-gate r = pci_pbm_add_intr(pci_p);
1727c478bd9Sstevel@tonic-gate return (PCI_ATTACH_RETCODE(PCI_PBM_OBJ, PCI_OBJ_INTR_ADD, r));
1737c478bd9Sstevel@tonic-gate }
1747c478bd9Sstevel@tonic-gate
1757c478bd9Sstevel@tonic-gate void
pbm_destroy(pci_t * pci_p)1767c478bd9Sstevel@tonic-gate pbm_destroy(pci_t *pci_p)
1777c478bd9Sstevel@tonic-gate {
1787c478bd9Sstevel@tonic-gate pbm_t *pbm_p = pci_p->pci_pbm_p;
1797c478bd9Sstevel@tonic-gate ib_t *ib_p = pci_p->pci_ib_p;
1807c478bd9Sstevel@tonic-gate uint32_t mondo;
1817c478bd9Sstevel@tonic-gate
1827c478bd9Sstevel@tonic-gate DEBUG0(DBG_DETACH, pci_p->pci_dip, "pbm_destroy:\n");
1837c478bd9Sstevel@tonic-gate
1847c478bd9Sstevel@tonic-gate mondo = IB_INO_TO_MONDO(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
1857c478bd9Sstevel@tonic-gate mondo = CB_MONDO_TO_XMONDO(pci_p->pci_cb_p, mondo);
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate /*
1887c478bd9Sstevel@tonic-gate * Free the pokefault mutex.
1897c478bd9Sstevel@tonic-gate */
1907c478bd9Sstevel@tonic-gate mutex_destroy(&pbm_p->pbm_pokefault_mutex);
1917c478bd9Sstevel@tonic-gate
1927c478bd9Sstevel@tonic-gate /*
1937c478bd9Sstevel@tonic-gate * Remove the error interrupt and consistent dma sync handler.
1947c478bd9Sstevel@tonic-gate */
1957c478bd9Sstevel@tonic-gate intr_dist_rem(pbm_intr_dist, pbm_p);
1967c478bd9Sstevel@tonic-gate pci_pbm_rem_intr(pci_p);
1977c478bd9Sstevel@tonic-gate ib_intr_disable(ib_p, pci_p->pci_inos[CBNINTR_PBM], IB_INTR_WAIT);
198b0fc0e77Sgovinda VERIFY(rem_ivintr(mondo, pci_pil[CBNINTR_PBM]) == 0);
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate * Remove the error disable function.
2027c478bd9Sstevel@tonic-gate */
2037c478bd9Sstevel@tonic-gate bus_func_unregister(BF_TYPE_ERRDIS,
2047c478bd9Sstevel@tonic-gate (busfunc_t)pbm_disable_pci_errors, pbm_p);
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate pci_pbm_teardown(pbm_p);
2077c478bd9Sstevel@tonic-gate
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate * Free the pbm state structure.
2107c478bd9Sstevel@tonic-gate */
2117c478bd9Sstevel@tonic-gate kmem_free(pbm_p, sizeof (pbm_t));
2127c478bd9Sstevel@tonic-gate pci_p->pci_pbm_p = NULL;
2137c478bd9Sstevel@tonic-gate }
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gate static uint_t
pbm_error_intr(caddr_t a)2167c478bd9Sstevel@tonic-gate pbm_error_intr(caddr_t a)
2177c478bd9Sstevel@tonic-gate {
2187c478bd9Sstevel@tonic-gate pci_t *pci_p = (pci_t *)a;
2197c478bd9Sstevel@tonic-gate pbm_t *pbm_p = pci_p->pci_pbm_p;
2207c478bd9Sstevel@tonic-gate ddi_fm_error_t derr;
2217c478bd9Sstevel@tonic-gate int err = DDI_FM_OK;
2227c478bd9Sstevel@tonic-gate on_trap_data_t *otp = pbm_p->pbm_ontrap_data;
2237c478bd9Sstevel@tonic-gate
2247c478bd9Sstevel@tonic-gate bzero(&derr, sizeof (ddi_fm_error_t));
2257c478bd9Sstevel@tonic-gate derr.fme_version = DDI_FME_VERSION;
2267c478bd9Sstevel@tonic-gate mutex_enter(&pci_p->pci_common_p->pci_fm_mutex);
2274fd7ecabSdilpreet if (pbm_p->pbm_excl_handle != NULL) {
2287c478bd9Sstevel@tonic-gate /*
2297c478bd9Sstevel@tonic-gate * cautious write protection, protected from all errors.
2307c478bd9Sstevel@tonic-gate */
2317c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&pbm_p->pbm_pokefault_mutex));
2327c478bd9Sstevel@tonic-gate ddi_fm_acc_err_get(pbm_p->pbm_excl_handle, &derr,
233*1f4c6dbcSPeter Tribble DDI_FME_VERSION);
2344fd7ecabSdilpreet ASSERT(derr.fme_flag == DDI_FM_ERR_EXPECTED);
2357c478bd9Sstevel@tonic-gate derr.fme_acc_handle = pbm_p->pbm_excl_handle;
2364fd7ecabSdilpreet err = pci_pbm_err_handler(pci_p->pci_dip, &derr, (void *)pci_p,
2374fd7ecabSdilpreet PCI_INTR_CALL);
2384fd7ecabSdilpreet } else if ((otp != NULL) && (otp->ot_prot & OT_DATA_ACCESS)) {
2394fd7ecabSdilpreet /*
2404fd7ecabSdilpreet * ddi_poke protection, check nexus and children for
2414fd7ecabSdilpreet * expected errors.
2424fd7ecabSdilpreet */
2434fd7ecabSdilpreet otp->ot_trap |= OT_DATA_ACCESS;
2444fd7ecabSdilpreet membar_sync();
2454fd7ecabSdilpreet derr.fme_flag = DDI_FM_ERR_POKE;
2467c478bd9Sstevel@tonic-gate err = pci_pbm_err_handler(pci_p->pci_dip, &derr, (void *)pci_p,
247*1f4c6dbcSPeter Tribble PCI_INTR_CALL);
2487c478bd9Sstevel@tonic-gate } else if (pci_check_error(pci_p) != 0) {
2497c478bd9Sstevel@tonic-gate /*
2507c478bd9Sstevel@tonic-gate * unprotected error, check for all errors.
2517c478bd9Sstevel@tonic-gate */
2527c478bd9Sstevel@tonic-gate if (pci_errtrig_pa)
2537c478bd9Sstevel@tonic-gate (void) ldphysio(pci_errtrig_pa);
2547c478bd9Sstevel@tonic-gate derr.fme_flag = DDI_FM_ERR_UNEXPECTED;
2557c478bd9Sstevel@tonic-gate err = pci_pbm_err_handler(pci_p->pci_dip, &derr, (void *)pci_p,
256*1f4c6dbcSPeter Tribble PCI_INTR_CALL);
2577c478bd9Sstevel@tonic-gate }
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate if (err == DDI_FM_FATAL) {
2607c478bd9Sstevel@tonic-gate if (pci_panic_on_fatal_errors) {
2617c478bd9Sstevel@tonic-gate mutex_exit(&pci_p->pci_common_p->pci_fm_mutex);
2627c478bd9Sstevel@tonic-gate fm_panic("%s-%d: Fatal PCI bus error(s)\n",
263*1f4c6dbcSPeter Tribble ddi_driver_name(pci_p->pci_dip),
264*1f4c6dbcSPeter Tribble ddi_get_instance(pci_p->pci_dip));
2657c478bd9Sstevel@tonic-gate }
2667c478bd9Sstevel@tonic-gate }
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate mutex_exit(&pci_p->pci_common_p->pci_fm_mutex);
2697c478bd9Sstevel@tonic-gate ib_nintr_clear(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
2707c478bd9Sstevel@tonic-gate return (DDI_INTR_CLAIMED);
2717c478bd9Sstevel@tonic-gate }
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate void
pbm_suspend(pbm_t * pbm_p)2747c478bd9Sstevel@tonic-gate pbm_suspend(pbm_t *pbm_p)
2757c478bd9Sstevel@tonic-gate {
2767c478bd9Sstevel@tonic-gate pci_t *pci_p = pbm_p->pbm_pci_p;
2777c478bd9Sstevel@tonic-gate ib_ino_t ino = pci_p->pci_inos[CBNINTR_PBM];
2787c478bd9Sstevel@tonic-gate pbm_p->pbm_imr_save = *ib_intr_map_reg_addr(pci_p->pci_ib_p, ino);
2797c478bd9Sstevel@tonic-gate
2807c478bd9Sstevel@tonic-gate pci_pbm_suspend(pci_p);
2817c478bd9Sstevel@tonic-gate }
2827c478bd9Sstevel@tonic-gate
2837c478bd9Sstevel@tonic-gate void
pbm_resume(pbm_t * pbm_p)2847c478bd9Sstevel@tonic-gate pbm_resume(pbm_t *pbm_p)
2857c478bd9Sstevel@tonic-gate {
2867c478bd9Sstevel@tonic-gate pci_t *pci_p = pbm_p->pbm_pci_p;
2877c478bd9Sstevel@tonic-gate ib_ino_t ino = pci_p->pci_inos[CBNINTR_PBM];
2887c478bd9Sstevel@tonic-gate
2897c478bd9Sstevel@tonic-gate ib_nintr_clear(pci_p->pci_ib_p, ino);
2907c478bd9Sstevel@tonic-gate *ib_intr_map_reg_addr(pci_p->pci_ib_p, ino) = pbm_p->pbm_imr_save;
2917c478bd9Sstevel@tonic-gate
2927c478bd9Sstevel@tonic-gate pci_pbm_resume(pci_p);
2937c478bd9Sstevel@tonic-gate }
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate void
pbm_intr_dist(void * arg)2967c478bd9Sstevel@tonic-gate pbm_intr_dist(void *arg)
2977c478bd9Sstevel@tonic-gate {
2987c478bd9Sstevel@tonic-gate pbm_t *pbm_p = (pbm_t *)arg;
2997c478bd9Sstevel@tonic-gate pci_t *pci_p = pbm_p->pbm_pci_p;
3007c478bd9Sstevel@tonic-gate ib_t *ib_p = pci_p->pci_ib_p;
3017c478bd9Sstevel@tonic-gate ib_ino_t ino = IB_MONDO_TO_INO(pci_p->pci_inos[CBNINTR_PBM]);
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate mutex_enter(&ib_p->ib_intr_lock);
3047c478bd9Sstevel@tonic-gate ib_intr_dist_nintr(ib_p, ino, ib_intr_map_reg_addr(ib_p, ino));
3057c478bd9Sstevel@tonic-gate pci_pbm_intr_dist(pbm_p);
3067c478bd9Sstevel@tonic-gate mutex_exit(&ib_p->ib_intr_lock);
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate * Function used to log PBM AFSR register bits and to lookup and fault
3117c478bd9Sstevel@tonic-gate * handle associated with PBM AFAR register. Called by pci_pbm_err_handler with
3127c478bd9Sstevel@tonic-gate * pci_fm_mutex held.
3137c478bd9Sstevel@tonic-gate */
3147c478bd9Sstevel@tonic-gate int
pbm_afsr_report(dev_info_t * dip,uint64_t fme_ena,pbm_errstate_t * pbm_err_p)3157c478bd9Sstevel@tonic-gate pbm_afsr_report(dev_info_t *dip, uint64_t fme_ena, pbm_errstate_t *pbm_err_p)
3167c478bd9Sstevel@tonic-gate {
3177c478bd9Sstevel@tonic-gate int fatal = 0;
3187c478bd9Sstevel@tonic-gate int ret = 0;
3197c478bd9Sstevel@tonic-gate pci_t *pci_p = get_pci_soft_state(ddi_get_instance(dip));
3207c478bd9Sstevel@tonic-gate pci_common_t *cmn_p = pci_p->pci_common_p;
3217c478bd9Sstevel@tonic-gate
3227c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&cmn_p->pci_fm_mutex));
3237c478bd9Sstevel@tonic-gate
3247c478bd9Sstevel@tonic-gate pbm_err_p->pbm_pri = PBM_PRIMARY;
3257c478bd9Sstevel@tonic-gate (void) pci_pbm_classify(pbm_err_p);
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate pci_format_addr(dip, &pbm_err_p->pbm_pci.pci_pa, pbm_err_p->pbm_afsr);
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate if (pbm_err_p->pbm_log == FM_LOG_PBM)
3307c478bd9Sstevel@tonic-gate pbm_ereport_post(dip, fme_ena, pbm_err_p);
3317c478bd9Sstevel@tonic-gate
3327c478bd9Sstevel@tonic-gate /*
3337c478bd9Sstevel@tonic-gate * Lookup and fault errant handle
3347c478bd9Sstevel@tonic-gate */
33500d0963fSdilpreet if (((ret = ndi_fmc_error(dip, NULL, ACC_HANDLE, fme_ena,
33600d0963fSdilpreet (void *)&pbm_err_p->pbm_pci.pci_pa)) == DDI_FM_FATAL) ||
33700d0963fSdilpreet (ret == DDI_FM_UNKNOWN))
3387c478bd9Sstevel@tonic-gate fatal++;
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate /*
3417c478bd9Sstevel@tonic-gate * queue target ereport if appropriate
3427c478bd9Sstevel@tonic-gate */
34300d0963fSdilpreet if (pbm_err_p->pbm_terr_class)
34400d0963fSdilpreet pci_target_enqueue(fme_ena, pbm_err_p->pbm_terr_class,
34500d0963fSdilpreet (pbm_err_p->pbm_log == FM_LOG_PCI) ? "pci" :
34600d0963fSdilpreet pbm_err_p->pbm_bridge_type, pbm_err_p->pbm_pci.pci_pa);
3477c478bd9Sstevel@tonic-gate
3487c478bd9Sstevel@tonic-gate /*
3497c478bd9Sstevel@tonic-gate * We are currently not dealing with the multiple error
3507c478bd9Sstevel@tonic-gate * case, for any secondary errors we will panic.
3517c478bd9Sstevel@tonic-gate */
3527c478bd9Sstevel@tonic-gate pbm_err_p->pbm_pri = PBM_SECONDARY;
3537c478bd9Sstevel@tonic-gate if (pci_pbm_classify(pbm_err_p)) {
3547c478bd9Sstevel@tonic-gate fatal++;
3557c478bd9Sstevel@tonic-gate if (pbm_err_p->pbm_log == FM_LOG_PBM)
3567c478bd9Sstevel@tonic-gate pbm_ereport_post(dip, fme_ena, pbm_err_p);
3577c478bd9Sstevel@tonic-gate }
3587c478bd9Sstevel@tonic-gate
3597c478bd9Sstevel@tonic-gate if (fatal)
3607c478bd9Sstevel@tonic-gate return (DDI_FM_FATAL);
3617c478bd9Sstevel@tonic-gate
3627c478bd9Sstevel@tonic-gate return (DDI_FM_NONFATAL);
3637c478bd9Sstevel@tonic-gate }
364