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*25cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 6*25cf1a30Sjl139090 * 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 /* 228949bcd6Sandrei * Copyright 2006 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/x_call.h> 317c478bd9Sstevel@tonic-gate #include <sys/cmp.h> 327c478bd9Sstevel@tonic-gate #include <sys/debug.h> 337c478bd9Sstevel@tonic-gate #include <sys/chip.h> 347c478bd9Sstevel@tonic-gate #include <sys/cheetahregs.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * Note: We assume that chipid == portid. This is not necessarily true. 387c478bd9Sstevel@tonic-gate * We buried it down here in the implementation, and not in the 397c478bd9Sstevel@tonic-gate * interfaces, so that we can change it later. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * pre-alloc'ed because this is used early in boot (before the memory 447c478bd9Sstevel@tonic-gate * allocator is available). 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate static cpuset_t chips[MAX_CPU_CHIPID]; 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * Returns 1 if cpuid is CMP-capable, 0 otherwise. 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate int 527c478bd9Sstevel@tonic-gate cmp_cpu_is_cmp(processorid_t cpuid) 537c478bd9Sstevel@tonic-gate { 547c478bd9Sstevel@tonic-gate chipid_t chipid; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* N.B. We're assuming that the cpunode[].portid is still intact */ 577c478bd9Sstevel@tonic-gate chipid = cpunodes[cpuid].portid; 587c478bd9Sstevel@tonic-gate return (!CPUSET_ISNULL(chips[chipid])); 597c478bd9Sstevel@tonic-gate } 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Indicate that this core (cpuid) resides on the chip indicated by chipid. 637c478bd9Sstevel@tonic-gate * Called during boot and DR add. 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate void 667c478bd9Sstevel@tonic-gate cmp_add_cpu(chipid_t chipid, processorid_t cpuid) 677c478bd9Sstevel@tonic-gate { 687c478bd9Sstevel@tonic-gate CPUSET_ADD(chips[chipid], cpuid); 697c478bd9Sstevel@tonic-gate } 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * Indicate that this core (cpuid) is being DR removed. 737c478bd9Sstevel@tonic-gate */ 747c478bd9Sstevel@tonic-gate void 757c478bd9Sstevel@tonic-gate cmp_delete_cpu(processorid_t cpuid) 767c478bd9Sstevel@tonic-gate { 777c478bd9Sstevel@tonic-gate chipid_t chipid; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* N.B. We're assuming that the cpunode[].portid is still intact */ 807c478bd9Sstevel@tonic-gate chipid = cpunodes[cpuid].portid; 817c478bd9Sstevel@tonic-gate CPUSET_DEL(chips[chipid], cpuid); 827c478bd9Sstevel@tonic-gate } 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * Called when cpuid is being onlined or offlined. If the offlined 867c478bd9Sstevel@tonic-gate * processor is CMP-capable then current target of the CMP Error Steering 877c478bd9Sstevel@tonic-gate * Register is set to either the lowest numbered on-line sibling core, if 887c478bd9Sstevel@tonic-gate * one exists, or else to this core. 897c478bd9Sstevel@tonic-gate */ 90*25cf1a30Sjl139090 /* ARGSUSED */ 917c478bd9Sstevel@tonic-gate void 927c478bd9Sstevel@tonic-gate cmp_error_resteer(processorid_t cpuid) 937c478bd9Sstevel@tonic-gate { 94*25cf1a30Sjl139090 #ifndef _CMP_NO_ERROR_STEERING 957c478bd9Sstevel@tonic-gate cpuset_t mycores; 967c478bd9Sstevel@tonic-gate cpu_t *cpu; 977c478bd9Sstevel@tonic-gate chipid_t chipid; 987c478bd9Sstevel@tonic-gate int i; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate if (!cmp_cpu_is_cmp(cpuid)) 1017c478bd9Sstevel@tonic-gate return; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&cpu_lock)); 1047c478bd9Sstevel@tonic-gate chipid = cpunodes[cpuid].portid; 1057c478bd9Sstevel@tonic-gate mycores = chips[chipid]; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* Look for an online sibling core */ 1087c478bd9Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 1097c478bd9Sstevel@tonic-gate if (i == cpuid) 1107c478bd9Sstevel@tonic-gate continue; 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate if (CPU_IN_SET(mycores, i) && 1137c478bd9Sstevel@tonic-gate (cpu = cpu_get(i)) != NULL && cpu_is_active(cpu)) { 1147c478bd9Sstevel@tonic-gate /* Found one, reset error steering */ 1157c478bd9Sstevel@tonic-gate xc_one(i, (xcfunc_t *)set_cmp_error_steering, 0, 0); 1167c478bd9Sstevel@tonic-gate break; 1177c478bd9Sstevel@tonic-gate } 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* No online sibling cores, point to this core. */ 1217c478bd9Sstevel@tonic-gate if (i == NCPU) { 1227c478bd9Sstevel@tonic-gate xc_one(cpuid, (xcfunc_t *)set_cmp_error_steering, 0, 0); 1237c478bd9Sstevel@tonic-gate } 124*25cf1a30Sjl139090 #else 125*25cf1a30Sjl139090 /* Not all CMP's support (e.g. Olympus-C by Fujitsu) error steering */ 126*25cf1a30Sjl139090 return; 127*25cf1a30Sjl139090 #endif /* _CMP_NO_ERROR_STEERING */ 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate chipid_t 1317c478bd9Sstevel@tonic-gate cmp_cpu_to_chip(processorid_t cpuid) 1327c478bd9Sstevel@tonic-gate { 1337c478bd9Sstevel@tonic-gate if (!cmp_cpu_is_cmp(cpuid)) { 1347c478bd9Sstevel@tonic-gate /* This CPU is not a CMP, so by definition chipid==cpuid */ 1357c478bd9Sstevel@tonic-gate ASSERT(cpuid < MAX_CPU_CHIPID && CPUSET_ISNULL(chips[cpuid])); 1367c478bd9Sstevel@tonic-gate return (cpuid); 1377c478bd9Sstevel@tonic-gate } 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate /* N.B. We're assuming that the cpunode[].portid is still intact */ 1407c478bd9Sstevel@tonic-gate return (cpunodes[cpuid].portid); 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* 1447c478bd9Sstevel@tonic-gate * Return a chip "id" for the given cpu_t 1457c478bd9Sstevel@tonic-gate * cpu_t's residing on the same physical processor 1467c478bd9Sstevel@tonic-gate * should map to the same "id" 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate chipid_t 1497c478bd9Sstevel@tonic-gate chip_plat_get_chipid(cpu_t *cp) 1507c478bd9Sstevel@tonic-gate { 1517c478bd9Sstevel@tonic-gate return (cmp_cpu_to_chip(cp->cpu_id)); 1527c478bd9Sstevel@tonic-gate } 1537c478bd9Sstevel@tonic-gate 1548949bcd6Sandrei /* 155*25cf1a30Sjl139090 * Return the "core id" for the given cpu_t 156*25cf1a30Sjl139090 * The "core id" space spans uniquely across all 157*25cf1a30Sjl139090 * cpu chips. 1588949bcd6Sandrei */ 1598949bcd6Sandrei id_t 1608949bcd6Sandrei chip_plat_get_coreid(cpu_t *cp) 1618949bcd6Sandrei { 162*25cf1a30Sjl139090 int impl; 163*25cf1a30Sjl139090 164*25cf1a30Sjl139090 impl = cpunodes[cp->cpu_id].implementation; 165*25cf1a30Sjl139090 166*25cf1a30Sjl139090 if (IS_OLYMPUS_C(impl)) { 167*25cf1a30Sjl139090 /* 168*25cf1a30Sjl139090 * Currently only Fujitsu Olympus-c processor supports 169*25cf1a30Sjl139090 * multi-stranded cores. Return the cpu_id with 170*25cf1a30Sjl139090 * the strand bit masked out. 171*25cf1a30Sjl139090 */ 172*25cf1a30Sjl139090 return ((id_t)((uint_t)cp->cpu_id & ~(0x1))); 173*25cf1a30Sjl139090 } else { 1748949bcd6Sandrei return (cp->cpu_id); 1758949bcd6Sandrei } 176*25cf1a30Sjl139090 } 1778949bcd6Sandrei 1787c478bd9Sstevel@tonic-gate void 1797c478bd9Sstevel@tonic-gate chip_plat_define_chip(cpu_t *cp, chip_def_t *cd) 1807c478bd9Sstevel@tonic-gate { 1817c478bd9Sstevel@tonic-gate int impl; 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* 1847c478bd9Sstevel@tonic-gate * Define the chip's type 1857c478bd9Sstevel@tonic-gate */ 1867c478bd9Sstevel@tonic-gate impl = cpunodes[cp->cpu_id].implementation; 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate if (IS_JAGUAR(impl)) { 1897c478bd9Sstevel@tonic-gate cd->chipd_type = CHIP_CMP_SPLIT_CACHE; 190*25cf1a30Sjl139090 } else if (IS_PANTHER(impl) || IS_OLYMPUS_C(impl)) { 1917c478bd9Sstevel@tonic-gate cd->chipd_type = CHIP_CMP_SHARED_CACHE; 1927c478bd9Sstevel@tonic-gate } else { 1937c478bd9Sstevel@tonic-gate cd->chipd_type = CHIP_DEFAULT; 1947c478bd9Sstevel@tonic-gate } 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* 1977c478bd9Sstevel@tonic-gate * Define any needed adjustment of rechoose_interval 1987c478bd9Sstevel@tonic-gate * For now, all chips use the default. This 1997c478bd9Sstevel@tonic-gate * will change with future processors. 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate cd->chipd_rechoose_adj = 0; 2027c478bd9Sstevel@tonic-gate } 203