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 5*00d0963fSdilpreet * Common Development and Distribution License (the "License"). 6*00d0963fSdilpreet * 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 /* 22*00d0963fSdilpreet * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 307c478bd9Sstevel@tonic-gate #include <sys/sunndi.h> 317c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 327c478bd9Sstevel@tonic-gate #include <sys/async.h> 337c478bd9Sstevel@tonic-gate #include <sys/membar.h> 347c478bd9Sstevel@tonic-gate #include <sys/spl.h> 357c478bd9Sstevel@tonic-gate #include <sys/iommu.h> 367c478bd9Sstevel@tonic-gate #include <sys/pci/pci_obj.h> 377c478bd9Sstevel@tonic-gate #include <sys/fm/util.h> 387c478bd9Sstevel@tonic-gate #include <sys/fm/io/pci.h> 397c478bd9Sstevel@tonic-gate #include <sys/fm/io/ddi.h> 407c478bd9Sstevel@tonic-gate #include <sys/fm/io/sun4upci.h> 417c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h> 427c478bd9Sstevel@tonic-gate #include <sys/intr.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * The routines below are generic sun4u PCI interfaces to support 487c478bd9Sstevel@tonic-gate * Fault Management. 497c478bd9Sstevel@tonic-gate * 507c478bd9Sstevel@tonic-gate * pci_dma_check, pci_acc_check, pci_handle_lookup are functions used 517c478bd9Sstevel@tonic-gate * to associate a captured PCI address to a particular dma/acc handle. 527c478bd9Sstevel@tonic-gate * 537c478bd9Sstevel@tonic-gate * pci_fm_acc_setup, pci_fm_init_child, pci_fm_create, 547c478bd9Sstevel@tonic-gate * pci_fm_destroy are constructors/destructors used to setup and teardown 557c478bd9Sstevel@tonic-gate * necessary resources. 567c478bd9Sstevel@tonic-gate * 577c478bd9Sstevel@tonic-gate * pci_bus_enter, pci_bus_exit are registered via busops and are used to 587c478bd9Sstevel@tonic-gate * provide exclusive access to the PCI bus. 597c478bd9Sstevel@tonic-gate * 607c478bd9Sstevel@tonic-gate * pci_err_callback is the registered callback for PCI which is called 617c478bd9Sstevel@tonic-gate * by the CPU code when it detects a UE/TO/BERR. 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate * pbm_ereport_post is used by the PBM code to generically report all 647c478bd9Sstevel@tonic-gate * PBM errors. 657c478bd9Sstevel@tonic-gate * 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Function used to setup access functions depending on level of desired 707c478bd9Sstevel@tonic-gate * protection. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate void 737c478bd9Sstevel@tonic-gate pci_fm_acc_setup(ddi_map_req_t *mp, dev_info_t *rdip) 747c478bd9Sstevel@tonic-gate { 757c478bd9Sstevel@tonic-gate uchar_t fflag; 767c478bd9Sstevel@tonic-gate ddi_acc_hdl_t *hp; 777c478bd9Sstevel@tonic-gate ddi_acc_impl_t *ap; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate hp = mp->map_handlep; 807c478bd9Sstevel@tonic-gate ap = (ddi_acc_impl_t *)hp->ah_platform_private; 817c478bd9Sstevel@tonic-gate fflag = ap->ahi_common.ah_acc.devacc_attr_access; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate if (mp->map_op == DDI_MO_MAP_LOCKED) { 847c478bd9Sstevel@tonic-gate ndi_fmc_insert(rdip, ACC_HANDLE, (void *)hp, NULL); 857c478bd9Sstevel@tonic-gate switch (fflag) { 867c478bd9Sstevel@tonic-gate case DDI_FLAGERR_ACC: 877c478bd9Sstevel@tonic-gate ap->ahi_get8 = i_ddi_prot_get8; 887c478bd9Sstevel@tonic-gate ap->ahi_get16 = i_ddi_prot_get16; 897c478bd9Sstevel@tonic-gate ap->ahi_get32 = i_ddi_prot_get32; 907c478bd9Sstevel@tonic-gate ap->ahi_get64 = i_ddi_prot_get64; 917c478bd9Sstevel@tonic-gate ap->ahi_put8 = i_ddi_prot_put8; 927c478bd9Sstevel@tonic-gate ap->ahi_put16 = i_ddi_prot_put16; 937c478bd9Sstevel@tonic-gate ap->ahi_put32 = i_ddi_prot_put32; 947c478bd9Sstevel@tonic-gate ap->ahi_put64 = i_ddi_prot_put64; 957c478bd9Sstevel@tonic-gate ap->ahi_rep_get8 = i_ddi_prot_rep_get8; 967c478bd9Sstevel@tonic-gate ap->ahi_rep_get16 = i_ddi_prot_rep_get16; 977c478bd9Sstevel@tonic-gate ap->ahi_rep_get32 = i_ddi_prot_rep_get32; 987c478bd9Sstevel@tonic-gate ap->ahi_rep_get64 = i_ddi_prot_rep_get64; 997c478bd9Sstevel@tonic-gate ap->ahi_rep_put8 = i_ddi_prot_rep_put8; 1007c478bd9Sstevel@tonic-gate ap->ahi_rep_put16 = i_ddi_prot_rep_put16; 1017c478bd9Sstevel@tonic-gate ap->ahi_rep_put32 = i_ddi_prot_rep_put32; 1027c478bd9Sstevel@tonic-gate ap->ahi_rep_put64 = i_ddi_prot_rep_put64; 1037c478bd9Sstevel@tonic-gate break; 1047c478bd9Sstevel@tonic-gate case DDI_CAUTIOUS_ACC : 1057c478bd9Sstevel@tonic-gate ap->ahi_get8 = i_ddi_caut_get8; 1067c478bd9Sstevel@tonic-gate ap->ahi_get16 = i_ddi_caut_get16; 1077c478bd9Sstevel@tonic-gate ap->ahi_get32 = i_ddi_caut_get32; 1087c478bd9Sstevel@tonic-gate ap->ahi_get64 = i_ddi_caut_get64; 1097c478bd9Sstevel@tonic-gate ap->ahi_put8 = i_ddi_caut_put8; 1107c478bd9Sstevel@tonic-gate ap->ahi_put16 = i_ddi_caut_put16; 1117c478bd9Sstevel@tonic-gate ap->ahi_put32 = i_ddi_caut_put32; 1127c478bd9Sstevel@tonic-gate ap->ahi_put64 = i_ddi_caut_put64; 1137c478bd9Sstevel@tonic-gate ap->ahi_rep_get8 = i_ddi_caut_rep_get8; 1147c478bd9Sstevel@tonic-gate ap->ahi_rep_get16 = i_ddi_caut_rep_get16; 1157c478bd9Sstevel@tonic-gate ap->ahi_rep_get32 = i_ddi_caut_rep_get32; 1167c478bd9Sstevel@tonic-gate ap->ahi_rep_get64 = i_ddi_caut_rep_get64; 1177c478bd9Sstevel@tonic-gate ap->ahi_rep_put8 = i_ddi_caut_rep_put8; 1187c478bd9Sstevel@tonic-gate ap->ahi_rep_put16 = i_ddi_caut_rep_put16; 1197c478bd9Sstevel@tonic-gate ap->ahi_rep_put32 = i_ddi_caut_rep_put32; 1207c478bd9Sstevel@tonic-gate ap->ahi_rep_put64 = i_ddi_caut_rep_put64; 1217c478bd9Sstevel@tonic-gate break; 1227c478bd9Sstevel@tonic-gate default: 1237c478bd9Sstevel@tonic-gate break; 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate } else if (mp->map_op == DDI_MO_UNMAP) { 1267c478bd9Sstevel@tonic-gate ndi_fmc_remove(rdip, ACC_HANDLE, (void *)hp); 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate /* 1317c478bd9Sstevel@tonic-gate * Function used to initialize FMA for our children nodes. Called 1327c478bd9Sstevel@tonic-gate * through pci busops when child node calls ddi_fm_init. 1337c478bd9Sstevel@tonic-gate */ 1347c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1357c478bd9Sstevel@tonic-gate int 1367c478bd9Sstevel@tonic-gate pci_fm_init_child(dev_info_t *dip, dev_info_t *tdip, int cap, 1377c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t *ibc) 1387c478bd9Sstevel@tonic-gate { 1397c478bd9Sstevel@tonic-gate pci_t *pci_p = get_pci_soft_state(ddi_get_instance(dip)); 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate ASSERT(ibc != NULL); 142*00d0963fSdilpreet *ibc = pci_p->pci_fm_ibc; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate return (pci_p->pci_fm_cap); 1457c478bd9Sstevel@tonic-gate } 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* 1487c478bd9Sstevel@tonic-gate * Lock accesses to the pci bus, to be able to protect against bus errors. 1497c478bd9Sstevel@tonic-gate */ 1507c478bd9Sstevel@tonic-gate void 1517c478bd9Sstevel@tonic-gate pci_bus_enter(dev_info_t *dip, ddi_acc_handle_t handle) 1527c478bd9Sstevel@tonic-gate { 1537c478bd9Sstevel@tonic-gate pci_t *pci_p = get_pci_soft_state(ddi_get_instance(dip)); 1547c478bd9Sstevel@tonic-gate pbm_t *pbm_p = pci_p->pci_pbm_p; 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate membar_sync(); 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate mutex_enter(&pbm_p->pbm_pokefault_mutex); 1597c478bd9Sstevel@tonic-gate pbm_p->pbm_excl_handle = handle; 1607c478bd9Sstevel@tonic-gate } 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* 1637c478bd9Sstevel@tonic-gate * Unlock access to bus and clear errors before exiting. 1647c478bd9Sstevel@tonic-gate */ 1657c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1667c478bd9Sstevel@tonic-gate void 1677c478bd9Sstevel@tonic-gate pci_bus_exit(dev_info_t *dip, ddi_acc_handle_t handle) 1687c478bd9Sstevel@tonic-gate { 1697c478bd9Sstevel@tonic-gate pci_t *pci_p = get_pci_soft_state(ddi_get_instance(dip)); 1707c478bd9Sstevel@tonic-gate pbm_t *pbm_p = pci_p->pci_pbm_p; 1717c478bd9Sstevel@tonic-gate ddi_fm_error_t derr; 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&pbm_p->pbm_pokefault_mutex)); 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate membar_sync(); 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate mutex_enter(&pci_p->pci_common_p->pci_fm_mutex); 1787c478bd9Sstevel@tonic-gate ddi_fm_acc_err_get(pbm_p->pbm_excl_handle, &derr, DDI_FME_VERSION); 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate if (derr.fme_status == DDI_FM_OK) { 1817c478bd9Sstevel@tonic-gate if (pci_check_error(pci_p) != 0) { 1827c478bd9Sstevel@tonic-gate (void) pci_pbm_err_handler(pci_p->pci_dip, &derr, 1837c478bd9Sstevel@tonic-gate (const void *)pci_p, PCI_BUS_EXIT_CALL); 1847c478bd9Sstevel@tonic-gate } 1857c478bd9Sstevel@tonic-gate } 1867c478bd9Sstevel@tonic-gate mutex_exit(&pci_p->pci_common_p->pci_fm_mutex); 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate pbm_p->pbm_excl_handle = NULL; 1897c478bd9Sstevel@tonic-gate mutex_exit(&pbm_p->pbm_pokefault_mutex); 1907c478bd9Sstevel@tonic-gate } 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate /* 1937c478bd9Sstevel@tonic-gate * PCI error callback which is registered with our parent to call 1947c478bd9Sstevel@tonic-gate * for PCI logging when the CPU traps due to BERR/TO/UE. 1957c478bd9Sstevel@tonic-gate */ 1967c478bd9Sstevel@tonic-gate int 1977c478bd9Sstevel@tonic-gate pci_err_callback(dev_info_t *dip, ddi_fm_error_t *derr, 1987c478bd9Sstevel@tonic-gate const void *impl_data) 1997c478bd9Sstevel@tonic-gate { 2007c478bd9Sstevel@tonic-gate pci_t *pci_p = (pci_t *)impl_data; 2017c478bd9Sstevel@tonic-gate pci_common_t *cmn_p = pci_p->pci_common_p; 2027c478bd9Sstevel@tonic-gate ecc_t *ecc_p = cmn_p->pci_common_ecc_p; 2037c478bd9Sstevel@tonic-gate ecc_errstate_t ecc_err; 2047c478bd9Sstevel@tonic-gate int fatal = 0; 2057c478bd9Sstevel@tonic-gate int nonfatal = 0; 2067c478bd9Sstevel@tonic-gate int unknown = 0; 2077c478bd9Sstevel@tonic-gate int ret = DDI_FM_OK; 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate bzero(&ecc_err, sizeof (ecc_err)); 2107c478bd9Sstevel@tonic-gate mutex_enter(&cmn_p->pci_fm_mutex); 2117c478bd9Sstevel@tonic-gate /* 2127c478bd9Sstevel@tonic-gate * Check and log ecc and pbm errors 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate ecc_err.ecc_ii_p = ecc_p->ecc_ue; 2157c478bd9Sstevel@tonic-gate ecc_err.ecc_ena = derr->fme_ena; 2167c478bd9Sstevel@tonic-gate ecc_err.ecc_caller = PCI_TRAP_CALL; 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate if ((ret = ecc_err_handler(&ecc_err)) == DDI_FM_FATAL) 2197c478bd9Sstevel@tonic-gate fatal++; 2207c478bd9Sstevel@tonic-gate else if (ret == DDI_FM_NONFATAL) 2217c478bd9Sstevel@tonic-gate nonfatal++; 2227c478bd9Sstevel@tonic-gate else if (ret == DDI_FM_UNKNOWN) 2237c478bd9Sstevel@tonic-gate unknown++; 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate if (pci_check_error(pci_p) != 0) { 2267c478bd9Sstevel@tonic-gate int err = pci_pbm_err_handler(pci_p->pci_dip, derr, 2277c478bd9Sstevel@tonic-gate (const void *)pci_p, PCI_TRAP_CALL); 2287c478bd9Sstevel@tonic-gate if (err == DDI_FM_FATAL) 2297c478bd9Sstevel@tonic-gate fatal++; 2307c478bd9Sstevel@tonic-gate else if (err == DDI_FM_NONFATAL) 2317c478bd9Sstevel@tonic-gate nonfatal++; 2327c478bd9Sstevel@tonic-gate else if (err == DDI_FM_UNKNOWN) 2337c478bd9Sstevel@tonic-gate unknown++; 2347c478bd9Sstevel@tonic-gate } 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate mutex_exit(&cmn_p->pci_fm_mutex); 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate if (fatal) 2397c478bd9Sstevel@tonic-gate return (DDI_FM_FATAL); 2407c478bd9Sstevel@tonic-gate else if (nonfatal) 2417c478bd9Sstevel@tonic-gate return (DDI_FM_NONFATAL); 2427c478bd9Sstevel@tonic-gate else if (unknown) 2437c478bd9Sstevel@tonic-gate return (DDI_FM_UNKNOWN); 2447c478bd9Sstevel@tonic-gate else 2457c478bd9Sstevel@tonic-gate return (DDI_FM_OK); 2467c478bd9Sstevel@tonic-gate } 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate void 2497c478bd9Sstevel@tonic-gate pci_fm_create(pci_t *pci_p) 2507c478bd9Sstevel@tonic-gate { 2517c478bd9Sstevel@tonic-gate pci_common_t *cmn_p = pci_p->pci_common_p; 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate /* 2547c478bd9Sstevel@tonic-gate * PCI detected ECC errorq, to schedule async handling 2557c478bd9Sstevel@tonic-gate * of ECC errors and logging. 2567c478bd9Sstevel@tonic-gate * The errorq is created here but destroyed when _fini is called 2577c478bd9Sstevel@tonic-gate * for the pci module. 2587c478bd9Sstevel@tonic-gate */ 2597c478bd9Sstevel@tonic-gate if (pci_ecc_queue == NULL) { 2607c478bd9Sstevel@tonic-gate pci_ecc_queue = errorq_create("pci_ecc_queue", 2617c478bd9Sstevel@tonic-gate (errorq_func_t)ecc_err_drain, 262*00d0963fSdilpreet (void *)pci_p->pci_ecc_p, 2637c478bd9Sstevel@tonic-gate ECC_MAX_ERRS, sizeof (ecc_errstate_t), 2647c478bd9Sstevel@tonic-gate PIL_2, ERRORQ_VITAL); 2657c478bd9Sstevel@tonic-gate if (pci_ecc_queue == NULL) 2667c478bd9Sstevel@tonic-gate panic("failed to create required system error queue"); 2677c478bd9Sstevel@tonic-gate } 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate /* 270*00d0963fSdilpreet * Initialize pci_target_queue for FMA handling of pci errors. 2717c478bd9Sstevel@tonic-gate */ 272*00d0963fSdilpreet pci_targetq_init(); 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate /* 2757c478bd9Sstevel@tonic-gate * Initialize FMA support 2767c478bd9Sstevel@tonic-gate * The axq workaround prevents fault management of access errors 2777c478bd9Sstevel@tonic-gate */ 2787c478bd9Sstevel@tonic-gate if (pci_p->pci_pbm_p->pbm_pio_limit == 0) 2797c478bd9Sstevel@tonic-gate pci_p->pci_fm_cap = DDI_FM_EREPORT_CAPABLE | 2807c478bd9Sstevel@tonic-gate DDI_FM_ACCCHK_CAPABLE | DDI_FM_DMACHK_CAPABLE | 2817c478bd9Sstevel@tonic-gate DDI_FM_ERRCB_CAPABLE; 2827c478bd9Sstevel@tonic-gate else 2837c478bd9Sstevel@tonic-gate pci_p->pci_fm_cap = DDI_FM_EREPORT_CAPABLE | 2847c478bd9Sstevel@tonic-gate DDI_FM_DMACHK_CAPABLE | DDI_FM_ERRCB_CAPABLE; 2857c478bd9Sstevel@tonic-gate /* 2867c478bd9Sstevel@tonic-gate * Call parent to get it's capablity 2877c478bd9Sstevel@tonic-gate */ 2887c478bd9Sstevel@tonic-gate ddi_fm_init(pci_p->pci_dip, &pci_p->pci_fm_cap, 2897c478bd9Sstevel@tonic-gate &pci_p->pci_fm_ibc); 2907c478bd9Sstevel@tonic-gate /* 2917c478bd9Sstevel@tonic-gate * Need to be ereport and error handler cabable 2927c478bd9Sstevel@tonic-gate */ 2937c478bd9Sstevel@tonic-gate ASSERT((pci_p->pci_fm_cap & DDI_FM_ERRCB_CAPABLE) && 2947c478bd9Sstevel@tonic-gate (pci_p->pci_fm_cap & DDI_FM_EREPORT_CAPABLE)); 2957c478bd9Sstevel@tonic-gate /* 2967c478bd9Sstevel@tonic-gate * Initialize error handling mutex. 2977c478bd9Sstevel@tonic-gate */ 2987c478bd9Sstevel@tonic-gate if (cmn_p->pci_common_refcnt == 0) { 2997c478bd9Sstevel@tonic-gate mutex_init(&cmn_p->pci_fm_mutex, NULL, MUTEX_DRIVER, 3007c478bd9Sstevel@tonic-gate (void *)pci_p->pci_fm_ibc); 3017c478bd9Sstevel@tonic-gate } 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate /* 3047c478bd9Sstevel@tonic-gate * Register error callback with our parent. 3057c478bd9Sstevel@tonic-gate */ 3067c478bd9Sstevel@tonic-gate ddi_fm_handler_register(pci_p->pci_dip, pci_err_callback, 3077c478bd9Sstevel@tonic-gate pci_p); 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate } 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate void 3127c478bd9Sstevel@tonic-gate pci_fm_destroy(pci_t *pci_p) 3137c478bd9Sstevel@tonic-gate { 3147c478bd9Sstevel@tonic-gate pci_common_t *cmn_p = pci_p->pci_common_p; 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate /* schizo non-shared objects */ 3177c478bd9Sstevel@tonic-gate ddi_fm_handler_unregister(pci_p->pci_dip); 3187c478bd9Sstevel@tonic-gate ddi_fm_fini(pci_p->pci_dip); 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate if (cmn_p->pci_common_refcnt != 0) 3217c478bd9Sstevel@tonic-gate return; 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate mutex_destroy(&cmn_p->pci_fm_mutex); 3247c478bd9Sstevel@tonic-gate } 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* 3277c478bd9Sstevel@tonic-gate * Function used to post PCI block module specific ereports. 3287c478bd9Sstevel@tonic-gate */ 3297c478bd9Sstevel@tonic-gate void 3307c478bd9Sstevel@tonic-gate pbm_ereport_post(dev_info_t *dip, uint64_t ena, pbm_errstate_t *pbm_err) 3317c478bd9Sstevel@tonic-gate { 3327c478bd9Sstevel@tonic-gate char buf[FM_MAX_CLASS]; 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate (void) snprintf(buf, FM_MAX_CLASS, "%s.%s", 3357c478bd9Sstevel@tonic-gate pbm_err->pbm_bridge_type, pbm_err->pbm_err_class); 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate ena = ena ? ena : fm_ena_generate(0, FM_ENA_FMT1); 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate ddi_fm_ereport_post(dip, buf, ena, DDI_NOSLEEP, 3407c478bd9Sstevel@tonic-gate FM_VERSION, DATA_TYPE_UINT8, 0, 3417c478bd9Sstevel@tonic-gate PCI_CONFIG_STATUS, DATA_TYPE_UINT16, pbm_err->pbm_pci.pci_cfg_stat, 3427c478bd9Sstevel@tonic-gate PCI_CONFIG_COMMAND, DATA_TYPE_UINT16, pbm_err->pbm_pci.pci_cfg_comm, 3437c478bd9Sstevel@tonic-gate PCI_PBM_CSR, DATA_TYPE_UINT64, pbm_err->pbm_ctl_stat, 3447c478bd9Sstevel@tonic-gate PCI_PBM_AFSR, DATA_TYPE_UINT64, pbm_err->pbm_afsr, 3457c478bd9Sstevel@tonic-gate PCI_PBM_AFAR, DATA_TYPE_UINT64, pbm_err->pbm_afar, 3467c478bd9Sstevel@tonic-gate PCI_PBM_SLOT, DATA_TYPE_UINT64, pbm_err->pbm_err_sl, 3477c478bd9Sstevel@tonic-gate PCI_PBM_VALOG, DATA_TYPE_UINT64, pbm_err->pbm_va_log, 3487c478bd9Sstevel@tonic-gate NULL); 3497c478bd9Sstevel@tonic-gate } 350