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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*8949bcd6Sandrei * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/machsystm.h> 317c478bd9Sstevel@tonic-gate #include <sys/x_call.h> 327c478bd9Sstevel@tonic-gate #include <sys/cmp.h> 337c478bd9Sstevel@tonic-gate #include <sys/debug.h> 347c478bd9Sstevel@tonic-gate #include <sys/chip.h> 357c478bd9Sstevel@tonic-gate #include <sys/cheetahregs.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * Note: We assume that chipid == portid. This is not necessarily true. 397c478bd9Sstevel@tonic-gate * We buried it down here in the implementation, and not in the 407c478bd9Sstevel@tonic-gate * interfaces, so that we can change it later. 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * pre-alloc'ed because this is used early in boot (before the memory 457c478bd9Sstevel@tonic-gate * allocator is available). 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate static cpuset_t chips[MAX_CPU_CHIPID]; 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Returns 1 if cpuid is CMP-capable, 0 otherwise. 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate int 537c478bd9Sstevel@tonic-gate cmp_cpu_is_cmp(processorid_t cpuid) 547c478bd9Sstevel@tonic-gate { 557c478bd9Sstevel@tonic-gate chipid_t chipid; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* N.B. We're assuming that the cpunode[].portid is still intact */ 587c478bd9Sstevel@tonic-gate chipid = cpunodes[cpuid].portid; 597c478bd9Sstevel@tonic-gate return (!CPUSET_ISNULL(chips[chipid])); 607c478bd9Sstevel@tonic-gate } 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * Indicate that this core (cpuid) resides on the chip indicated by chipid. 647c478bd9Sstevel@tonic-gate * Called during boot and DR add. 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate void 677c478bd9Sstevel@tonic-gate cmp_add_cpu(chipid_t chipid, processorid_t cpuid) 687c478bd9Sstevel@tonic-gate { 697c478bd9Sstevel@tonic-gate CPUSET_ADD(chips[chipid], cpuid); 707c478bd9Sstevel@tonic-gate } 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Indicate that this core (cpuid) is being DR removed. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate void 767c478bd9Sstevel@tonic-gate cmp_delete_cpu(processorid_t cpuid) 777c478bd9Sstevel@tonic-gate { 787c478bd9Sstevel@tonic-gate chipid_t chipid; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* N.B. We're assuming that the cpunode[].portid is still intact */ 817c478bd9Sstevel@tonic-gate chipid = cpunodes[cpuid].portid; 827c478bd9Sstevel@tonic-gate CPUSET_DEL(chips[chipid], cpuid); 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * Called when cpuid is being onlined or offlined. If the offlined 877c478bd9Sstevel@tonic-gate * processor is CMP-capable then current target of the CMP Error Steering 887c478bd9Sstevel@tonic-gate * Register is set to either the lowest numbered on-line sibling core, if 897c478bd9Sstevel@tonic-gate * one exists, or else to this core. 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate void 927c478bd9Sstevel@tonic-gate cmp_error_resteer(processorid_t cpuid) 937c478bd9Sstevel@tonic-gate { 947c478bd9Sstevel@tonic-gate cpuset_t mycores; 957c478bd9Sstevel@tonic-gate cpu_t *cpu; 967c478bd9Sstevel@tonic-gate chipid_t chipid; 977c478bd9Sstevel@tonic-gate int i; 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate if (!cmp_cpu_is_cmp(cpuid)) 1007c478bd9Sstevel@tonic-gate return; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&cpu_lock)); 1037c478bd9Sstevel@tonic-gate chipid = cpunodes[cpuid].portid; 1047c478bd9Sstevel@tonic-gate mycores = chips[chipid]; 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* Look for an online sibling core */ 1077c478bd9Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 1087c478bd9Sstevel@tonic-gate if (i == cpuid) 1097c478bd9Sstevel@tonic-gate continue; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate if (CPU_IN_SET(mycores, i) && 1127c478bd9Sstevel@tonic-gate (cpu = cpu_get(i)) != NULL && cpu_is_active(cpu)) { 1137c478bd9Sstevel@tonic-gate /* Found one, reset error steering */ 1147c478bd9Sstevel@tonic-gate xc_one(i, (xcfunc_t *)set_cmp_error_steering, 0, 0); 1157c478bd9Sstevel@tonic-gate break; 1167c478bd9Sstevel@tonic-gate } 1177c478bd9Sstevel@tonic-gate } 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* No online sibling cores, point to this core. */ 1207c478bd9Sstevel@tonic-gate if (i == NCPU) { 1217c478bd9Sstevel@tonic-gate xc_one(cpuid, (xcfunc_t *)set_cmp_error_steering, 0, 0); 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate } 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate chipid_t 1267c478bd9Sstevel@tonic-gate cmp_cpu_to_chip(processorid_t cpuid) 1277c478bd9Sstevel@tonic-gate { 1287c478bd9Sstevel@tonic-gate if (!cmp_cpu_is_cmp(cpuid)) { 1297c478bd9Sstevel@tonic-gate /* This CPU is not a CMP, so by definition chipid==cpuid */ 1307c478bd9Sstevel@tonic-gate ASSERT(cpuid < MAX_CPU_CHIPID && CPUSET_ISNULL(chips[cpuid])); 1317c478bd9Sstevel@tonic-gate return (cpuid); 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* N.B. We're assuming that the cpunode[].portid is still intact */ 1357c478bd9Sstevel@tonic-gate return (cpunodes[cpuid].portid); 1367c478bd9Sstevel@tonic-gate } 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* 1397c478bd9Sstevel@tonic-gate * Return a chip "id" for the given cpu_t 1407c478bd9Sstevel@tonic-gate * cpu_t's residing on the same physical processor 1417c478bd9Sstevel@tonic-gate * should map to the same "id" 1427c478bd9Sstevel@tonic-gate */ 1437c478bd9Sstevel@tonic-gate chipid_t 1447c478bd9Sstevel@tonic-gate chip_plat_get_chipid(cpu_t *cp) 1457c478bd9Sstevel@tonic-gate { 1467c478bd9Sstevel@tonic-gate return (cmp_cpu_to_chip(cp->cpu_id)); 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate 149*8949bcd6Sandrei /* 150*8949bcd6Sandrei * We don't have any multi-threaded cores on sun4u yet. 151*8949bcd6Sandrei */ 152*8949bcd6Sandrei id_t 153*8949bcd6Sandrei chip_plat_get_coreid(cpu_t *cp) 154*8949bcd6Sandrei { 155*8949bcd6Sandrei return (cp->cpu_id); 156*8949bcd6Sandrei } 157*8949bcd6Sandrei 1587c478bd9Sstevel@tonic-gate void 1597c478bd9Sstevel@tonic-gate chip_plat_define_chip(cpu_t *cp, chip_def_t *cd) 1607c478bd9Sstevel@tonic-gate { 1617c478bd9Sstevel@tonic-gate int impl; 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* 1647c478bd9Sstevel@tonic-gate * Define the chip's type 1657c478bd9Sstevel@tonic-gate */ 1667c478bd9Sstevel@tonic-gate impl = cpunodes[cp->cpu_id].implementation; 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate if (IS_JAGUAR(impl)) { 1697c478bd9Sstevel@tonic-gate cd->chipd_type = CHIP_CMP_SPLIT_CACHE; 1707c478bd9Sstevel@tonic-gate } else if (IS_PANTHER(impl)) { 1717c478bd9Sstevel@tonic-gate cd->chipd_type = CHIP_CMP_SHARED_CACHE; 1727c478bd9Sstevel@tonic-gate } else { 1737c478bd9Sstevel@tonic-gate cd->chipd_type = CHIP_DEFAULT; 1747c478bd9Sstevel@tonic-gate } 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate /* 1777c478bd9Sstevel@tonic-gate * Define any needed adjustment of rechoose_interval 1787c478bd9Sstevel@tonic-gate * For now, all chips use the default. This 1797c478bd9Sstevel@tonic-gate * will change with future processors. 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate cd->chipd_rechoose_adj = 0; 1827c478bd9Sstevel@tonic-gate } 183