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
55cff7825Smh  * Common Development and Distribution License (the "License").
65cff7825Smh  * 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 /*
22b9e93c10SJonathan Haslam  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/systm.h>
287c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
297c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
307c478bd9Sstevel@tonic-gate #include <sys/archsystm.h>
317c478bd9Sstevel@tonic-gate #include <sys/vmsystm.h>
327c478bd9Sstevel@tonic-gate #include <sys/machparam.h>
337c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
347c478bd9Sstevel@tonic-gate #include <sys/machthread.h>
357c478bd9Sstevel@tonic-gate #include <sys/cpu.h>
367c478bd9Sstevel@tonic-gate #include <sys/cmp.h>
377c478bd9Sstevel@tonic-gate #include <sys/elf_SPARC.h>
387c478bd9Sstevel@tonic-gate #include <vm/hat_sfmmu.h>
397c478bd9Sstevel@tonic-gate #include <vm/seg_kmem.h>
407c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
417c478bd9Sstevel@tonic-gate #include <sys/cheetahregs.h>
427c478bd9Sstevel@tonic-gate #include <sys/us3_module.h>
437c478bd9Sstevel@tonic-gate #include <sys/async.h>
447c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
457c478bd9Sstevel@tonic-gate #include <sys/debug.h>
467c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
477c478bd9Sstevel@tonic-gate #include <sys/prom_debug.h>
487c478bd9Sstevel@tonic-gate #include <sys/prom_plat.h>
497c478bd9Sstevel@tonic-gate #include <sys/cpu_module.h>
507c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
517c478bd9Sstevel@tonic-gate #include <sys/intreg.h>
527c478bd9Sstevel@tonic-gate #include <sys/clock.h>
537c478bd9Sstevel@tonic-gate #include <sys/platform_module.h>
547c478bd9Sstevel@tonic-gate #include <sys/machtrap.h>
557c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
567c478bd9Sstevel@tonic-gate #include <sys/panic.h>
577c478bd9Sstevel@tonic-gate #include <sys/memlist.h>
587c478bd9Sstevel@tonic-gate #include <sys/bootconf.h>
597c478bd9Sstevel@tonic-gate #include <sys/ivintr.h>
607c478bd9Sstevel@tonic-gate #include <sys/atomic.h>
617c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h>
627c478bd9Sstevel@tonic-gate #include <sys/fm/cpu/UltraSPARC-III.h>
637c478bd9Sstevel@tonic-gate #include <sys/errclassify.h>
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #ifdef	CHEETAHPLUS_ERRATUM_25
667c478bd9Sstevel@tonic-gate #include <sys/cyclic.h>
677c478bd9Sstevel@tonic-gate #endif	/* CHEETAHPLUS_ERRATUM_25 */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* cpu estar private data */
707c478bd9Sstevel@tonic-gate typedef struct {
717c478bd9Sstevel@tonic-gate 	uint8_t state : 7;
727c478bd9Sstevel@tonic-gate 	uint8_t valid : 1;
737c478bd9Sstevel@tonic-gate } mcu_fsm_def_t;
747c478bd9Sstevel@tonic-gate mcu_fsm_def_t mcu_fsm_init_state[NCPU];
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #if defined(JALAPENO) && defined(JALAPENO_ERRATA_85)
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * jp_errata_85_enable can be set to 0 in /etc/system to disable
797c478bd9Sstevel@tonic-gate  * JP Errata 85 workaround.
807c478bd9Sstevel@tonic-gate  *
817c478bd9Sstevel@tonic-gate  * jp_errata_85_allow_slow_scrub is usually set to !jp_errata_85_enable,
827c478bd9Sstevel@tonic-gate  * but can be overridden in /etc/system.  If set, it allows the scrubber
837c478bd9Sstevel@tonic-gate  * to run in 1/2 or 1/32 mode.  If a cpu is vulnerable to errata 85,
847c478bd9Sstevel@tonic-gate  * this value should be zero.
857c478bd9Sstevel@tonic-gate  *
867c478bd9Sstevel@tonic-gate  * jp_errata_85_active is an internal variable and must not be
877c478bd9Sstevel@tonic-gate  * set/changed via /etc/system or in any other way.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate extern int	jp_errata_85_enable;	/* for /etc/system use */
907c478bd9Sstevel@tonic-gate extern int	jp_errata_85_allow_slow_scrub;	/* for /etc/system use */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate int	jp_errata_85_active = -1;	/* warn: modified in code ONLY */
937c478bd9Sstevel@tonic-gate uint64_t	jp_estar_tl0_data[8];
947c478bd9Sstevel@tonic-gate uint64_t	jp_estar_tl1_data[8];
957c478bd9Sstevel@tonic-gate #endif	/* JALAPENO && JALAPENO_ERRATA_85 */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate /*
987c478bd9Sstevel@tonic-gate  * Setup trap handlers.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate void
cpu_init_trap(void)1017c478bd9Sstevel@tonic-gate cpu_init_trap(void)
1027c478bd9Sstevel@tonic-gate {
103b9e93c10SJonathan Haslam 	CH_SET_TRAP(pil15_epilogue, ch_pil15_interrupt_instr);
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt0_fecc, fecc_err_instr);
1067c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt1_fecc, fecc_err_tl1_instr);
1077c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt1_swtrap0, fecc_err_tl1_cont_instr);
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt0_dperr, dcache_parity_instr);
1107c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt1_dperr, dcache_parity_tl1_instr);
1117c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt1_swtrap1, dcache_parity_tl1_cont_instr);
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt0_iperr, icache_parity_instr);
1147c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt1_iperr, icache_parity_tl1_instr);
1157c478bd9Sstevel@tonic-gate 	CH_SET_TRAP(tt1_swtrap2, icache_parity_tl1_cont_instr);
1167c478bd9Sstevel@tonic-gate }
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate static int
getintprop(pnode_t node,char * name,int deflt)120fa9e4066Sahrens getintprop(pnode_t node, char *name, int deflt)
1217c478bd9Sstevel@tonic-gate {
1227c478bd9Sstevel@tonic-gate 	int	value;
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 	switch (prom_getproplen(node, name)) {
1257c478bd9Sstevel@tonic-gate 	case sizeof (int):
1267c478bd9Sstevel@tonic-gate 		(void) prom_getprop(node, name, (caddr_t)&value);
1277c478bd9Sstevel@tonic-gate 		break;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 	default:
1307c478bd9Sstevel@tonic-gate 		value = deflt;
1317c478bd9Sstevel@tonic-gate 		break;
1327c478bd9Sstevel@tonic-gate 	}
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 	return (value);
1357c478bd9Sstevel@tonic-gate }
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate /*
1387c478bd9Sstevel@tonic-gate  * Set the magic constants of the implementation.
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1417c478bd9Sstevel@tonic-gate void
cpu_fiximp(pnode_t dnode)142fa9e4066Sahrens cpu_fiximp(pnode_t dnode)
1437c478bd9Sstevel@tonic-gate {
1447c478bd9Sstevel@tonic-gate 	int i, a;
1457c478bd9Sstevel@tonic-gate 	extern int vac_size, vac_shift;
1467c478bd9Sstevel@tonic-gate 	extern uint_t vac_mask;
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 	static struct {
1497c478bd9Sstevel@tonic-gate 		char	*name;
1507c478bd9Sstevel@tonic-gate 		int	*var;
1517c478bd9Sstevel@tonic-gate 		int	defval;
1527c478bd9Sstevel@tonic-gate 	} prop[] = {
1537c478bd9Sstevel@tonic-gate 		"dcache-size", &dcache_size, CH_DCACHE_SIZE,
1547c478bd9Sstevel@tonic-gate 		"dcache-line-size", &dcache_linesize, CH_DCACHE_LSIZE,
1557c478bd9Sstevel@tonic-gate 		"icache-size", &icache_size, CH_ICACHE_SIZE,
1567c478bd9Sstevel@tonic-gate 		"icache-line-size", &icache_linesize, CH_ICACHE_LSIZE,
1577c478bd9Sstevel@tonic-gate 		"ecache-size", &ecache_size, JP_ECACHE_MAX_SIZE,
1587c478bd9Sstevel@tonic-gate 		"ecache-line-size", &ecache_alignsize, JP_ECACHE_MAX_LSIZE,
1597c478bd9Sstevel@tonic-gate 		"ecache-associativity", &ecache_associativity, JP_ECACHE_NWAY
1607c478bd9Sstevel@tonic-gate 	};
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (prop) / sizeof (prop[0]); i++)
1637c478bd9Sstevel@tonic-gate 		*prop[i].var = getintprop(dnode, prop[i].name, prop[i].defval);
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 	ecache_setsize = ecache_size / ecache_associativity;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate 	vac_size = CH_VAC_SIZE;
1687c478bd9Sstevel@tonic-gate 	vac_mask = MMU_PAGEMASK & (vac_size - 1);
1697c478bd9Sstevel@tonic-gate 	i = 0; a = vac_size;
1707c478bd9Sstevel@tonic-gate 	while (a >>= 1)
1717c478bd9Sstevel@tonic-gate 		++i;
1727c478bd9Sstevel@tonic-gate 	vac_shift = i;
1737c478bd9Sstevel@tonic-gate 	shm_alignment = vac_size;
1747c478bd9Sstevel@tonic-gate 	vac = 1;
1757c478bd9Sstevel@tonic-gate }
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate void
send_mondo_set(cpuset_t set)1787c478bd9Sstevel@tonic-gate send_mondo_set(cpuset_t set)
1797c478bd9Sstevel@tonic-gate {
1807c478bd9Sstevel@tonic-gate 	int lo, busy, nack, shipped = 0;
1817c478bd9Sstevel@tonic-gate 	uint16_t i, cpuids[IDSR_BN_SETS];
1827c478bd9Sstevel@tonic-gate 	uint64_t idsr, nackmask = 0, busymask, curnack, curbusy;
1837c478bd9Sstevel@tonic-gate 	uint64_t starttick, endtick, tick, lasttick;
1847c478bd9Sstevel@tonic-gate #ifdef	CHEETAHPLUS_ERRATUM_25
1857c478bd9Sstevel@tonic-gate 	int recovered = 0;
1867c478bd9Sstevel@tonic-gate 	int cpuid;
1877c478bd9Sstevel@tonic-gate #endif
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate 	ASSERT(!CPUSET_ISNULL(set));
1907c478bd9Sstevel@tonic-gate 	starttick = lasttick = gettick();
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 	/*
1937c478bd9Sstevel@tonic-gate 	 * Lower 2 bits of the agent ID determine which BUSY/NACK pair
1947c478bd9Sstevel@tonic-gate 	 * will be used for dispatching interrupt. For now, assume
1957c478bd9Sstevel@tonic-gate 	 * there are no more than IDSR_BN_SETS CPUs, hence no aliasing
1967c478bd9Sstevel@tonic-gate 	 * issues with respect to BUSY/NACK pair usage.
1977c478bd9Sstevel@tonic-gate 	 */
1987c478bd9Sstevel@tonic-gate 	for (i = 0; i < NCPU; i++)
1997c478bd9Sstevel@tonic-gate 		if (CPU_IN_SET(set, i)) {
2007c478bd9Sstevel@tonic-gate 			shipit(i, shipped /* ignored */);
2017c478bd9Sstevel@tonic-gate 			nackmask |= IDSR_NACK_BIT(CPUID_TO_BN_PAIR(i));
2027c478bd9Sstevel@tonic-gate 			cpuids[CPUID_TO_BN_PAIR(i)] = i;
2037c478bd9Sstevel@tonic-gate 			shipped++;
2047c478bd9Sstevel@tonic-gate 			CPUSET_DEL(set, i);
2057c478bd9Sstevel@tonic-gate 			if (CPUSET_ISNULL(set))
2067c478bd9Sstevel@tonic-gate 				break;
2077c478bd9Sstevel@tonic-gate 		}
2087c478bd9Sstevel@tonic-gate 	CPU_STATS_ADDQ(CPU, sys, xcalls, shipped);
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 	busymask = IDSR_NACK_TO_BUSY(nackmask);
2117c478bd9Sstevel@tonic-gate 	busy = nack = 0;
2127c478bd9Sstevel@tonic-gate 	endtick = starttick + xc_tick_limit;
2137c478bd9Sstevel@tonic-gate 	for (;;) {
2147c478bd9Sstevel@tonic-gate 		idsr = getidsr();
2157c478bd9Sstevel@tonic-gate 		if (idsr == 0)
2167c478bd9Sstevel@tonic-gate 			break;
2177c478bd9Sstevel@tonic-gate 		tick = gettick();
2187c478bd9Sstevel@tonic-gate 		/*
2197c478bd9Sstevel@tonic-gate 		 * If there is a big jump between the current tick
2207c478bd9Sstevel@tonic-gate 		 * count and lasttick, we have probably hit a break
2217c478bd9Sstevel@tonic-gate 		 * point.  Adjust endtick accordingly to avoid panic.
2227c478bd9Sstevel@tonic-gate 		 */
2237c478bd9Sstevel@tonic-gate 		if (tick > (lasttick + xc_tick_jump_limit))
2247c478bd9Sstevel@tonic-gate 			endtick += (tick - lasttick);
2257c478bd9Sstevel@tonic-gate 		lasttick = tick;
2267c478bd9Sstevel@tonic-gate 		if (tick > endtick) {
2277c478bd9Sstevel@tonic-gate 			if (panic_quiesce)
2287c478bd9Sstevel@tonic-gate 				return;
2297c478bd9Sstevel@tonic-gate #ifdef	CHEETAHPLUS_ERRATUM_25
2307c478bd9Sstevel@tonic-gate 			cpuid = -1;
2317c478bd9Sstevel@tonic-gate 			for (i = 0; i < IDSR_BN_SETS; i++) {
2327c478bd9Sstevel@tonic-gate 				if (idsr & (IDSR_NACK_BIT(i) |
2337c478bd9Sstevel@tonic-gate 				    IDSR_BUSY_BIT(i))) {
2347c478bd9Sstevel@tonic-gate 					cpuid = cpuids[i];
2357c478bd9Sstevel@tonic-gate 					break;
2367c478bd9Sstevel@tonic-gate 				}
2377c478bd9Sstevel@tonic-gate 			}
2387c478bd9Sstevel@tonic-gate 			if (cheetah_sendmondo_recover && cpuid != -1 &&
2397c478bd9Sstevel@tonic-gate 			    recovered == 0) {
2407c478bd9Sstevel@tonic-gate 				if (mondo_recover(cpuid, i)) {
2417c478bd9Sstevel@tonic-gate 					/*
2427c478bd9Sstevel@tonic-gate 					 * We claimed the whole memory or
2437c478bd9Sstevel@tonic-gate 					 * full scan is disabled.
2447c478bd9Sstevel@tonic-gate 					 */
2457c478bd9Sstevel@tonic-gate 					recovered++;
2467c478bd9Sstevel@tonic-gate 				}
2477c478bd9Sstevel@tonic-gate 				tick = gettick();
2487c478bd9Sstevel@tonic-gate 				endtick = tick + xc_tick_limit;
2497c478bd9Sstevel@tonic-gate 				lasttick = tick;
2507c478bd9Sstevel@tonic-gate 				/*
2517c478bd9Sstevel@tonic-gate 				 * Recheck idsr
2527c478bd9Sstevel@tonic-gate 				 */
2537c478bd9Sstevel@tonic-gate 				continue;
2547c478bd9Sstevel@tonic-gate 			} else
2557c478bd9Sstevel@tonic-gate #endif	/* CHEETAHPLUS_ERRATUM_25 */
2567c478bd9Sstevel@tonic-gate 			{
2577c478bd9Sstevel@tonic-gate 				cmn_err(CE_CONT, "send mondo timeout "
2587c478bd9Sstevel@tonic-gate 				    "[%d NACK %d BUSY]\nIDSR 0x%"
2597c478bd9Sstevel@tonic-gate 				    "" PRIx64 "  cpuids:", nack, busy, idsr);
2607c478bd9Sstevel@tonic-gate 				for (i = 0; i < IDSR_BN_SETS; i++) {
2617c478bd9Sstevel@tonic-gate 					if (idsr & (IDSR_NACK_BIT(i) |
2627c478bd9Sstevel@tonic-gate 					    IDSR_BUSY_BIT(i))) {
2637c478bd9Sstevel@tonic-gate 						cmn_err(CE_CONT, " 0x%x",
2647c478bd9Sstevel@tonic-gate 						    cpuids[i]);
2657c478bd9Sstevel@tonic-gate 					}
2667c478bd9Sstevel@tonic-gate 				}
2677c478bd9Sstevel@tonic-gate 				cmn_err(CE_CONT, "\n");
2687c478bd9Sstevel@tonic-gate 				cmn_err(CE_PANIC, "send_mondo_set: timeout");
2697c478bd9Sstevel@tonic-gate 			}
2707c478bd9Sstevel@tonic-gate 		}
2717c478bd9Sstevel@tonic-gate 		curnack = idsr & nackmask;
2727c478bd9Sstevel@tonic-gate 		curbusy = idsr & busymask;
2737c478bd9Sstevel@tonic-gate 		if (curbusy) {
2747c478bd9Sstevel@tonic-gate 			busy++;
2757c478bd9Sstevel@tonic-gate 			continue;
2767c478bd9Sstevel@tonic-gate 		}
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate #ifdef SEND_MONDO_STATS
2797c478bd9Sstevel@tonic-gate 		{
2807c478bd9Sstevel@tonic-gate 			int n = gettick() - starttick;
2817c478bd9Sstevel@tonic-gate 			if (n < 8192)
2827c478bd9Sstevel@tonic-gate 				x_nack_stimes[n >> 7]++;
2837c478bd9Sstevel@tonic-gate 		}
2847c478bd9Sstevel@tonic-gate #endif
2857c478bd9Sstevel@tonic-gate 		while (gettick() < (tick + sys_clock_mhz))
2867c478bd9Sstevel@tonic-gate 			;
2877c478bd9Sstevel@tonic-gate 		do {
2887c478bd9Sstevel@tonic-gate 			lo = lowbit(curnack) - 1;
2897c478bd9Sstevel@tonic-gate 			i = IDSR_NACK_IDX(lo);
2907c478bd9Sstevel@tonic-gate 			shipit(cpuids[i], i);
2917c478bd9Sstevel@tonic-gate 			curnack &= ~(1ull << lo);
2927c478bd9Sstevel@tonic-gate 		} while (curnack);
2937c478bd9Sstevel@tonic-gate 		nack++;
2947c478bd9Sstevel@tonic-gate 		busy = 0;
2957c478bd9Sstevel@tonic-gate 	}
2967c478bd9Sstevel@tonic-gate #ifdef SEND_MONDO_STATS
2977c478bd9Sstevel@tonic-gate 	{
2987c478bd9Sstevel@tonic-gate 		int n = gettick() - starttick;
2997c478bd9Sstevel@tonic-gate 		if (n < 8192)
3007c478bd9Sstevel@tonic-gate 			x_set_stimes[n >> 7]++;
3017c478bd9Sstevel@tonic-gate 		else
3027c478bd9Sstevel@tonic-gate 			x_set_ltimes[(n >> 13) & 0xf]++;
3037c478bd9Sstevel@tonic-gate 	}
3047c478bd9Sstevel@tonic-gate 	x_set_cpus[shipped]++;
3057c478bd9Sstevel@tonic-gate #endif
3067c478bd9Sstevel@tonic-gate }
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate /*
3097c478bd9Sstevel@tonic-gate  * Handles error logging for implementation specific error types
3107c478bd9Sstevel@tonic-gate  */
3117c478bd9Sstevel@tonic-gate int
cpu_impl_async_log_err(void * flt,errorq_elem_t * eqep)3127c478bd9Sstevel@tonic-gate cpu_impl_async_log_err(void *flt, errorq_elem_t *eqep)
3137c478bd9Sstevel@tonic-gate {
3147c478bd9Sstevel@tonic-gate 	ch_async_flt_t *ch_flt = (ch_async_flt_t *)flt;
3157c478bd9Sstevel@tonic-gate 	struct async_flt *aflt = (struct async_flt *)flt;
316db874c57Selowe 	uint64_t errors;
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 	switch (ch_flt->flt_type) {
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate 	case CPU_IC_PARITY:
3217c478bd9Sstevel@tonic-gate 		cpu_async_log_ic_parity_err(flt);
3227c478bd9Sstevel@tonic-gate 		return (CH_ASYNC_LOG_DONE);
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate 	case CPU_DC_PARITY:
3257c478bd9Sstevel@tonic-gate 		cpu_async_log_dc_parity_err(flt);
3267c478bd9Sstevel@tonic-gate 		return (CH_ASYNC_LOG_DONE);
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate 	case CPU_RCE:
329db874c57Selowe 		if (page_retire_check(aflt->flt_addr, &errors) == EINVAL) {
3307c478bd9Sstevel@tonic-gate 			CE_XDIAG_SETSKIPCODE(aflt->flt_disp,
3317c478bd9Sstevel@tonic-gate 			    CE_XDIAG_SKIP_NOPP);
332db874c57Selowe 		} else if (errors != PR_OK) {
333db874c57Selowe 			CE_XDIAG_SETSKIPCODE(aflt->flt_disp,
334db874c57Selowe 			    CE_XDIAG_SKIP_PAGEDET);
335db874c57Selowe 		} else if (ce_scrub_xdiag_recirc(aflt, ce_queue, eqep,
336db874c57Selowe 		    offsetof(ch_async_flt_t, cmn_asyncflt))) {
337db874c57Selowe 			return (CH_ASYNC_LOG_RECIRC);
3387c478bd9Sstevel@tonic-gate 		}
3397c478bd9Sstevel@tonic-gate 		/*FALLTHRU*/
3407c478bd9Sstevel@tonic-gate 	/*
3417c478bd9Sstevel@tonic-gate 	 * cases where we just want to report the error and continue.
3427c478bd9Sstevel@tonic-gate 	 */
3437c478bd9Sstevel@tonic-gate 	case CPU_BPAR:
3447c478bd9Sstevel@tonic-gate 	case CPU_UMS:
3457c478bd9Sstevel@tonic-gate 	case CPU_FRC:
3467c478bd9Sstevel@tonic-gate 	case CPU_FRU:
3477c478bd9Sstevel@tonic-gate 		cpu_log_err(aflt);
3487c478bd9Sstevel@tonic-gate 		return (CH_ASYNC_LOG_DONE);
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate 	/*
3517c478bd9Sstevel@tonic-gate 	 * Cases where we want to fall through to handle panicking.
3527c478bd9Sstevel@tonic-gate 	 */
3537c478bd9Sstevel@tonic-gate 	case CPU_RUE:
3547c478bd9Sstevel@tonic-gate 		cpu_log_err(aflt);
3557c478bd9Sstevel@tonic-gate 		return (CH_ASYNC_LOG_CONTINUE);
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate 	default:
3587c478bd9Sstevel@tonic-gate 		return (CH_ASYNC_LOG_UNKNOWN);
3597c478bd9Sstevel@tonic-gate 	}
3607c478bd9Sstevel@tonic-gate }
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate /*
3637c478bd9Sstevel@tonic-gate  * Figure out if Ecache is direct-mapped (Cheetah or Cheetah+ with Ecache
3647c478bd9Sstevel@tonic-gate  * control ECCR_ASSOC bit off or 2-way (Cheetah+ with ECCR_ASSOC on).
3657c478bd9Sstevel@tonic-gate  * We need to do this on the fly because we may have mixed Cheetah+'s with
3667c478bd9Sstevel@tonic-gate  * both direct and 2-way Ecaches.
3677c478bd9Sstevel@tonic-gate  */
3687c478bd9Sstevel@tonic-gate int
cpu_ecache_nway(void)3697c478bd9Sstevel@tonic-gate cpu_ecache_nway(void)
3707c478bd9Sstevel@tonic-gate {
3717c478bd9Sstevel@tonic-gate 	return (JP_ECACHE_NWAY);
3727c478bd9Sstevel@tonic-gate }
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate /*
3757c478bd9Sstevel@tonic-gate  * Note that these are entered into the table in the order:
3767c478bd9Sstevel@tonic-gate  * Fatal Errors first, orphaned UCU/UCC, AFAR Overwrite policy,
3777c478bd9Sstevel@tonic-gate  * FRC/FRU, and finally IVPE.
3787c478bd9Sstevel@tonic-gate  *
3797c478bd9Sstevel@tonic-gate  * Afar overwrite policy is:
3807c478bd9Sstevel@tonic-gate  * Jalapeno:
3817c478bd9Sstevel@tonic-gate  *   UCU,UCC > RUE,UE,EDU,WDU,CPU,WBP,BP > RCE,CE,EDC,WDC,CPC >
3827c478bd9Sstevel@tonic-gate  *   TO,BERR > UMS,OM
3837c478bd9Sstevel@tonic-gate  * Serrano:
3847c478bd9Sstevel@tonic-gate  *   UCU,UCC > RUE,UE,EDU,WDU,CPU,WBP,BP > RCE,CE,EDC,WDC,CPC,ETI,ETC >
3857c478bd9Sstevel@tonic-gate  *   TO,BERR > UMS,OM
3867c478bd9Sstevel@tonic-gate  */
3877c478bd9Sstevel@tonic-gate ecc_type_to_info_t ecc_type_to_info[] = {
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate 	/* Fatal Errors */
3907c478bd9Sstevel@tonic-gate 	C_AFSR_JETO,	"JETO ",	ECC_ALL_TRAPS,	CPU_FATAL,
3917c478bd9Sstevel@tonic-gate 		"JETO Fatal",
3927c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM1,
3937c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_JETO,
3947c478bd9Sstevel@tonic-gate 	C_AFSR_SCE,	"SCE ",		ECC_ALL_TRAPS,	CPU_FATAL,
3957c478bd9Sstevel@tonic-gate 		"SCE Fatal",
3967c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM1,
3977c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_SCE,
3987c478bd9Sstevel@tonic-gate 	C_AFSR_JEIC,	"JEIC ",	ECC_ALL_TRAPS,	CPU_FATAL,
3997c478bd9Sstevel@tonic-gate 		"JEIC Fatal",
4007c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM1,
4017c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_JEIC,
4027c478bd9Sstevel@tonic-gate 	C_AFSR_JEIT,	"JEIT ",	ECC_ALL_TRAPS,	CPU_FATAL,
4037c478bd9Sstevel@tonic-gate 		"JEIT Fatal",
4047c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM1,
4057c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_JEIT,
4067c478bd9Sstevel@tonic-gate 	C_AFSR_JEIS,	"JEIS ",	ECC_ALL_TRAPS,	CPU_FATAL,
4077c478bd9Sstevel@tonic-gate 		"JEIS Fatal",
4087c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM1,
4097c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_JEIS,
4107c478bd9Sstevel@tonic-gate #if defined(JALAPENO)
4117c478bd9Sstevel@tonic-gate 	C_AFSR_ETP,	"ETP ",		ECC_ALL_TRAPS,	CPU_FATAL,
4127c478bd9Sstevel@tonic-gate 		"ETP Fatal",
4137c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_TAG_PE,
4147c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_ETP,
4157c478bd9Sstevel@tonic-gate #elif defined(SERRANO)
4167c478bd9Sstevel@tonic-gate 	C_AFSR_ETS,	"ETS ",		ECC_ASYNC_TRAPS, CPU_FATAL,
4177c478bd9Sstevel@tonic-gate 		"ETS Fatal",
4187c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_TAG_ECC,
4197c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_ETS,
4207c478bd9Sstevel@tonic-gate 	C_AFSR_ETU,	"ETU ",		ECC_ASYNC_TRAPS, CPU_FATAL,
4217c478bd9Sstevel@tonic-gate 		"ETU Fatal",
4227c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_TAG_ECC,
4237c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_ETU,
4247c478bd9Sstevel@tonic-gate #endif	/* SERRANO */
4257c478bd9Sstevel@tonic-gate 	C_AFSR_IERR,	"IERR ", 	ECC_ALL_TRAPS,	CPU_FATAL,
4267c478bd9Sstevel@tonic-gate 		"IERR Fatal",
4277c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM2,
4287c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_IERR,
4297c478bd9Sstevel@tonic-gate 	C_AFSR_ISAP,	"ISAP ",	ECC_ALL_TRAPS,	CPU_FATAL,
4307c478bd9Sstevel@tonic-gate 		"ISAP Fatal",
4317c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM1,
4327c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_ISAP,
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate 	/* Orphaned UCU/UCC Errors */
4357c478bd9Sstevel@tonic-gate 	C_AFSR_UCU,	"OUCU ",	ECC_ORPH_TRAPS, CPU_ORPH,
4367c478bd9Sstevel@tonic-gate 		"Orphaned UCU",
4377c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4387c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_UCU,
4397c478bd9Sstevel@tonic-gate 	C_AFSR_UCC,	"OUCC ",	ECC_ORPH_TRAPS, CPU_ORPH,
4407c478bd9Sstevel@tonic-gate 		"Orphaned UCC",
4417c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4427c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_UCC,
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate 	/* UCU, UCC */
4457c478bd9Sstevel@tonic-gate 	C_AFSR_UCU,	"UCU ",		ECC_F_TRAP,	CPU_UE_ECACHE,
4467c478bd9Sstevel@tonic-gate 		"UCU",
4477c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4487c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_UCU,
4497c478bd9Sstevel@tonic-gate 	C_AFSR_UCC,	"UCC ",		ECC_F_TRAP,	CPU_CE_ECACHE,
4507c478bd9Sstevel@tonic-gate 		"UCC",
4517c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4527c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_UCC,
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate 	/* RUE, UE, EDU:ST, EDU:BLD, WDU, CPU, BP, WBP */
4567c478bd9Sstevel@tonic-gate 	C_AFSR_RUE,	"RUE ",		ECC_ASYNC_TRAPS, CPU_RUE,
4577c478bd9Sstevel@tonic-gate 		"Uncorrectable remote memory/cache (RUE)",
4587c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_MEMORY,
4597c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_RUE,
4607c478bd9Sstevel@tonic-gate 	C_AFSR_UE,	"UE ",		ECC_ASYNC_TRAPS, CPU_UE,
4617c478bd9Sstevel@tonic-gate 		"Uncorrectable memory (UE)",
4627c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_MEMORY,
4637c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_UE,
4647c478bd9Sstevel@tonic-gate 	C_AFSR_EDU,	"EDU ",		ECC_C_TRAP,	CPU_UE_ECACHE_RETIRE,
4657c478bd9Sstevel@tonic-gate 		"EDU:ST",
4667c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4677c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_EDUST,
4687c478bd9Sstevel@tonic-gate 	C_AFSR_EDU,	"EDU ",		ECC_D_TRAP,	CPU_UE_ECACHE_RETIRE,
4697c478bd9Sstevel@tonic-gate 		"EDU:BLD",
4707c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4717c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_EDUBL,
4727c478bd9Sstevel@tonic-gate 	C_AFSR_WDU,	"WDU ",		ECC_C_TRAP,	CPU_UE_ECACHE_RETIRE,
4737c478bd9Sstevel@tonic-gate 		"WDU",
4747c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4757c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_WDU,
4767c478bd9Sstevel@tonic-gate 	C_AFSR_CPU,	"CPU ",		ECC_C_TRAP,	CPU_UE_ECACHE,
4777c478bd9Sstevel@tonic-gate 		"CPU",
4787c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
4797c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_CPU,
4807c478bd9Sstevel@tonic-gate 	C_AFSR_WBP,	"WBP ",		ECC_C_TRAP,	CPU_BPAR,
4817c478bd9Sstevel@tonic-gate 		"JBUS parity error on writeback or block store (WBP)",
4827c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM3,
4837c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_WBP,
4847c478bd9Sstevel@tonic-gate 	C_AFSR_BP,	"BP ",		ECC_ASYNC_TRAPS, CPU_BPAR,
4857c478bd9Sstevel@tonic-gate 		"JBUS parity error on returned read data (BP)",
4867c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM3,
4877c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_BP,
4887c478bd9Sstevel@tonic-gate 
4897c478bd9Sstevel@tonic-gate 	/* RCE, CE, EDC, WDC, CPC */
4907c478bd9Sstevel@tonic-gate 	C_AFSR_RCE,	"RCE ",		ECC_C_TRAP,	CPU_RCE,
4917c478bd9Sstevel@tonic-gate 		"Corrected remote memory/cache (RCE)",
4927c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_MEMORY,
4937c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_RCE,
4947c478bd9Sstevel@tonic-gate 	C_AFSR_CE,	"CE ",		ECC_C_TRAP,	CPU_CE,
4957c478bd9Sstevel@tonic-gate 		"Corrected memory (CE)",
4967c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_MEMORY,
4977c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_CE,
4987c478bd9Sstevel@tonic-gate 	C_AFSR_EDC,	"EDC ",		ECC_C_TRAP,	CPU_CE_ECACHE,
4997c478bd9Sstevel@tonic-gate 		"EDC",
5007c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
5017c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_EDC,
5027c478bd9Sstevel@tonic-gate 	C_AFSR_WDC,	"WDC ",		ECC_C_TRAP,	CPU_CE_ECACHE,
5037c478bd9Sstevel@tonic-gate 		"WDC",
5047c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
5057c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_WDC,
5067c478bd9Sstevel@tonic-gate 	C_AFSR_CPC,	"CPC ",		ECC_C_TRAP,	CPU_CE_ECACHE,
5077c478bd9Sstevel@tonic-gate 		"CPC",
5087c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_DATA,
5097c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_CPC,
5107c478bd9Sstevel@tonic-gate #if defined(SERRANO)
5117c478bd9Sstevel@tonic-gate 	/* ETI, ETC */
5127c478bd9Sstevel@tonic-gate 	C_AFSR_ETI,	"ETI",	ECC_F_TRAP | ECC_C_TRAP, CPU_CE_ECACHE,
5137c478bd9Sstevel@tonic-gate 		"ETI",
5147c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_TAG_ECC,
5157c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_ETI,
5167c478bd9Sstevel@tonic-gate 	C_AFSR_ETC,	"ETC",	ECC_F_TRAP | ECC_C_TRAP, CPU_CE_ECACHE,
5177c478bd9Sstevel@tonic-gate 		"ETC",
5187c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_L2_TAG_ECC,
5197c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_ETC,
5207c478bd9Sstevel@tonic-gate #endif	/* SERRANO */
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate 	/* TO, BERR */
5237c478bd9Sstevel@tonic-gate 	C_AFSR_TO,	"TO ",		ECC_ASYNC_TRAPS, CPU_TO,
5247c478bd9Sstevel@tonic-gate 		"Timeout (TO)",
5257c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_IO,
5267c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_TO,
5277c478bd9Sstevel@tonic-gate 	C_AFSR_BERR,	"BERR ",	ECC_ASYNC_TRAPS, CPU_BERR,
5287c478bd9Sstevel@tonic-gate 		"Bus Error (BERR)",
5297c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_IO,
5307c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_BERR,
5317c478bd9Sstevel@tonic-gate 
5327c478bd9Sstevel@tonic-gate 	/* UMS, OM */
5337c478bd9Sstevel@tonic-gate 	C_AFSR_UMS,	"UMS ",		ECC_C_TRAP,	 CPU_UMS,
5347c478bd9Sstevel@tonic-gate 		"Unsupported store (UMS)",
5357c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_IO,
5367c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_UMS,
5377c478bd9Sstevel@tonic-gate 	C_AFSR_OM,	"OM ",		ECC_ASYNC_TRAPS, CPU_BERR,
5387c478bd9Sstevel@tonic-gate 		"Out of range memory (OM)",
5397c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_IO,
5407c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_OM,
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate 	/* FRC, FRU */
5437c478bd9Sstevel@tonic-gate 	C_AFSR_FRC,	"FRC ",		ECC_C_TRAP,	CPU_FRC,
5447c478bd9Sstevel@tonic-gate 		"Corrected memory (FRC)",
5457c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_MEMORY,
5467c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_FRC,
5477c478bd9Sstevel@tonic-gate 	C_AFSR_FRU,	"FRU ",		ECC_C_TRAP,	 CPU_FRU,
5487c478bd9Sstevel@tonic-gate 		"Uncorrectable memory (FRU)",
5497c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_MEMORY,
5507c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_FRU,
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate 	/* IVPE */
5537c478bd9Sstevel@tonic-gate 	C_AFSR_IVPE,	"IVPE ",	ECC_C_TRAP,	CPU_IV,
5547c478bd9Sstevel@tonic-gate 		"IVPE",
5557c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_SYSTEM1,
5567c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_IVPE,
5577c478bd9Sstevel@tonic-gate 
5587c478bd9Sstevel@tonic-gate 	0,		NULL,		0,		0,
5597c478bd9Sstevel@tonic-gate 		NULL,
5607c478bd9Sstevel@tonic-gate 		FM_EREPORT_PAYLOAD_UNKNOWN,
5617c478bd9Sstevel@tonic-gate 		FM_EREPORT_CPU_USIII_UNKNOWN,
5627c478bd9Sstevel@tonic-gate };
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate /*
5657c478bd9Sstevel@tonic-gate  * J_REQ overwrite policy (see UltraSPARC-IIIi PRM)
5667c478bd9Sstevel@tonic-gate  *
5677c478bd9Sstevel@tonic-gate  *   Class 4:  RUE, BP, WBP
5687c478bd9Sstevel@tonic-gate  *   Class 3:  RCE
5697c478bd9Sstevel@tonic-gate  *   Class 2:  TO, BERR
5707c478bd9Sstevel@tonic-gate  *   Class 1:  UMS
5717c478bd9Sstevel@tonic-gate  */
5727c478bd9Sstevel@tonic-gate uint64_t jreq_overwrite[] = {
5737c478bd9Sstevel@tonic-gate 	C_AFSR_RUE | C_AFSR_BP | C_AFSR_WBP,
5747c478bd9Sstevel@tonic-gate 	C_AFSR_RCE,
5757c478bd9Sstevel@tonic-gate 	C_AFSR_TO | C_AFSR_BERR,
5767c478bd9Sstevel@tonic-gate 	C_AFSR_UMS,
5777c478bd9Sstevel@tonic-gate 	0
5787c478bd9Sstevel@tonic-gate };
5797c478bd9Sstevel@tonic-gate 
5807c478bd9Sstevel@tonic-gate /*
5817c478bd9Sstevel@tonic-gate  * AGENT ID overwrite policy (see UltraSPARC-IIIi PRM)
5827c478bd9Sstevel@tonic-gate  *
5837c478bd9Sstevel@tonic-gate  *   Class 2:  CPU, FRU
5847c478bd9Sstevel@tonic-gate  *   Class 1:  CPC, FRC
5857c478bd9Sstevel@tonic-gate  */
5867c478bd9Sstevel@tonic-gate uint64_t jbus_aid_overwrite[] = {
5877c478bd9Sstevel@tonic-gate 	C_AFSR_CPU | C_AFSR_FRU,
5887c478bd9Sstevel@tonic-gate 	C_AFSR_CPC | C_AFSR_FRC,
5897c478bd9Sstevel@tonic-gate 	0
5907c478bd9Sstevel@tonic-gate };
5917c478bd9Sstevel@tonic-gate 
5927c478bd9Sstevel@tonic-gate int
afsr_to_jaid_status(uint64_t afsr,uint64_t afsr_bit)5937c478bd9Sstevel@tonic-gate afsr_to_jaid_status(uint64_t afsr, uint64_t afsr_bit)
5947c478bd9Sstevel@tonic-gate {
5957c478bd9Sstevel@tonic-gate 	return (afsr_to_overw_status(afsr, afsr_bit, jbus_aid_overwrite));
5967c478bd9Sstevel@tonic-gate }
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate /*
5997c478bd9Sstevel@tonic-gate  * See UltraSPARC-IIIi+ PRM
6007c478bd9Sstevel@tonic-gate  *   Class 5:  ETS, ETU, EFES
6017c478bd9Sstevel@tonic-gate  *   Class 4:  UCC, UCU
6027c478bd9Sstevel@tonic-gate  *   Class 3:  UE, RUE, BP, WBP, EDU, WDU, CPU
6037c478bd9Sstevel@tonic-gate  *   Class 2:  CE, RCE, EDC, WDC, CPC, ETI, ETC
6047c478bd9Sstevel@tonic-gate  *   Class 1:  TO, BERR
6057c478bd9Sstevel@tonic-gate  *   Class 0:  UMS, OM
6067c478bd9Sstevel@tonic-gate  *
6077c478bd9Sstevel@tonic-gate  * See UltraSPARC-IIIi PRM
6087c478bd9Sstevel@tonic-gate  *   Class 5:  ETP
6097c478bd9Sstevel@tonic-gate  *   Class 4:  UCC, UCU
6107c478bd9Sstevel@tonic-gate  *   Class 3:  UE, RUE, BP, WBP, EDU, WDU
6117c478bd9Sstevel@tonic-gate  *   Class 2:  CE, RCE, EDC, WDC
6127c478bd9Sstevel@tonic-gate  *   Class 1:  TO, BERR
6137c478bd9Sstevel@tonic-gate  *   Class 0:  UMS, OM
6147c478bd9Sstevel@tonic-gate  */
6157c478bd9Sstevel@tonic-gate uint64_t afar_overwrite[] = {
6167c478bd9Sstevel@tonic-gate #if defined(JALAPENO)
6177c478bd9Sstevel@tonic-gate 	C_AFSR_ETP,
6187c478bd9Sstevel@tonic-gate #elif defined(SERRANO)
6197c478bd9Sstevel@tonic-gate 	C_AFSR_ETS | C_AFSR_ETU | C_AFSR_EFES,
6207c478bd9Sstevel@tonic-gate #endif /* SERRANO */
6217c478bd9Sstevel@tonic-gate 	C_AFSR_UCC | C_AFSR_UCU,
6227c478bd9Sstevel@tonic-gate 	C_AFSR_UE | C_AFSR_RUE | C_AFSR_BP | C_AFSR_WBP | C_AFSR_EDU |
6237c478bd9Sstevel@tonic-gate 	    C_AFSR_WDU | C_AFSR_CPU,
6247c478bd9Sstevel@tonic-gate #if defined(SERRANO)
6257c478bd9Sstevel@tonic-gate 	C_AFSR_ETI | C_AFSR_ETC |
6267c478bd9Sstevel@tonic-gate #endif /* SERRANO */
6277c478bd9Sstevel@tonic-gate 	C_AFSR_CE | C_AFSR_RCE | C_AFSR_EDC | C_AFSR_WDC | C_AFSR_CPC,
6287c478bd9Sstevel@tonic-gate 	C_AFSR_TO | C_AFSR_BERR,
6297c478bd9Sstevel@tonic-gate 	C_AFSR_UMS | C_AFSR_OM,
6307c478bd9Sstevel@tonic-gate 	0
6317c478bd9Sstevel@tonic-gate };
6327c478bd9Sstevel@tonic-gate 
6337c478bd9Sstevel@tonic-gate #if defined(SERRANO)
6347c478bd9Sstevel@tonic-gate /*
6357c478bd9Sstevel@tonic-gate  * Serrano has a second AFAR that captures the physical address on
6367c478bd9Sstevel@tonic-gate  * FRC/FRU errors (which Jalapeno does not).  This register also
6377c478bd9Sstevel@tonic-gate  * captures the address for UE and CE errors.
6387c478bd9Sstevel@tonic-gate  *
6397c478bd9Sstevel@tonic-gate  * See UltraSPARC-IIIi+ PRM
6407c478bd9Sstevel@tonic-gate  *  Class 3: UE
6417c478bd9Sstevel@tonic-gate  *  Class 2: FRU
6427c478bd9Sstevel@tonic-gate  *  Class 1: CE
6437c478bd9Sstevel@tonic-gate  *  Class 0: FRC
6447c478bd9Sstevel@tonic-gate  */
6457c478bd9Sstevel@tonic-gate uint64_t afar2_overwrite[] = {
6467c478bd9Sstevel@tonic-gate 	C_AFSR_UE,
6477c478bd9Sstevel@tonic-gate 	C_AFSR_FRU,
6487c478bd9Sstevel@tonic-gate 	C_AFSR_CE,
6497c478bd9Sstevel@tonic-gate 	C_AFSR_FRC,
6507c478bd9Sstevel@tonic-gate 	0
6517c478bd9Sstevel@tonic-gate };
6527c478bd9Sstevel@tonic-gate #endif  /* SERRANO */
6537c478bd9Sstevel@tonic-gate 
6547c478bd9Sstevel@tonic-gate /*
6557c478bd9Sstevel@tonic-gate  * See UltraSPARC-IIIi PRM
6567c478bd9Sstevel@tonic-gate  *   Class 2:  UE, FRU, EDU, WDU, UCU, CPU
6577c478bd9Sstevel@tonic-gate  *   Class 1:  CE, FRC, EDC, WDC, UCC, CPC
6587c478bd9Sstevel@tonic-gate  */
6597c478bd9Sstevel@tonic-gate uint64_t esynd_overwrite[] = {
6607c478bd9Sstevel@tonic-gate #if defined(SERRANO)
6617c478bd9Sstevel@tonic-gate 	C_AFSR_ETS | C_AFSR_ETU |
6627c478bd9Sstevel@tonic-gate #endif	/* SERRANO */
6637c478bd9Sstevel@tonic-gate 	C_AFSR_UE | C_AFSR_FRU | C_AFSR_EDU | C_AFSR_WDU | C_AFSR_UCU |
6647c478bd9Sstevel@tonic-gate 	    C_AFSR_CPU,
6657c478bd9Sstevel@tonic-gate 	C_AFSR_CE | C_AFSR_FRC | C_AFSR_EDC | C_AFSR_WDC | C_AFSR_UCC |
6667c478bd9Sstevel@tonic-gate 	    C_AFSR_CPC,
6677c478bd9Sstevel@tonic-gate 	0
6687c478bd9Sstevel@tonic-gate };
6697c478bd9Sstevel@tonic-gate 
6707c478bd9Sstevel@tonic-gate /*
6717c478bd9Sstevel@tonic-gate  * Prioritized list of Error bits for BSYND (referred to as
6727c478bd9Sstevel@tonic-gate  * MSYND to share code with CHEETAH & CHEETAH_PLUS) overwrite.
6737c478bd9Sstevel@tonic-gate  * See UltraSPARC-IIIi PRM
6747c478bd9Sstevel@tonic-gate  *   Class 3:  ISAP
6757c478bd9Sstevel@tonic-gate  *   Class 2:  BP
6767c478bd9Sstevel@tonic-gate  *   Class 1:  WBP, IVPE
6777c478bd9Sstevel@tonic-gate  */
6787c478bd9Sstevel@tonic-gate uint64_t msynd_overwrite[] = {
6797c478bd9Sstevel@tonic-gate 	C_AFSR_ISAP,
6807c478bd9Sstevel@tonic-gate 	C_AFSR_BP,
6817c478bd9Sstevel@tonic-gate 	C_AFSR_WBP | C_AFSR_IVPE,
6827c478bd9Sstevel@tonic-gate 	0
6837c478bd9Sstevel@tonic-gate };
6847c478bd9Sstevel@tonic-gate 
6857c478bd9Sstevel@tonic-gate /*
6867c478bd9Sstevel@tonic-gate  * change cpu speed bits -- new speed will be normal-speed/divisor.
6877c478bd9Sstevel@tonic-gate  *
6887c478bd9Sstevel@tonic-gate  * The Jalapeno memory controllers are required to drain outstanding
6897c478bd9Sstevel@tonic-gate  * memory transactions within 32 JBus clocks in order to be ready
6907c478bd9Sstevel@tonic-gate  * to enter Estar mode.  In some corner cases however, that time
6917c478bd9Sstevel@tonic-gate  * fell short.
6927c478bd9Sstevel@tonic-gate  *
6937c478bd9Sstevel@tonic-gate  * A safe software solution is to force MCU to act like in Estar mode,
6947c478bd9Sstevel@tonic-gate  * then delay 1us (in ppm code) prior to assert J_CHNG_L signal.
6957c478bd9Sstevel@tonic-gate  * To reverse the effect, upon exiting Estar, software restores the
6967c478bd9Sstevel@tonic-gate  * MCU to its original state.
6977c478bd9Sstevel@tonic-gate  */
6987c478bd9Sstevel@tonic-gate /* ARGSUSED1 */
6997c478bd9Sstevel@tonic-gate void
cpu_change_speed(uint64_t divisor,uint64_t arg2)7007c478bd9Sstevel@tonic-gate cpu_change_speed(uint64_t divisor, uint64_t arg2)
7017c478bd9Sstevel@tonic-gate {
7025cff7825Smh 	bus_config_eclk_t	*bceclk;
7037c478bd9Sstevel@tonic-gate 	uint64_t		reg;
7047c478bd9Sstevel@tonic-gate 	uint64_t		oldreg;
7057c478bd9Sstevel@tonic-gate 	uint64_t		mreg;
7067c478bd9Sstevel@tonic-gate 	uint64_t		val64;
7077c478bd9Sstevel@tonic-gate 	int			id = (CPU)->cpu_id;
7085cff7825Smh 	processor_info_t	*pi = &(CPU->cpu_type_info);
7097c478bd9Sstevel@tonic-gate 
7107c478bd9Sstevel@tonic-gate #if defined(JALAPENO) && defined(JALAPENO_ERRATA_85)
7117c478bd9Sstevel@tonic-gate 	/*
7127c478bd9Sstevel@tonic-gate 	 * ASI Ecache flush in 1/2 or 1/32 speed mode can result
7137c478bd9Sstevel@tonic-gate 	 * in CPU fatal reset (JETO or IERR/TO on MP). A workaround
7147c478bd9Sstevel@tonic-gate 	 * is to force the CPU to full speed mode prior to using
7157c478bd9Sstevel@tonic-gate 	 * ASI Ecache flush opeartion to flush E$. Since we can't
7167c478bd9Sstevel@tonic-gate 	 * always use cross calls at the time of flushing E$, we
7177c478bd9Sstevel@tonic-gate 	 * cannot change other CPU speed. Hence, this workaround
7187c478bd9Sstevel@tonic-gate 	 * is applicable to uniprocessor configuration only and
7197c478bd9Sstevel@tonic-gate 	 * can't be used in multiprocessor configuration.
7207c478bd9Sstevel@tonic-gate 	 *
7217c478bd9Sstevel@tonic-gate 	 * Note that this workaround is activated only when the CPU
7227c478bd9Sstevel@tonic-gate 	 * has been fully initialized and its speed is lowered by the
7237c478bd9Sstevel@tonic-gate 	 * ppm for the first time. It can be disabled via /etc/system
7247c478bd9Sstevel@tonic-gate 	 * by setting jp_errata_85_enable to 0 and rebooting the
7257c478bd9Sstevel@tonic-gate 	 * system.
7267c478bd9Sstevel@tonic-gate 	 */
7277c478bd9Sstevel@tonic-gate 	if ((jp_errata_85_active == -1) &&
7287c478bd9Sstevel@tonic-gate 	    jp_errata_85_enable &&
7297c478bd9Sstevel@tonic-gate 	    (divisor != JBUS_CONFIG_ECLK_1_DIV)) {
7307c478bd9Sstevel@tonic-gate 		if (ncpus == 1)
7317c478bd9Sstevel@tonic-gate 			jp_errata_85_active = 1;
7327c478bd9Sstevel@tonic-gate 		else
7337c478bd9Sstevel@tonic-gate 			jp_errata_85_active = 0;
7347c478bd9Sstevel@tonic-gate 	}
7357c478bd9Sstevel@tonic-gate 	if ((!jp_errata_85_allow_slow_scrub) && (CPU_PRIVATE(CPU) != NULL)) {
7367c478bd9Sstevel@tonic-gate 		int i;
7377c478bd9Sstevel@tonic-gate 		ch_scrub_misc_t	*chpr_scrubp =
7387c478bd9Sstevel@tonic-gate 		    CPU_PRIVATE_PTR(CPU, chpr_scrub_misc);
7397c478bd9Sstevel@tonic-gate 
7407c478bd9Sstevel@tonic-gate 		/* We're only allowed to run the scrubbers at full speed */
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate 		for (i = 0; i < CACHE_SCRUBBER_COUNT; i++) {
7437c478bd9Sstevel@tonic-gate 			chpr_scrubp->chsm_enable[i] =
7447c478bd9Sstevel@tonic-gate 			    (divisor == JBUS_CONFIG_ECLK_1_DIV);
7457c478bd9Sstevel@tonic-gate 		}
7467c478bd9Sstevel@tonic-gate 	}
7477c478bd9Sstevel@tonic-gate #endif	/* JALAPENO && JALAPENO_ERRATA_85 */
7487c478bd9Sstevel@tonic-gate 
7497c478bd9Sstevel@tonic-gate 	/*
7507c478bd9Sstevel@tonic-gate 	 * We're only interested in mcu_ctl_reg1 bit 26 and 25, of which
7517c478bd9Sstevel@tonic-gate 	 * the value will be stored in the lower half of a byte.  The
7527c478bd9Sstevel@tonic-gate 	 * top bit of this byte is designated as a valid bit - 0 means
7537c478bd9Sstevel@tonic-gate 	 * invalid, 1 means valid.
7547c478bd9Sstevel@tonic-gate 	 */
7557c478bd9Sstevel@tonic-gate 	if (!mcu_fsm_init_state[id].valid) {
7567c478bd9Sstevel@tonic-gate 		val64 = get_mcu_ctl_reg1() & JP_MCU_FSM_MASK;
7577c478bd9Sstevel@tonic-gate 		mcu_fsm_init_state[id].state = val64 >> JP_MCU_FSM_SHIFT;
7587c478bd9Sstevel@tonic-gate 		mcu_fsm_init_state[id].valid = 1;
7597c478bd9Sstevel@tonic-gate 	}
7607c478bd9Sstevel@tonic-gate 
7617c478bd9Sstevel@tonic-gate 	for (bceclk = bus_config_eclk; bceclk->divisor; bceclk++) {
7627c478bd9Sstevel@tonic-gate 		if (bceclk->divisor != divisor)
7637c478bd9Sstevel@tonic-gate 			continue;
7647c478bd9Sstevel@tonic-gate 		reg = get_jbus_config();
7657c478bd9Sstevel@tonic-gate 		oldreg = reg;
7667c478bd9Sstevel@tonic-gate 		reg &= ~JBUS_CONFIG_ECLK_MASK;
7677c478bd9Sstevel@tonic-gate 		reg |= bceclk->mask;
7687c478bd9Sstevel@tonic-gate 		set_jbus_config(reg);
7697c478bd9Sstevel@tonic-gate 		(void) get_jbus_config();
7707c478bd9Sstevel@tonic-gate 
7717c478bd9Sstevel@tonic-gate 		/*
7727c478bd9Sstevel@tonic-gate 		 * MCU workaround, refer to Jalapeno spec, EnergyStar section
7737c478bd9Sstevel@tonic-gate 		 * for detail.
7747c478bd9Sstevel@tonic-gate 		 */
7757c478bd9Sstevel@tonic-gate 
7767c478bd9Sstevel@tonic-gate 		/* Upon entering engery star mode, turn off extra MCU FSMs */
7777c478bd9Sstevel@tonic-gate 		if (((oldreg & JBUS_CONFIG_ECLK_MASK) == JBUS_CONFIG_ECLK_1) &&
7787c478bd9Sstevel@tonic-gate 		    ((divisor == JBUS_CONFIG_ECLK_2_DIV) ||
7797c478bd9Sstevel@tonic-gate 		    (divisor == JBUS_CONFIG_ECLK_32_DIV))) {
7807c478bd9Sstevel@tonic-gate 			mreg = get_mcu_ctl_reg1();
7817c478bd9Sstevel@tonic-gate 			if ((mreg & JP_MCU_FSM_MASK) != 0) {
7827c478bd9Sstevel@tonic-gate 				mreg &= ~JP_MCU_FSM_MASK;
7837c478bd9Sstevel@tonic-gate 				set_mcu_ctl_reg1(mreg);
7847c478bd9Sstevel@tonic-gate 				(void) get_mcu_ctl_reg1();
7857c478bd9Sstevel@tonic-gate 			}
7867c478bd9Sstevel@tonic-gate 		/* Upon exiting energy star mode, restore extra MCU FSMs */
7877c478bd9Sstevel@tonic-gate 		} else if (divisor == JBUS_CONFIG_ECLK_1_DIV) {
7887c478bd9Sstevel@tonic-gate 			mreg = get_mcu_ctl_reg1();
7897c478bd9Sstevel@tonic-gate 			val64 = mcu_fsm_init_state[id].state;
7907c478bd9Sstevel@tonic-gate 			mreg |= val64 << JP_MCU_FSM_SHIFT;
7917c478bd9Sstevel@tonic-gate 			set_mcu_ctl_reg1(mreg);
7927c478bd9Sstevel@tonic-gate 			(void) get_mcu_ctl_reg1();
7937c478bd9Sstevel@tonic-gate 		}
7947c478bd9Sstevel@tonic-gate 		CPU->cpu_m.divisor = (uchar_t)divisor;
795*0e751525SEric Saxe 		cpu_set_curr_clock(((uint64_t)pi->pi_clock * 1000000) /
796*0e751525SEric Saxe 		    divisor);
7977c478bd9Sstevel@tonic-gate 		return;
7987c478bd9Sstevel@tonic-gate 	}
7997c478bd9Sstevel@tonic-gate 	/*
8007c478bd9Sstevel@tonic-gate 	 * We will reach here only if OBP and kernel don't agree on
8017c478bd9Sstevel@tonic-gate 	 * the speeds supported by the CPU.
8027c478bd9Sstevel@tonic-gate 	 */
8037c478bd9Sstevel@tonic-gate 	cmn_err(CE_WARN, "cpu_change_speed: bad divisor %" PRIu64, divisor);
8047c478bd9Sstevel@tonic-gate }
8057c478bd9Sstevel@tonic-gate 
8067c478bd9Sstevel@tonic-gate /*
8077c478bd9Sstevel@tonic-gate  * Cpu private initialization.  This includes allocating the cpu_private
8087c478bd9Sstevel@tonic-gate  * data structure, initializing it, and initializing the scrubber for this
8097c478bd9Sstevel@tonic-gate  * cpu.  This function calls cpu_init_ecache_scrub_dr to init the scrubber.
8107c478bd9Sstevel@tonic-gate  * We use kmem_cache_create for the cheetah private data structure because
8117c478bd9Sstevel@tonic-gate  * it needs to be allocated on a PAGESIZE (8192) byte boundary.
8127c478bd9Sstevel@tonic-gate  */
8137c478bd9Sstevel@tonic-gate void
cpu_init_private(struct cpu * cp)8147c478bd9Sstevel@tonic-gate cpu_init_private(struct cpu *cp)
8157c478bd9Sstevel@tonic-gate {
8167c478bd9Sstevel@tonic-gate 	cheetah_private_t *chprp;
8177c478bd9Sstevel@tonic-gate 	int i;
8187c478bd9Sstevel@tonic-gate 
8197c478bd9Sstevel@tonic-gate 	ASSERT(CPU_PRIVATE(cp) == NULL);
8207c478bd9Sstevel@tonic-gate 
8217c478bd9Sstevel@tonic-gate 	/* LINTED: E_TRUE_LOGICAL_EXPR */
8227c478bd9Sstevel@tonic-gate 	ASSERT((offsetof(cheetah_private_t, chpr_tl1_err_data) +
8237c478bd9Sstevel@tonic-gate 	    sizeof (ch_err_tl1_data_t) * CH_ERR_TL1_TLMAX) <= PAGESIZE);
8247c478bd9Sstevel@tonic-gate 
8257c478bd9Sstevel@tonic-gate #if defined(SERRANO)
8267c478bd9Sstevel@tonic-gate 	if (!IS_SERRANO(cpunodes[cp->cpu_id].implementation)) {
8277c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "CPU%d: implementation 0x%x not supported"
8287c478bd9Sstevel@tonic-gate 		    " on UltraSPARC-IIIi+ code\n", cp->cpu_id,
8297c478bd9Sstevel@tonic-gate 		    cpunodes[cp->cpu_id].implementation);
8307c478bd9Sstevel@tonic-gate 	}
8317c478bd9Sstevel@tonic-gate #else /* SERRANO */
8327c478bd9Sstevel@tonic-gate 	if (!IS_JALAPENO(cpunodes[cp->cpu_id].implementation)) {
8337c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "CPU%d: implementation 0x%x not supported"
8347c478bd9Sstevel@tonic-gate 		    " on UltraSPARC-IIIi code\n", cp->cpu_id,
8357c478bd9Sstevel@tonic-gate 		    cpunodes[cp->cpu_id].implementation);
8367c478bd9Sstevel@tonic-gate 	}
8377c478bd9Sstevel@tonic-gate #endif /* SERRANO */
8387c478bd9Sstevel@tonic-gate 
8397c478bd9Sstevel@tonic-gate 	/*
8407c478bd9Sstevel@tonic-gate 	 * If the ch_private_cache has not been created, create it.
8417c478bd9Sstevel@tonic-gate 	 */
8427c478bd9Sstevel@tonic-gate 	if (ch_private_cache == NULL) {
8437c478bd9Sstevel@tonic-gate 		ch_private_cache = kmem_cache_create("ch_private_cache",
8447c478bd9Sstevel@tonic-gate 		    sizeof (cheetah_private_t), PAGESIZE, NULL, NULL,
8457c478bd9Sstevel@tonic-gate 		    NULL, NULL, static_arena, 0);
8467c478bd9Sstevel@tonic-gate 	}
8477c478bd9Sstevel@tonic-gate 
8487c478bd9Sstevel@tonic-gate 	chprp = CPU_PRIVATE(cp) = kmem_cache_alloc(ch_private_cache, KM_SLEEP);
8497c478bd9Sstevel@tonic-gate 
8507c478bd9Sstevel@tonic-gate 	bzero(chprp, sizeof (cheetah_private_t));
8517c478bd9Sstevel@tonic-gate 	chprp->chpr_fecctl0_logout.clo_data.chd_afar = LOGOUT_INVALID;
8527c478bd9Sstevel@tonic-gate 	chprp->chpr_cecc_logout.clo_data.chd_afar = LOGOUT_INVALID;
8537c478bd9Sstevel@tonic-gate 	chprp->chpr_async_logout.clo_data.chd_afar = LOGOUT_INVALID;
8547c478bd9Sstevel@tonic-gate 	for (i = 0; i < CH_ERR_TL1_TLMAX; i++)
8557c478bd9Sstevel@tonic-gate 		chprp->chpr_tl1_err_data[i].ch_err_tl1_logout.clo_data.chd_afar
8567c478bd9Sstevel@tonic-gate 		    = LOGOUT_INVALID;
8577c478bd9Sstevel@tonic-gate 
8587c478bd9Sstevel@tonic-gate 	chprp->chpr_icache_size = CH_ICACHE_SIZE;
8597c478bd9Sstevel@tonic-gate 	chprp->chpr_icache_linesize = CH_ICACHE_LSIZE;
8607c478bd9Sstevel@tonic-gate 
8617c478bd9Sstevel@tonic-gate 	cpu_init_ecache_scrub_dr(cp);
8627c478bd9Sstevel@tonic-gate 
8637c478bd9Sstevel@tonic-gate 	chprp->chpr_ec_set_size = cpunodes[cp->cpu_id].ecache_size /
8647c478bd9Sstevel@tonic-gate 	    cpu_ecache_nway();
8657c478bd9Sstevel@tonic-gate 
8667c478bd9Sstevel@tonic-gate 	adjust_hw_copy_limits(cpunodes[cp->cpu_id].ecache_size);
8677c478bd9Sstevel@tonic-gate 	ch_err_tl1_paddrs[cp->cpu_id] = va_to_pa(chprp);
8687c478bd9Sstevel@tonic-gate 	ASSERT(ch_err_tl1_paddrs[cp->cpu_id] != -1);
8697c478bd9Sstevel@tonic-gate }
8707c478bd9Sstevel@tonic-gate 
8717c478bd9Sstevel@tonic-gate /*
8727c478bd9Sstevel@tonic-gate  * Clear the error state registers for this CPU.
8737c478bd9Sstevel@tonic-gate  * For Jalapeno, just clear the AFSR
8747c478bd9Sstevel@tonic-gate  */
8757c478bd9Sstevel@tonic-gate void
set_cpu_error_state(ch_cpu_errors_t * cpu_error_regs)8767c478bd9Sstevel@tonic-gate set_cpu_error_state(ch_cpu_errors_t *cpu_error_regs)
8777c478bd9Sstevel@tonic-gate {
8787c478bd9Sstevel@tonic-gate 	set_asyncflt(cpu_error_regs->afsr & ~C_AFSR_FATAL_ERRS);
8797c478bd9Sstevel@tonic-gate }
8807c478bd9Sstevel@tonic-gate 
8817c478bd9Sstevel@tonic-gate /*
8827c478bd9Sstevel@tonic-gate  * Update cpu_offline_set so the scrubber knows which cpus are offline
8837c478bd9Sstevel@tonic-gate  */
8847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
8857c478bd9Sstevel@tonic-gate int
cpu_scrub_cpu_setup(cpu_setup_t what,int cpuid,void * arg)8867c478bd9Sstevel@tonic-gate cpu_scrub_cpu_setup(cpu_setup_t what, int cpuid, void *arg)
8877c478bd9Sstevel@tonic-gate {
8887c478bd9Sstevel@tonic-gate 	switch (what) {
8897c478bd9Sstevel@tonic-gate 	case CPU_ON:
8907c478bd9Sstevel@tonic-gate 	case CPU_INIT:
8917c478bd9Sstevel@tonic-gate 		CPUSET_DEL(cpu_offline_set, cpuid);
8927c478bd9Sstevel@tonic-gate 		break;
8937c478bd9Sstevel@tonic-gate 	case CPU_OFF:
8947c478bd9Sstevel@tonic-gate 		CPUSET_ADD(cpu_offline_set, cpuid);
8957c478bd9Sstevel@tonic-gate 		break;
8967c478bd9Sstevel@tonic-gate 	default:
8977c478bd9Sstevel@tonic-gate 		break;
8987c478bd9Sstevel@tonic-gate 	}
8997c478bd9Sstevel@tonic-gate 	return (0);
9007c478bd9Sstevel@tonic-gate }
901