xref: /onnv-gate/usr/src/uts/sun4u/io/pci/pci_pbm.c (revision 2973:55b674bffad9)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51865Sdilpreet  * Common Development and Distribution License (the "License").
61865Sdilpreet  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
221865Sdilpreet  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * PCI PBM implementation:
300Sstevel@tonic-gate  *	initialization
310Sstevel@tonic-gate  *	Bus error interrupt handler
320Sstevel@tonic-gate  */
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #include <sys/types.h>
350Sstevel@tonic-gate #include <sys/kmem.h>
360Sstevel@tonic-gate #include <sys/spl.h>
370Sstevel@tonic-gate #include <sys/sysmacros.h>
380Sstevel@tonic-gate #include <sys/sunddi.h>
390Sstevel@tonic-gate #include <sys/fm/protocol.h>
400Sstevel@tonic-gate #include <sys/fm/util.h>
410Sstevel@tonic-gate #include <sys/machsystm.h>	/* ldphysio() */
420Sstevel@tonic-gate #include <sys/async.h>
430Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
440Sstevel@tonic-gate #include <sys/ontrap.h>
450Sstevel@tonic-gate #include <sys/pci/pci_obj.h>
460Sstevel@tonic-gate #include <sys/membar.h>
470Sstevel@tonic-gate #include <sys/ivintr.h>
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /*LINTLIBRARY*/
500Sstevel@tonic-gate 
510Sstevel@tonic-gate static uint_t pbm_error_intr(caddr_t a);
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /* The nexus interrupt priority values */
540Sstevel@tonic-gate int pci_pil[] = {14, 14, 14, 14, 14, 14};
550Sstevel@tonic-gate void
pbm_create(pci_t * pci_p)560Sstevel@tonic-gate pbm_create(pci_t *pci_p)
570Sstevel@tonic-gate {
580Sstevel@tonic-gate 	pbm_t *pbm_p;
590Sstevel@tonic-gate 	int i, len;
600Sstevel@tonic-gate 	int nrange = pci_p->pci_ranges_length / sizeof (pci_ranges_t);
610Sstevel@tonic-gate 	dev_info_t *dip = pci_p->pci_dip;
620Sstevel@tonic-gate 	pci_ranges_t *rangep = pci_p->pci_ranges;
630Sstevel@tonic-gate 	uint64_t base_addr, last_addr;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate #ifdef lint
660Sstevel@tonic-gate 	dip = dip;
670Sstevel@tonic-gate #endif
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 	/*
700Sstevel@tonic-gate 	 * Allocate a state structure for the PBM and cross-link it
710Sstevel@tonic-gate 	 * to its per pci node state structure.
720Sstevel@tonic-gate 	 */
730Sstevel@tonic-gate 	pbm_p = (pbm_t *)kmem_zalloc(sizeof (pbm_t), KM_SLEEP);
740Sstevel@tonic-gate 	pci_p->pci_pbm_p = pbm_p;
750Sstevel@tonic-gate 	pbm_p->pbm_pci_p = pci_p;
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 	len = snprintf(pbm_p->pbm_nameinst_str,
780Sstevel@tonic-gate 		sizeof (pbm_p->pbm_nameinst_str),
790Sstevel@tonic-gate 		"%s%d", NAMEINST(dip));
800Sstevel@tonic-gate 	pbm_p->pbm_nameaddr_str = pbm_p->pbm_nameinst_str + ++len;
810Sstevel@tonic-gate 	(void) snprintf(pbm_p->pbm_nameaddr_str,
820Sstevel@tonic-gate 		sizeof (pbm_p->pbm_nameinst_str) - len,
830Sstevel@tonic-gate 		"%s@%s", NAMEADDR(dip));
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 	pci_pbm_setup(pbm_p);
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	/*
880Sstevel@tonic-gate 	 * Get this pbm's mem32 and mem64 segments to determine whether
890Sstevel@tonic-gate 	 * a dma object originates from ths pbm. i.e. dev to dev dma
900Sstevel@tonic-gate 	 */
910Sstevel@tonic-gate 	/* Init all of our boundaries */
920Sstevel@tonic-gate 	base_addr = -1ull;
930Sstevel@tonic-gate 	last_addr = 0ull;
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 	for (i = 0; i < nrange; i++, rangep++) {
960Sstevel@tonic-gate 		uint32_t rng_type = rangep->child_high & PCI_ADDR_MASK;
970Sstevel@tonic-gate 		if (rng_type == PCI_ADDR_MEM32 || rng_type == PCI_ADDR_MEM64) {
980Sstevel@tonic-gate 			uint64_t rng_addr, rng_size;
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate 			rng_addr = (uint64_t)rangep->parent_high << 32;
1010Sstevel@tonic-gate 			rng_addr |= (uint64_t)rangep->parent_low;
1020Sstevel@tonic-gate 			rng_size = (uint64_t)rangep->size_high << 32;
1030Sstevel@tonic-gate 			rng_size |= (uint64_t)rangep->size_low;
1040Sstevel@tonic-gate 			base_addr = MIN(rng_addr, base_addr);
1050Sstevel@tonic-gate 			last_addr = MAX(rng_addr + rng_size, last_addr);
1060Sstevel@tonic-gate 		}
1070Sstevel@tonic-gate 	}
1080Sstevel@tonic-gate 	pbm_p->pbm_base_pfn = mmu_btop(base_addr);
1090Sstevel@tonic-gate 	pbm_p->pbm_last_pfn = mmu_btop(last_addr);
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate 	DEBUG4(DBG_ATTACH, dip,
1120Sstevel@tonic-gate 		"pbm_create: ctrl=%x, afsr=%x, afar=%x, diag=%x\n",
1130Sstevel@tonic-gate 		pbm_p->pbm_ctrl_reg, pbm_p->pbm_async_flt_status_reg,
1140Sstevel@tonic-gate 		pbm_p->pbm_async_flt_addr_reg, pbm_p->pbm_diag_reg);
1150Sstevel@tonic-gate 	DEBUG1(DBG_ATTACH, dip, "pbm_create: conf=%x\n",
1160Sstevel@tonic-gate 		pbm_p->pbm_config_header);
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate 	/*
1190Sstevel@tonic-gate 	 * Register a function to disable pbm error interrupts during a panic.
1200Sstevel@tonic-gate 	 */
1210Sstevel@tonic-gate 	bus_func_register(BF_TYPE_ERRDIS,
1220Sstevel@tonic-gate 	    (busfunc_t)pbm_disable_pci_errors, pbm_p);
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate 	/*
1250Sstevel@tonic-gate 	 * create the interrupt-priorities property if it doesn't
1260Sstevel@tonic-gate 	 * already exist to provide a hint as to the PIL level for
1270Sstevel@tonic-gate 	 * our interrupt.
1280Sstevel@tonic-gate 	 */
1290Sstevel@tonic-gate 	if (ddi_getproplen(DDI_DEV_T_ANY, dip,
1300Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "interrupt-priorities",
1310Sstevel@tonic-gate 	    &len) != DDI_PROP_SUCCESS) {
1320Sstevel@tonic-gate 				/* Create the interrupt-priorities property. */
1330Sstevel@tonic-gate 		(void) ddi_prop_create(DDI_DEV_T_NONE, dip,
1340Sstevel@tonic-gate 		    DDI_PROP_CANSLEEP, "interrupt-priorities",
1350Sstevel@tonic-gate 		    (caddr_t)pci_pil, sizeof (pci_pil));
1360Sstevel@tonic-gate 	}
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate 	pbm_configure(pbm_p);
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate 	/*
1410Sstevel@tonic-gate 	 * Determine if we need to apply the Sun Fire 15k AXQ/PIO
1420Sstevel@tonic-gate 	 * workaround.
1430Sstevel@tonic-gate 	 */
1440Sstevel@tonic-gate 	pci_axq_pio_limit(pbm_p);
1450Sstevel@tonic-gate }
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate int
pbm_register_intr(pbm_t * pbm_p)1480Sstevel@tonic-gate pbm_register_intr(pbm_t *pbm_p)
1490Sstevel@tonic-gate {
1500Sstevel@tonic-gate 	pci_t		*pci_p = pbm_p->pbm_pci_p;
1510Sstevel@tonic-gate 	uint32_t	mondo;
1520Sstevel@tonic-gate 	int		r = DDI_SUCCESS;
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 	ib_nintr_clear(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate 	/*
1570Sstevel@tonic-gate 	 * Install the PCI error interrupt handler.
1580Sstevel@tonic-gate 	 */
1590Sstevel@tonic-gate 	mondo = IB_INO_TO_MONDO(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
1600Sstevel@tonic-gate 	mondo = CB_MONDO_TO_XMONDO(pci_p->pci_cb_p, mondo);
1610Sstevel@tonic-gate 
162*2973Sgovinda 	VERIFY(add_ivintr(mondo, pci_pil[CBNINTR_PBM], (intrfunc)pbm_error_intr,
163*2973Sgovinda 	    (caddr_t)pci_p, NULL, NULL) == 0);
1640Sstevel@tonic-gate 
165946Smathue 	pbm_p->pbm_iblock_cookie = (void *)(uintptr_t)pci_pil[CBNINTR_PBM];
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate 	/*
1680Sstevel@tonic-gate 	 * Create the pokefault mutex at the PIL below the error interrupt.
1690Sstevel@tonic-gate 	 */
1700Sstevel@tonic-gate 	mutex_init(&pbm_p->pbm_pokefault_mutex, NULL, MUTEX_DRIVER,
171946Smathue 	    (void *)(uintptr_t)ipltospl(spltoipl(
172946Smathue 	    (int)(uintptr_t)pbm_p->pbm_iblock_cookie) - 1));
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate 	if (!r)
1750Sstevel@tonic-gate 		r = pci_pbm_add_intr(pci_p);
1760Sstevel@tonic-gate 	return (PCI_ATTACH_RETCODE(PCI_PBM_OBJ, PCI_OBJ_INTR_ADD, r));
1770Sstevel@tonic-gate }
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate void
pbm_destroy(pci_t * pci_p)1800Sstevel@tonic-gate pbm_destroy(pci_t *pci_p)
1810Sstevel@tonic-gate {
1820Sstevel@tonic-gate 	pbm_t		*pbm_p = pci_p->pci_pbm_p;
1830Sstevel@tonic-gate 	ib_t		*ib_p = pci_p->pci_ib_p;
1840Sstevel@tonic-gate 	uint32_t	mondo;
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate 	DEBUG0(DBG_DETACH, pci_p->pci_dip, "pbm_destroy:\n");
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate 	mondo = IB_INO_TO_MONDO(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
1890Sstevel@tonic-gate 	mondo = CB_MONDO_TO_XMONDO(pci_p->pci_cb_p, mondo);
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate 	/*
1920Sstevel@tonic-gate 	 * Free the pokefault mutex.
1930Sstevel@tonic-gate 	 */
1940Sstevel@tonic-gate 	mutex_destroy(&pbm_p->pbm_pokefault_mutex);
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate 	/*
1970Sstevel@tonic-gate 	 * Remove the error interrupt and consistent dma sync handler.
1980Sstevel@tonic-gate 	 */
1990Sstevel@tonic-gate 	intr_dist_rem(pbm_intr_dist, pbm_p);
2000Sstevel@tonic-gate 	pci_pbm_rem_intr(pci_p);
2010Sstevel@tonic-gate 	ib_intr_disable(ib_p, pci_p->pci_inos[CBNINTR_PBM], IB_INTR_WAIT);
202*2973Sgovinda 	VERIFY(rem_ivintr(mondo, pci_pil[CBNINTR_PBM]) == 0);
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate 	/*
2050Sstevel@tonic-gate 	 * Remove the error disable function.
2060Sstevel@tonic-gate 	 */
2070Sstevel@tonic-gate 	bus_func_unregister(BF_TYPE_ERRDIS,
2080Sstevel@tonic-gate 	    (busfunc_t)pbm_disable_pci_errors, pbm_p);
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate 	pci_pbm_teardown(pbm_p);
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate 	/*
2130Sstevel@tonic-gate 	 * Free the pbm state structure.
2140Sstevel@tonic-gate 	 */
2150Sstevel@tonic-gate 	kmem_free(pbm_p, sizeof (pbm_t));
2160Sstevel@tonic-gate 	pci_p->pci_pbm_p = NULL;
2170Sstevel@tonic-gate }
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate static uint_t
pbm_error_intr(caddr_t a)2200Sstevel@tonic-gate pbm_error_intr(caddr_t a)
2210Sstevel@tonic-gate {
2220Sstevel@tonic-gate 	pci_t *pci_p = (pci_t *)a;
2230Sstevel@tonic-gate 	pbm_t *pbm_p = pci_p->pci_pbm_p;
2240Sstevel@tonic-gate 	ddi_fm_error_t derr;
2250Sstevel@tonic-gate 	int err = DDI_FM_OK;
2260Sstevel@tonic-gate 	on_trap_data_t *otp = pbm_p->pbm_ontrap_data;
2270Sstevel@tonic-gate 
2280Sstevel@tonic-gate 	bzero(&derr, sizeof (ddi_fm_error_t));
2290Sstevel@tonic-gate 	derr.fme_version = DDI_FME_VERSION;
2300Sstevel@tonic-gate 	mutex_enter(&pci_p->pci_common_p->pci_fm_mutex);
231815Sdilpreet 	if (pbm_p->pbm_excl_handle != NULL) {
232815Sdilpreet 		/*
233815Sdilpreet 		 * cautious write protection, protected from all errors.
234815Sdilpreet 		 */
235815Sdilpreet 		ASSERT(MUTEX_HELD(&pbm_p->pbm_pokefault_mutex));
236815Sdilpreet 		ddi_fm_acc_err_get(pbm_p->pbm_excl_handle, &derr,
237815Sdilpreet 				DDI_FME_VERSION);
238815Sdilpreet 		ASSERT(derr.fme_flag == DDI_FM_ERR_EXPECTED);
239815Sdilpreet 		derr.fme_acc_handle = pbm_p->pbm_excl_handle;
240815Sdilpreet 		err = pci_pbm_err_handler(pci_p->pci_dip, &derr, (void *)pci_p,
241815Sdilpreet 		    PCI_INTR_CALL);
242815Sdilpreet 	} else if ((otp != NULL) && (otp->ot_prot & OT_DATA_ACCESS)) {
2430Sstevel@tonic-gate 		/*
2440Sstevel@tonic-gate 		 * ddi_poke protection, check nexus and children for
2450Sstevel@tonic-gate 		 * expected errors.
2460Sstevel@tonic-gate 		 */
2470Sstevel@tonic-gate 		otp->ot_trap |= OT_DATA_ACCESS;
2480Sstevel@tonic-gate 		membar_sync();
2490Sstevel@tonic-gate 		derr.fme_flag = DDI_FM_ERR_POKE;
2500Sstevel@tonic-gate 		err = pci_pbm_err_handler(pci_p->pci_dip, &derr, (void *)pci_p,
2510Sstevel@tonic-gate 				PCI_INTR_CALL);
2520Sstevel@tonic-gate 	} else if (pci_check_error(pci_p) != 0) {
2530Sstevel@tonic-gate 		/*
2540Sstevel@tonic-gate 		 * unprotected error, check for all errors.
2550Sstevel@tonic-gate 		 */
2560Sstevel@tonic-gate 		if (pci_errtrig_pa)
2570Sstevel@tonic-gate 			(void) ldphysio(pci_errtrig_pa);
2580Sstevel@tonic-gate 		derr.fme_flag = DDI_FM_ERR_UNEXPECTED;
2590Sstevel@tonic-gate 		err = pci_pbm_err_handler(pci_p->pci_dip, &derr, (void *)pci_p,
2600Sstevel@tonic-gate 				PCI_INTR_CALL);
2610Sstevel@tonic-gate 	}
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate 	if (err == DDI_FM_FATAL) {
2640Sstevel@tonic-gate 		if (pci_panic_on_fatal_errors) {
2650Sstevel@tonic-gate 			mutex_exit(&pci_p->pci_common_p->pci_fm_mutex);
2660Sstevel@tonic-gate 			fm_panic("%s-%d: Fatal PCI bus error(s)\n",
2670Sstevel@tonic-gate 				ddi_driver_name(pci_p->pci_dip),
2680Sstevel@tonic-gate 				ddi_get_instance(pci_p->pci_dip));
2690Sstevel@tonic-gate 		}
2700Sstevel@tonic-gate 	}
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate 	mutex_exit(&pci_p->pci_common_p->pci_fm_mutex);
2730Sstevel@tonic-gate 	ib_nintr_clear(pci_p->pci_ib_p, pci_p->pci_inos[CBNINTR_PBM]);
2740Sstevel@tonic-gate 	return (DDI_INTR_CLAIMED);
2750Sstevel@tonic-gate }
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate void
pbm_suspend(pbm_t * pbm_p)2780Sstevel@tonic-gate pbm_suspend(pbm_t *pbm_p)
2790Sstevel@tonic-gate {
2800Sstevel@tonic-gate 	pci_t *pci_p = pbm_p->pbm_pci_p;
2810Sstevel@tonic-gate 	ib_ino_t ino = pci_p->pci_inos[CBNINTR_PBM];
2820Sstevel@tonic-gate 	pbm_p->pbm_imr_save = *ib_intr_map_reg_addr(pci_p->pci_ib_p, ino);
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 	pci_pbm_suspend(pci_p);
2850Sstevel@tonic-gate }
2860Sstevel@tonic-gate 
2870Sstevel@tonic-gate void
pbm_resume(pbm_t * pbm_p)2880Sstevel@tonic-gate pbm_resume(pbm_t *pbm_p)
2890Sstevel@tonic-gate {
2900Sstevel@tonic-gate 	pci_t *pci_p = pbm_p->pbm_pci_p;
2910Sstevel@tonic-gate 	ib_ino_t ino = pci_p->pci_inos[CBNINTR_PBM];
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate 	ib_nintr_clear(pci_p->pci_ib_p, ino);
2940Sstevel@tonic-gate 	*ib_intr_map_reg_addr(pci_p->pci_ib_p, ino) = pbm_p->pbm_imr_save;
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 	pci_pbm_resume(pci_p);
2970Sstevel@tonic-gate }
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate void
pbm_intr_dist(void * arg)3000Sstevel@tonic-gate pbm_intr_dist(void *arg)
3010Sstevel@tonic-gate {
3020Sstevel@tonic-gate 	pbm_t *pbm_p = (pbm_t *)arg;
3030Sstevel@tonic-gate 	pci_t *pci_p = pbm_p->pbm_pci_p;
3040Sstevel@tonic-gate 	ib_t *ib_p = pci_p->pci_ib_p;
3050Sstevel@tonic-gate 	ib_ino_t ino = IB_MONDO_TO_INO(pci_p->pci_inos[CBNINTR_PBM]);
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate 	mutex_enter(&ib_p->ib_intr_lock);
3080Sstevel@tonic-gate 	ib_intr_dist_nintr(ib_p, ino, ib_intr_map_reg_addr(ib_p, ino));
3090Sstevel@tonic-gate 	pci_pbm_intr_dist(pbm_p);
3100Sstevel@tonic-gate 	mutex_exit(&ib_p->ib_intr_lock);
3110Sstevel@tonic-gate }
3120Sstevel@tonic-gate 
3130Sstevel@tonic-gate /*
3140Sstevel@tonic-gate  * Function used to log PBM AFSR register bits and to lookup and fault
3150Sstevel@tonic-gate  * handle associated with PBM AFAR register. Called by pci_pbm_err_handler with
3160Sstevel@tonic-gate  * pci_fm_mutex held.
3170Sstevel@tonic-gate  */
3180Sstevel@tonic-gate int
pbm_afsr_report(dev_info_t * dip,uint64_t fme_ena,pbm_errstate_t * pbm_err_p)3190Sstevel@tonic-gate pbm_afsr_report(dev_info_t *dip, uint64_t fme_ena, pbm_errstate_t *pbm_err_p)
3200Sstevel@tonic-gate {
3210Sstevel@tonic-gate 	int fatal = 0;
3220Sstevel@tonic-gate 	int ret = 0;
3230Sstevel@tonic-gate 	pci_t *pci_p = get_pci_soft_state(ddi_get_instance(dip));
3240Sstevel@tonic-gate 	pci_common_t *cmn_p = pci_p->pci_common_p;
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate 	ASSERT(MUTEX_HELD(&cmn_p->pci_fm_mutex));
3270Sstevel@tonic-gate 
3280Sstevel@tonic-gate 	pbm_err_p->pbm_pri = PBM_PRIMARY;
3290Sstevel@tonic-gate 	(void) pci_pbm_classify(pbm_err_p);
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate 	pci_format_addr(dip, &pbm_err_p->pbm_pci.pci_pa, pbm_err_p->pbm_afsr);
3320Sstevel@tonic-gate 
3330Sstevel@tonic-gate 	if (pbm_err_p->pbm_log == FM_LOG_PBM)
3340Sstevel@tonic-gate 		pbm_ereport_post(dip, fme_ena, pbm_err_p);
3350Sstevel@tonic-gate 
3360Sstevel@tonic-gate 	/*
3370Sstevel@tonic-gate 	 * Lookup and fault errant handle
3380Sstevel@tonic-gate 	 */
3391865Sdilpreet 	if (((ret = ndi_fmc_error(dip, NULL, ACC_HANDLE, fme_ena,
3401865Sdilpreet 	    (void *)&pbm_err_p->pbm_pci.pci_pa)) == DDI_FM_FATAL) ||
3411865Sdilpreet 	    (ret == DDI_FM_UNKNOWN))
3420Sstevel@tonic-gate 		fatal++;
3430Sstevel@tonic-gate 
3440Sstevel@tonic-gate 	/*
3450Sstevel@tonic-gate 	 * queue target ereport if appropriate
3460Sstevel@tonic-gate 	 */
3471865Sdilpreet 	if (pbm_err_p->pbm_terr_class)
3481865Sdilpreet 		pci_target_enqueue(fme_ena, pbm_err_p->pbm_terr_class,
3491865Sdilpreet 		    (pbm_err_p->pbm_log == FM_LOG_PCI) ? "pci" :
3501865Sdilpreet 		    pbm_err_p->pbm_bridge_type, pbm_err_p->pbm_pci.pci_pa);
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate 	/*
3530Sstevel@tonic-gate 	 * We are currently not dealing with the multiple error
3540Sstevel@tonic-gate 	 * case, for any secondary errors we will panic.
3550Sstevel@tonic-gate 	 */
3560Sstevel@tonic-gate 	pbm_err_p->pbm_pri = PBM_SECONDARY;
3570Sstevel@tonic-gate 	if (pci_pbm_classify(pbm_err_p)) {
3580Sstevel@tonic-gate 		fatal++;
3590Sstevel@tonic-gate 		if (pbm_err_p->pbm_log == FM_LOG_PBM)
3600Sstevel@tonic-gate 			pbm_ereport_post(dip, fme_ena, pbm_err_p);
3610Sstevel@tonic-gate 	}
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate 	if (fatal)
3640Sstevel@tonic-gate 		return (DDI_FM_FATAL);
3650Sstevel@tonic-gate 
3660Sstevel@tonic-gate 	return (DDI_FM_NONFATAL);
3670Sstevel@tonic-gate }
368