xref: /onnv-gate/usr/src/uts/sun4v/os/cmp.c (revision 4769:291956cbfc21)
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
53434Sesaxe  * Common Development and Distribution License (the "License").
63434Sesaxe  * 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 /*
223434Sesaxe  * Copyright 2007 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 #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/machsystm.h>
300Sstevel@tonic-gate #include <sys/cmp.h>
314606Sesaxe #include <sys/cmt.h>
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * Note: For now assume the chip ID as 0 for all the cpus until additional
350Sstevel@tonic-gate  * information is available via machine description table
360Sstevel@tonic-gate  */
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * Returns 1 if cpuid is CMP-capable, 0 otherwise.
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate /*ARGSUSED*/
420Sstevel@tonic-gate int
430Sstevel@tonic-gate cmp_cpu_is_cmp(processorid_t cpuid)
440Sstevel@tonic-gate {
450Sstevel@tonic-gate 	return (0);
460Sstevel@tonic-gate }
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * Indicate that this core (cpuid) resides on the chip indicated by chipid.
500Sstevel@tonic-gate  * Called during boot and DR add.
510Sstevel@tonic-gate  */
520Sstevel@tonic-gate /*ARGSUSED*/
530Sstevel@tonic-gate void
540Sstevel@tonic-gate cmp_add_cpu(chipid_t chipid, processorid_t cpuid)
550Sstevel@tonic-gate {
560Sstevel@tonic-gate }
570Sstevel@tonic-gate 
580Sstevel@tonic-gate /*
590Sstevel@tonic-gate  * Indicate that this core (cpuid) is being DR removed.
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate /*ARGSUSED*/
620Sstevel@tonic-gate void
630Sstevel@tonic-gate cmp_delete_cpu(processorid_t cpuid)
640Sstevel@tonic-gate {
650Sstevel@tonic-gate }
660Sstevel@tonic-gate 
670Sstevel@tonic-gate /*
680Sstevel@tonic-gate  * Called when cpuid is being onlined or offlined.  If the offlined
690Sstevel@tonic-gate  * processor is CMP-capable then current target of the CMP Error Steering
700Sstevel@tonic-gate  * Register is set to either the lowest numbered on-line sibling core, if
710Sstevel@tonic-gate  * one exists, or else to this core.
720Sstevel@tonic-gate  */
730Sstevel@tonic-gate /*ARGSUSED*/
740Sstevel@tonic-gate void
750Sstevel@tonic-gate cmp_error_resteer(processorid_t cpuid)
760Sstevel@tonic-gate {
770Sstevel@tonic-gate }
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /*
800Sstevel@tonic-gate  * Return 0, shortterm workaround until MD table is updated
810Sstevel@tonic-gate  * to provide cpu-chip mapping
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /*ARGSUSED*/
850Sstevel@tonic-gate chipid_t
860Sstevel@tonic-gate cmp_cpu_to_chip(processorid_t cpuid)
870Sstevel@tonic-gate {
884732Sdavemq 	return (cpu[cpuid]->cpu_m.cpu_chip);
890Sstevel@tonic-gate }
900Sstevel@tonic-gate 
913434Sesaxe /*ARGSUSED*/
923434Sesaxe int
933434Sesaxe pg_plat_hw_shared(cpu_t *cp, pghw_type_t hw)
940Sstevel@tonic-gate {
953434Sesaxe 	switch (hw) {
963434Sesaxe 	case PGHW_IPIPE:
973434Sesaxe 		return (1);
983434Sesaxe 	case PGHW_FPU:
993434Sesaxe 		return (1);
100*4769Sdp78419 	case PGHW_MPIPE:
1013434Sesaxe 		return (1);
1023434Sesaxe 	}
1033434Sesaxe 	return (0);
1040Sstevel@tonic-gate }
1050Sstevel@tonic-gate 
1063434Sesaxe int
1073434Sesaxe pg_plat_cpus_share(cpu_t *cpu_a, cpu_t *cpu_b, pghw_type_t hw)
1080Sstevel@tonic-gate {
1093434Sesaxe 	if (pg_plat_hw_shared(cpu_a, hw) == 0 ||
1103434Sesaxe 	    pg_plat_hw_shared(cpu_b, hw) == 0)
1113434Sesaxe 		return (0);
1123434Sesaxe 
1133434Sesaxe 	return (pg_plat_hw_instance_id(cpu_a, hw) ==
1143434Sesaxe 	    pg_plat_hw_instance_id(cpu_b, hw));
1153434Sesaxe }
1160Sstevel@tonic-gate 
1173434Sesaxe id_t
1183434Sesaxe pg_plat_hw_instance_id(cpu_t *cpu, pghw_type_t hw)
1193434Sesaxe {
1203434Sesaxe 	switch (hw) {
1213434Sesaxe 	case PGHW_IPIPE:
1223434Sesaxe 		return (cpu->cpu_m.cpu_ipipe);
123*4769Sdp78419 	case PGHW_MPIPE:
124*4769Sdp78419 		return (cpu->cpu_m.cpu_mpipe);
1253434Sesaxe 	case PGHW_FPU:
1263434Sesaxe 		return (cpu->cpu_m.cpu_fpu);
1273434Sesaxe 	default:
1283434Sesaxe 		return (-1);
1293434Sesaxe 	}
1300Sstevel@tonic-gate }
131220Sesaxe 
132220Sesaxe /*
1333434Sesaxe  * Order the relevant hw sharing relationships
1343434Sesaxe  * from least, to greatest physical scope.
1353434Sesaxe  *
1363434Sesaxe  * The hierarchy *must* be defined for all hw that
1373434Sesaxe  * pg_plat_hw_shared() returns non-zero.
138220Sesaxe  */
1393434Sesaxe int
1403434Sesaxe pg_plat_hw_level(pghw_type_t hw)
1413434Sesaxe {
1423434Sesaxe 	int i;
1433434Sesaxe 	static pghw_type_t hw_hier[] = {
1443434Sesaxe 		PGHW_IPIPE,
1453434Sesaxe 		PGHW_FPU,
146*4769Sdp78419 		PGHW_MPIPE,
1473434Sesaxe 		PGHW_NUM_COMPONENTS
1483434Sesaxe 	};
1493434Sesaxe 
1503434Sesaxe 	for (i = 0; hw_hier[i] != PGHW_NUM_COMPONENTS; i++) {
1513434Sesaxe 		if (hw_hier[i] == hw)
1523434Sesaxe 			return (i);
1533434Sesaxe 	}
1543434Sesaxe 	return (-1);
1553434Sesaxe }
156220Sesaxe 
1574606Sesaxe /*
1584606Sesaxe  * Return 1 if CMT load balancing policies should be
1594606Sesaxe  * implemented across instances of the specified hardware
1604606Sesaxe  * sharing relationship.
1614606Sesaxe  */
1624606Sesaxe int
1634606Sesaxe pg_plat_cmt_load_bal_hw(pghw_type_t hw)
1644606Sesaxe {
1654606Sesaxe 	if (hw == PGHW_IPIPE ||
1664606Sesaxe 	    hw == PGHW_FPU ||
167*4769Sdp78419 	    hw == PGHW_MPIPE)
1684606Sesaxe 		return (1);
1694606Sesaxe 	else
1704606Sesaxe 		return (0);
1714606Sesaxe }
1724606Sesaxe 
1734606Sesaxe 
1744606Sesaxe /*
1754606Sesaxe  * Return 1 if thread affinity polices should be implemented
1764606Sesaxe  * for instances of the specifed hardware sharing relationship.
1774606Sesaxe  */
1784606Sesaxe int
1794606Sesaxe pg_plat_cmt_affinity_hw(pghw_type_t hw)
1804606Sesaxe {
1814606Sesaxe 	if (hw == PGHW_CACHE)
1824606Sesaxe 		return (1);
1834606Sesaxe 	else
1844606Sesaxe 		return (0);
1854606Sesaxe }
1864606Sesaxe 
187220Sesaxe id_t
1883434Sesaxe pg_plat_get_core_id(cpu_t *cpu)
189220Sesaxe {
1903434Sesaxe 	return (cpu->cpu_m.cpu_core);
191220Sesaxe }
1923434Sesaxe 
1933434Sesaxe void
1943434Sesaxe cmp_set_nosteal_interval(void)
1953434Sesaxe {
1963434Sesaxe 	nosteal_nsec = 0;
1973434Sesaxe }
198*4769Sdp78419 /*
199*4769Sdp78419  * Return 1 if CMT load balancing policies should be
200*4769Sdp78419  * implemented across instances of the specified hardware
201*4769Sdp78419  * sharing relationship.
202*4769Sdp78419  */
203*4769Sdp78419 int
204*4769Sdp78419 pg_cmt_load_bal_hw(pghw_type_t hw)
205*4769Sdp78419 {
206*4769Sdp78419 	if (hw == PGHW_IPIPE ||
207*4769Sdp78419 	    hw == PGHW_FPU ||
208*4769Sdp78419 	    hw == PGHW_MPIPE)
209*4769Sdp78419 		return (1);
210*4769Sdp78419 	else
211*4769Sdp78419 		return (0);
212*4769Sdp78419 }
213*4769Sdp78419 /*
214*4769Sdp78419  * Return 1 if thread affinity polices should be implemented
215*4769Sdp78419  * for instances of the specifed hardware sharing relationship.
216*4769Sdp78419  */
217*4769Sdp78419 int
218*4769Sdp78419 pg_cmt_affinity_hw(pghw_type_t hw)
219*4769Sdp78419 {
220*4769Sdp78419 	if (hw == PGHW_CACHE)
221*4769Sdp78419 		return (1);
222*4769Sdp78419 	else
223*4769Sdp78419 		return (0);
224*4769Sdp78419 }
225