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