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 51486Sdanice * Common Development and Distribution License (the "License"). 61486Sdanice * 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 /* 22*3558Sdduvall * 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 nexus driver tunables 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <sys/cmn_err.h> 340Sstevel@tonic-gate #include <sys/time.h> 350Sstevel@tonic-gate #include <sys/thread.h> 360Sstevel@tonic-gate #include <sys/ksynch.h> 370Sstevel@tonic-gate #include <sys/pci.h> 380Sstevel@tonic-gate #include <sys/pci/pci_space.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate 410Sstevel@tonic-gate /*LINTLIBRARY*/ 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* 440Sstevel@tonic-gate * Used to disallow bypass requests for tomatillos ver <= 2.3 450Sstevel@tonic-gate * 0 allow bypass, 1 disallow it. errata #75 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate uint_t tomatillo_disallow_bypass = 0; 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* 500Sstevel@tonic-gate * The three variables below enable a workround for 510Sstevel@tonic-gate * tomatillo's micro TLB bug. errata #82 520Sstevel@tonic-gate */ 530Sstevel@tonic-gate uint_t tm_mtlb_maxpgs = 20; 540Sstevel@tonic-gate uint_t tm_mtlb_gc = 0; /* for garbage collection */ 550Sstevel@tonic-gate uint_t tm_mtlb_gc_manual = 0; /* for manual tuning */ 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* 580Sstevel@tonic-gate * By initializing pci_interrupt_priorities_property to 1, the priority 590Sstevel@tonic-gate * level of the interrupt handler for a PCI device can be defined via an 600Sstevel@tonic-gate * "interrupt-priorities" property. This property is an array of integer 610Sstevel@tonic-gate * values that have a one to one mapping the the "interrupts" property. 620Sstevel@tonic-gate * For example, if a device's "interrupts" property was (1, 2) and its 630Sstevel@tonic-gate * "interrupt-priorities" value was (5, 12), the handler for the first 640Sstevel@tonic-gate * interrupt would run at cpu priority 5 and the second at priority 12. 650Sstevel@tonic-gate * This would override the drivers standard mechanism for assigning 660Sstevel@tonic-gate * priorities to interrupt handlers. 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate uint_t pci_interrupt_priorities_property = 1; 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* 710Sstevel@tonic-gate * By initializing pci_config_space_size_zero to 1, the driver will 720Sstevel@tonic-gate * tolerate mapping requests for configuration space "reg" entries whose 730Sstevel@tonic-gate * size is not zero. 740Sstevel@tonic-gate */ 750Sstevel@tonic-gate uint_t pci_config_space_size_zero = 1; 760Sstevel@tonic-gate 770Sstevel@tonic-gate int pci_dvma_sync_before_unmap = 0; 780Sstevel@tonic-gate int pci_sync_lock = 0; 790Sstevel@tonic-gate 800Sstevel@tonic-gate int tomatillo_store_store_wrka = 0; 810Sstevel@tonic-gate uint32_t pci_spurintr_duration = 60000000; /* One minute */ 820Sstevel@tonic-gate uint64_t pci_spurintr_msgs = PCI_SPURINTR_MSG_DEFAULT; 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * The variable controls the default setting of the command register 860Sstevel@tonic-gate * for pci devices. See init_child() for details. 870Sstevel@tonic-gate * 880Sstevel@tonic-gate * This flags also controls the setting of bits in the bridge control 890Sstevel@tonic-gate * register pci to pci bridges. See init_child() for details. 900Sstevel@tonic-gate */ 910Sstevel@tonic-gate ushort_t pci_command_default = PCI_COMM_SERR_ENABLE | 920Sstevel@tonic-gate PCI_COMM_WAIT_CYC_ENAB | 930Sstevel@tonic-gate PCI_COMM_PARITY_DETECT | 940Sstevel@tonic-gate PCI_COMM_ME | 950Sstevel@tonic-gate PCI_COMM_MAE | 960Sstevel@tonic-gate PCI_COMM_IO; 970Sstevel@tonic-gate /* 980Sstevel@tonic-gate * The following variable enables a workaround for the following obp bug: 990Sstevel@tonic-gate * 1000Sstevel@tonic-gate * 1234181 - obp should set latency timer registers in pci 1010Sstevel@tonic-gate * configuration header 1020Sstevel@tonic-gate * 1030Sstevel@tonic-gate * Until this bug gets fixed in the obp, the following workaround should 1040Sstevel@tonic-gate * be enabled. 1050Sstevel@tonic-gate */ 1060Sstevel@tonic-gate uint_t pci_set_latency_timer_register = 1; 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* 1090Sstevel@tonic-gate * The following variable enables a workaround for an obp bug to be 1100Sstevel@tonic-gate * submitted. A bug requesting a workaround fof this problem has 1110Sstevel@tonic-gate * been filed: 1120Sstevel@tonic-gate * 1130Sstevel@tonic-gate * 1235094 - need workarounds on positron nexus drivers to set cache 1140Sstevel@tonic-gate * line size registers 1150Sstevel@tonic-gate * 1160Sstevel@tonic-gate * Until this bug gets fixed in the obp, the following workaround should 1170Sstevel@tonic-gate * be enabled. 1180Sstevel@tonic-gate */ 1190Sstevel@tonic-gate uint_t pci_set_cache_line_size_register = 1; 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate /* 1220Sstevel@tonic-gate * The following driver parameters are defined as variables to allow 1230Sstevel@tonic-gate * patching for debugging and tuning. Flags that can be set on a per 1240Sstevel@tonic-gate * PBM basis are bit fields where the PBM device instance number maps 1250Sstevel@tonic-gate * to the bit position. 1260Sstevel@tonic-gate */ 1270Sstevel@tonic-gate #ifdef DEBUG 1280Sstevel@tonic-gate uint64_t pci_debug_flags = 0; 1290Sstevel@tonic-gate uint_t pci_warn_pp0 = 0; 1300Sstevel@tonic-gate #endif 1310Sstevel@tonic-gate uint_t pci_disable_pass1_workarounds = 0; 1320Sstevel@tonic-gate uint_t pci_disable_pass2_workarounds = 0; 1330Sstevel@tonic-gate uint_t pci_disable_pass3_workarounds = 0; 1340Sstevel@tonic-gate uint_t pci_disable_plus_workarounds = 0; 1350Sstevel@tonic-gate uint_t pci_disable_default_workarounds = 0; 1360Sstevel@tonic-gate uint_t ecc_error_intr_enable = 1; 1370Sstevel@tonic-gate uint_t pci_sbh_error_intr_enable = (uint_t)-1; 1380Sstevel@tonic-gate uint_t pci_mmu_error_intr_enable = (uint_t)-1; 1390Sstevel@tonic-gate uint_t pci_stream_buf_enable = (uint_t)-1; 1400Sstevel@tonic-gate uint_t pci_stream_buf_exists = 1; 1410Sstevel@tonic-gate uint_t pci_rerun_disable = 0; 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate uint_t pci_enable_retry_arb = (uint_t)-1; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate uint_t pci_bus_parking_enable = (uint_t)-1; 1460Sstevel@tonic-gate uint_t pci_error_intr_enable = (uint_t)-1; 1470Sstevel@tonic-gate uint_t pci_retry_disable = 0; 1480Sstevel@tonic-gate uint_t pci_retry_enable = 0; 1490Sstevel@tonic-gate uint_t pci_dwsync_disable = 0; 1500Sstevel@tonic-gate uint_t pci_intsync_disable = 0; 1510Sstevel@tonic-gate uint_t pci_b_arb_enable = 0xf; 1520Sstevel@tonic-gate uint_t pci_a_arb_enable = 0xf; 1530Sstevel@tonic-gate uint_t pci_ecc_afsr_retries = 100; /* XXX - what's a good value? */ 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate uint_t pci_intr_retry_intv = 5; /* for interrupt retry reg */ 1560Sstevel@tonic-gate uint8_t pci_latency_timer = 0x40; /* for pci latency timer reg */ 1570Sstevel@tonic-gate uint_t pci_panic_on_sbh_errors = 0; 1580Sstevel@tonic-gate uint_t pci_panic_on_fatal_errors = 1; /* should be 1 at beta */ 1590Sstevel@tonic-gate uint_t pci_thermal_intr_fatal = 1; /* thermal interrupts fatal */ 1600Sstevel@tonic-gate uint_t pci_buserr_interrupt = 1; /* safari buserr interrupt */ 1610Sstevel@tonic-gate uint_t pci_set_dto_value = 0; /* overwrite the prom settings? */ 1620Sstevel@tonic-gate uint_t pci_dto_value = 1; /* schizo consistent buf timeout PTO */ 1630Sstevel@tonic-gate uint_t pci_lock_sbuf = 0; 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate uint_t pci_use_contexts = 1; 1660Sstevel@tonic-gate uint_t pci_sc_use_contexts = 1; 1670Sstevel@tonic-gate uint_t pci_context_minpages = 2; 1680Sstevel@tonic-gate uint_t pci_ctx_flush_warn = CE_IGNORE; 1690Sstevel@tonic-gate uint_t pci_ctx_unsuccess_count = 0; /* unsuccessful ctx flush count */ 1700Sstevel@tonic-gate uint_t pci_ctx_no_active_flush = 0; /* cannot handle active ctx flush */ 1710Sstevel@tonic-gate uint_t pci_ctx_no_compat = 0; /* maintain compatibility */ 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate uint64_t pci_perr_enable = -1ull; 1740Sstevel@tonic-gate uint64_t pci_serr_enable = -1ull; 1750Sstevel@tonic-gate uint64_t pci_perr_fatal = -1ull; 1760Sstevel@tonic-gate uint64_t pci_serr_fatal = -1ull; 1770Sstevel@tonic-gate hrtime_t pci_intrpend_timeout = 5ll * NANOSEC; /* 5 seconds in nanoseconds */ 1780Sstevel@tonic-gate hrtime_t pci_sync_buf_timeout = 1ll * NANOSEC; /* 1 second in nanoseconds */ 1790Sstevel@tonic-gate hrtime_t pci_cdma_intr_timeout = 1ll * NANOSEC; /* consistent sync trigger */ 1800Sstevel@tonic-gate uint32_t pci_cdma_intr_count = 15; /* num of pci_cdma_intr_timeout cycles */ 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate uint32_t pci_dto_fault_warn = CE_WARN; /* set to CE_IGNORE for no messages */ 1830Sstevel@tonic-gate uint64_t pci_dto_intr_enable = 0; 1840Sstevel@tonic-gate uint64_t pci_dto_count = 0; 1850Sstevel@tonic-gate uint64_t pci_errtrig_pa = 0x0; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * The following flag controls behavior of the ino handler routine 1890Sstevel@tonic-gate * when multiple interrupts are attached to a single ino. Typically 1900Sstevel@tonic-gate * this case would occur for the ino's assigned to the PCI bus slots 1910Sstevel@tonic-gate * with multi-function devices or bus bridges. 1920Sstevel@tonic-gate * 1930Sstevel@tonic-gate * Setting the flag to zero causes the ino handler routine to return 1940Sstevel@tonic-gate * after finding the first interrupt handler to claim the interrupt. 1950Sstevel@tonic-gate * 1960Sstevel@tonic-gate * Setting the flag to non-zero causes the ino handler routine to 1970Sstevel@tonic-gate * return after making one complete pass through the interrupt 1980Sstevel@tonic-gate * handlers. 1990Sstevel@tonic-gate */ 2000Sstevel@tonic-gate uint_t pci_check_all_handlers = 1; 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate /* 2030Sstevel@tonic-gate * The following value is the number of consecutive unclaimed interrupts that 2040Sstevel@tonic-gate * will be tolerated for a particular ino_p before the interrupt is deemed to 2050Sstevel@tonic-gate * be jabbering and is blocked. 2060Sstevel@tonic-gate */ 2070Sstevel@tonic-gate uint_t pci_unclaimed_intr_max = 20; 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate ulong_t pci_iommu_dvma_end = 0xfffffffful; 2100Sstevel@tonic-gate uint_t pci_lock_tlb = 0; 2110Sstevel@tonic-gate uint64_t pci_dvma_debug_on = 0; 2120Sstevel@tonic-gate uint64_t pci_dvma_debug_off = 0; 2130Sstevel@tonic-gate uint32_t pci_dvma_debug_rec = 512; 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate /* 2160Sstevel@tonic-gate * dvma address space allocation cache variables 2170Sstevel@tonic-gate */ 2180Sstevel@tonic-gate uint_t pci_dvma_page_cache_entries = 0x200; /* # of chunks (1 << bits) */ 2190Sstevel@tonic-gate uint_t pci_dvma_page_cache_clustsz = 0x8; /* # of pages per chunk */ 2200Sstevel@tonic-gate #ifdef PCI_DMA_PROF 2210Sstevel@tonic-gate uint_t pci_dvmaft_npages = 0; /* FT fail due npages */ 2220Sstevel@tonic-gate uint_t pci_dvmaft_limit = 0; /* FT fail due limits */ 2230Sstevel@tonic-gate uint_t pci_dvmaft_free = 0; /* FT free */ 2240Sstevel@tonic-gate uint_t pci_dvmaft_success = 0; /* FT success */ 2250Sstevel@tonic-gate uint_t pci_dvmaft_exhaust = 0; /* FT vmem fallback */ 2260Sstevel@tonic-gate uint_t pci_dvma_vmem_alloc = 0; /* vmem alloc */ 2270Sstevel@tonic-gate uint_t pci_dvma_vmem_xalloc = 0; /* vmem xalloc */ 2280Sstevel@tonic-gate uint_t pci_dvma_vmem_xfree = 0; /* vmem xfree */ 2290Sstevel@tonic-gate uint_t pci_dvma_vmem_free = 0; /* vmem free */ 2300Sstevel@tonic-gate #endif 2310Sstevel@tonic-gate uint_t pci_disable_fdvma = 0; 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate uint_t pci_iommu_ctx_lock_failure = 0; 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate /* 2360Sstevel@tonic-gate * This flag preserves prom iommu settings by copying prom TSB entries 2370Sstevel@tonic-gate * to corresponding kernel TSB entry locations. It should be removed 2380Sstevel@tonic-gate * after the interface properties from obp have become default. 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate uint_t pci_preserve_iommu_tsb = 1; 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate /* 2430Sstevel@tonic-gate * memory callback list id callback list for kmem_alloc failure clients 2440Sstevel@tonic-gate */ 2450Sstevel@tonic-gate uintptr_t pci_kmem_clid = 0; 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate /* 2480Sstevel@tonic-gate * Perform a consistent-mode sync/flush during interrupt. 2490Sstevel@tonic-gate */ 2500Sstevel@tonic-gate uint_t pci_intr_dma_sync = 0; 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate /* 2530Sstevel@tonic-gate * This flag is used to enable max prefetch streaming cache mode 2540Sstevel@tonic-gate * feature of XMITS. 2550Sstevel@tonic-gate */ 2560Sstevel@tonic-gate uint_t pci_xmits_sc_max_prf = 0; 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate /* 2590Sstevel@tonic-gate * This flag is used to enable pcix error reporting in XMITS. 2600Sstevel@tonic-gate */ 2610Sstevel@tonic-gate uint64_t xmits_error_intr_enable = -1ull; 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate /* 2640Sstevel@tonic-gate * Enable parity error recovery for xmits 2650Sstevel@tonic-gate */ 2660Sstevel@tonic-gate uint_t xmits_perr_recov_int_enable = 0; 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate /* 2690Sstevel@tonic-gate * This flag controls whether or not DVMA remap support is 2700Sstevel@tonic-gate * enabled (currently, Schizo/XMITS only). 2710Sstevel@tonic-gate */ 2720Sstevel@tonic-gate int pci_dvma_remap_enabled = 0; 2730Sstevel@tonic-gate 2740Sstevel@tonic-gate /* 2750Sstevel@tonic-gate * Serialize PCI relocations, since they are time critical. 2760Sstevel@tonic-gate */ 2770Sstevel@tonic-gate kthread_t *pci_reloc_thread = NULL; 2780Sstevel@tonic-gate kmutex_t pci_reloc_mutex; 2790Sstevel@tonic-gate kcondvar_t pci_reloc_cv; 2800Sstevel@tonic-gate int pci_reloc_presuspend = 0; 2810Sstevel@tonic-gate int pci_reloc_suspend = 0; 2820Sstevel@tonic-gate id_t pci_dvma_cbid; 2830Sstevel@tonic-gate id_t pci_fast_dvma_cbid; 2840Sstevel@tonic-gate int pci_dma_panic_on_leak = 0; 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate /* 2870Sstevel@tonic-gate * Set Outstanding Maximum Split Transactions. Legal settings are: 2880Sstevel@tonic-gate * 0 = 1 Outstanding Transacation, 1 = 2, 2 = 3, 3 = 4, 4 = 8, 5 = 12, 2890Sstevel@tonic-gate * 6 = 16, 7 = 32. 2900Sstevel@tonic-gate */ 2910Sstevel@tonic-gate uint_t xmits_max_transactions = 0; 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate /* 2940Sstevel@tonic-gate * Set Max Memory Read Byte Count. Legal settings are: 2950Sstevel@tonic-gate * 0 = 512 Max Memory Read Bytes, 1 = 1024, 2 = 2048, 3 = 4096. 2960Sstevel@tonic-gate */ 2970Sstevel@tonic-gate uint_t xmits_max_read_bytes = 0; 2981295Sdanice 2991295Sdanice /* 3001295Sdanice * Bits 15:0 increase the maximum PIO retries allowed by XMITS. 3011295Sdanice */ 3021486Sdanice uint_t xmits_upper_retry_counter = 0x3E8; 3032358Sdanice 3042358Sdanice /* 3052358Sdanice * default values for xmits pcix diag BUG_FIX_CNTL bits 47:32 3062358Sdanice * depending on mode: pcix or pci. 3072358Sdanice */ 3082358Sdanice uint_t xmits_pcix_diag_bugcntl_pcix = 0xA0; 3092358Sdanice uint_t xmits_pcix_diag_bugcntl_pci = 0xFF; 310