xref: /titanic_51/usr/src/uts/sun4v/os/cmp.c (revision fb2f18f820d90b001aea4fb27dd654bc1263c440)
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*fb2f18f8Sesaxe  * Common Development and Distribution License (the "License").
6*fb2f18f8Sesaxe  * 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*fb2f18f8Sesaxe  * Copyright 2007 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/machsystm.h>
307c478bd9Sstevel@tonic-gate #include <sys/cmp.h>
31*fb2f18f8Sesaxe #include <sys/pghw.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * Note: For now assume the chip ID as 0 for all the cpus until additional
357c478bd9Sstevel@tonic-gate  * information is available via machine description table
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate  * Returns 1 if cpuid is CMP-capable, 0 otherwise.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate /*ARGSUSED*/
427c478bd9Sstevel@tonic-gate int
437c478bd9Sstevel@tonic-gate cmp_cpu_is_cmp(processorid_t cpuid)
447c478bd9Sstevel@tonic-gate {
457c478bd9Sstevel@tonic-gate 	return (0);
467c478bd9Sstevel@tonic-gate }
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Indicate that this core (cpuid) resides on the chip indicated by chipid.
507c478bd9Sstevel@tonic-gate  * Called during boot and DR add.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate /*ARGSUSED*/
537c478bd9Sstevel@tonic-gate void
547c478bd9Sstevel@tonic-gate cmp_add_cpu(chipid_t chipid, processorid_t cpuid)
557c478bd9Sstevel@tonic-gate {
567c478bd9Sstevel@tonic-gate }
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  * Indicate that this core (cpuid) is being DR removed.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate /*ARGSUSED*/
627c478bd9Sstevel@tonic-gate void
637c478bd9Sstevel@tonic-gate cmp_delete_cpu(processorid_t cpuid)
647c478bd9Sstevel@tonic-gate {
657c478bd9Sstevel@tonic-gate }
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * Called when cpuid is being onlined or offlined.  If the offlined
697c478bd9Sstevel@tonic-gate  * processor is CMP-capable then current target of the CMP Error Steering
707c478bd9Sstevel@tonic-gate  * Register is set to either the lowest numbered on-line sibling core, if
717c478bd9Sstevel@tonic-gate  * one exists, or else to this core.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate /*ARGSUSED*/
747c478bd9Sstevel@tonic-gate void
757c478bd9Sstevel@tonic-gate cmp_error_resteer(processorid_t cpuid)
767c478bd9Sstevel@tonic-gate {
777c478bd9Sstevel@tonic-gate }
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate /*
807c478bd9Sstevel@tonic-gate  * Return 0, shortterm workaround until MD table is updated
817c478bd9Sstevel@tonic-gate  * to provide cpu-chip mapping
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
857c478bd9Sstevel@tonic-gate chipid_t
867c478bd9Sstevel@tonic-gate cmp_cpu_to_chip(processorid_t cpuid)
877c478bd9Sstevel@tonic-gate {
887c478bd9Sstevel@tonic-gate 	return (0);
897c478bd9Sstevel@tonic-gate }
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*ARGSUSED*/
92*fb2f18f8Sesaxe int
93*fb2f18f8Sesaxe pg_plat_hw_shared(cpu_t *cp, pghw_type_t hw)
947c478bd9Sstevel@tonic-gate {
95*fb2f18f8Sesaxe 	switch (hw) {
96*fb2f18f8Sesaxe 	case PGHW_IPIPE:
97*fb2f18f8Sesaxe 		return (1);
98*fb2f18f8Sesaxe 	case PGHW_FPU:
99*fb2f18f8Sesaxe 		return (1);
100*fb2f18f8Sesaxe 	case PGHW_CHIP:
101*fb2f18f8Sesaxe 		return (1);
102*fb2f18f8Sesaxe 	}
103*fb2f18f8Sesaxe 	return (0);
1047c478bd9Sstevel@tonic-gate }
10570f54eadSesaxe 
106*fb2f18f8Sesaxe int
107*fb2f18f8Sesaxe pg_plat_cpus_share(cpu_t *cpu_a, cpu_t *cpu_b, pghw_type_t hw)
108*fb2f18f8Sesaxe {
109*fb2f18f8Sesaxe 	if (pg_plat_hw_shared(cpu_a, hw) == 0 ||
110*fb2f18f8Sesaxe 	    pg_plat_hw_shared(cpu_b, hw) == 0)
111*fb2f18f8Sesaxe 		return (0);
112*fb2f18f8Sesaxe 
113*fb2f18f8Sesaxe 	return (pg_plat_hw_instance_id(cpu_a, hw) ==
114*fb2f18f8Sesaxe 	    pg_plat_hw_instance_id(cpu_b, hw));
115*fb2f18f8Sesaxe }
11670f54eadSesaxe 
11770f54eadSesaxe id_t
118*fb2f18f8Sesaxe pg_plat_hw_instance_id(cpu_t *cpu, pghw_type_t hw)
11970f54eadSesaxe {
120*fb2f18f8Sesaxe 	switch (hw) {
121*fb2f18f8Sesaxe 	case PGHW_IPIPE:
122*fb2f18f8Sesaxe 		return (cpu->cpu_m.cpu_ipipe);
123*fb2f18f8Sesaxe 	case PGHW_CHIP:
124*fb2f18f8Sesaxe 		return (cmp_cpu_to_chip(cpu->cpu_id));
125*fb2f18f8Sesaxe 	case PGHW_FPU:
126*fb2f18f8Sesaxe 		return (cpu->cpu_m.cpu_fpu);
127*fb2f18f8Sesaxe 	default:
128*fb2f18f8Sesaxe 		return (-1);
129*fb2f18f8Sesaxe 	}
130*fb2f18f8Sesaxe }
131*fb2f18f8Sesaxe 
132*fb2f18f8Sesaxe /*
133*fb2f18f8Sesaxe  * Order the relevant hw sharing relationships
134*fb2f18f8Sesaxe  * from least, to greatest physical scope.
135*fb2f18f8Sesaxe  *
136*fb2f18f8Sesaxe  * The hierarchy *must* be defined for all hw that
137*fb2f18f8Sesaxe  * pg_plat_hw_shared() returns non-zero.
138*fb2f18f8Sesaxe  */
139*fb2f18f8Sesaxe int
140*fb2f18f8Sesaxe pg_plat_hw_level(pghw_type_t hw)
141*fb2f18f8Sesaxe {
142*fb2f18f8Sesaxe 	int i;
143*fb2f18f8Sesaxe 	static pghw_type_t hw_hier[] = {
144*fb2f18f8Sesaxe 		PGHW_IPIPE,
145*fb2f18f8Sesaxe 		PGHW_FPU,
146*fb2f18f8Sesaxe 		PGHW_CHIP,
147*fb2f18f8Sesaxe 		PGHW_NUM_COMPONENTS
148*fb2f18f8Sesaxe 	};
149*fb2f18f8Sesaxe 
150*fb2f18f8Sesaxe 	for (i = 0; hw_hier[i] != PGHW_NUM_COMPONENTS; i++) {
151*fb2f18f8Sesaxe 		if (hw_hier[i] == hw)
152*fb2f18f8Sesaxe 			return (i);
153*fb2f18f8Sesaxe 	}
154*fb2f18f8Sesaxe 	return (-1);
155*fb2f18f8Sesaxe }
156*fb2f18f8Sesaxe 
157*fb2f18f8Sesaxe id_t
158*fb2f18f8Sesaxe pg_plat_get_core_id(cpu_t *cpu)
159*fb2f18f8Sesaxe {
160*fb2f18f8Sesaxe 	return (cpu->cpu_m.cpu_core);
161*fb2f18f8Sesaxe }
162*fb2f18f8Sesaxe 
163*fb2f18f8Sesaxe void
164*fb2f18f8Sesaxe cmp_set_nosteal_interval(void)
165*fb2f18f8Sesaxe {
166*fb2f18f8Sesaxe 	nosteal_nsec = 0;
16770f54eadSesaxe }
168