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 5fb2f18f8Sesaxe * Common Development and Distribution License (the "License"). 6fb2f18f8Sesaxe * 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 /* 220e751525SEric Saxe * 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/machsystm.h> 287c478bd9Sstevel@tonic-gate #include <sys/cmp.h> 29d129bde2Sesaxe #include <sys/cmt.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate /* 327c478bd9Sstevel@tonic-gate * Note: For now assume the chip ID as 0 for all the cpus until additional 337c478bd9Sstevel@tonic-gate * information is available via machine description table 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * Returns 1 if cpuid is CMP-capable, 0 otherwise. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 407c478bd9Sstevel@tonic-gate int 417c478bd9Sstevel@tonic-gate cmp_cpu_is_cmp(processorid_t cpuid) 427c478bd9Sstevel@tonic-gate { 437c478bd9Sstevel@tonic-gate return (0); 447c478bd9Sstevel@tonic-gate } 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * Indicate that this core (cpuid) resides on the chip indicated by chipid. 487c478bd9Sstevel@tonic-gate * Called during boot and DR add. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 517c478bd9Sstevel@tonic-gate void 527c478bd9Sstevel@tonic-gate cmp_add_cpu(chipid_t chipid, processorid_t cpuid) 537c478bd9Sstevel@tonic-gate { 547c478bd9Sstevel@tonic-gate } 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * Indicate that this core (cpuid) is being DR removed. 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 607c478bd9Sstevel@tonic-gate void 617c478bd9Sstevel@tonic-gate cmp_delete_cpu(processorid_t cpuid) 627c478bd9Sstevel@tonic-gate { 637c478bd9Sstevel@tonic-gate } 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Called when cpuid is being onlined or offlined. If the offlined 677c478bd9Sstevel@tonic-gate * processor is CMP-capable then current target of the CMP Error Steering 687c478bd9Sstevel@tonic-gate * Register is set to either the lowest numbered on-line sibling core, if 697c478bd9Sstevel@tonic-gate * one exists, or else to this core. 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 727c478bd9Sstevel@tonic-gate void 737c478bd9Sstevel@tonic-gate cmp_error_resteer(processorid_t cpuid) 747c478bd9Sstevel@tonic-gate { 757c478bd9Sstevel@tonic-gate } 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * Return 0, shortterm workaround until MD table is updated 797c478bd9Sstevel@tonic-gate * to provide cpu-chip mapping 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 837c478bd9Sstevel@tonic-gate chipid_t 847c478bd9Sstevel@tonic-gate cmp_cpu_to_chip(processorid_t cpuid) 857c478bd9Sstevel@tonic-gate { 8659ac0c16Sdavemq return (cpu[cpuid]->cpu_m.cpu_chip); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 90fb2f18f8Sesaxe int 91fb2f18f8Sesaxe pg_plat_hw_shared(cpu_t *cp, pghw_type_t hw) 927c478bd9Sstevel@tonic-gate { 93fb2f18f8Sesaxe switch (hw) { 94fb2f18f8Sesaxe case PGHW_IPIPE: 95fb2f18f8Sesaxe return (1); 96fb2f18f8Sesaxe case PGHW_FPU: 97fb2f18f8Sesaxe return (1); 98ce8eb11aSdp78419 case PGHW_MPIPE: 99fb2f18f8Sesaxe return (1); 100fb2f18f8Sesaxe } 101fb2f18f8Sesaxe return (0); 1027c478bd9Sstevel@tonic-gate } 10370f54eadSesaxe 104fb2f18f8Sesaxe int 105fb2f18f8Sesaxe pg_plat_cpus_share(cpu_t *cpu_a, cpu_t *cpu_b, pghw_type_t hw) 106fb2f18f8Sesaxe { 107fb2f18f8Sesaxe if (pg_plat_hw_shared(cpu_a, hw) == 0 || 108fb2f18f8Sesaxe pg_plat_hw_shared(cpu_b, hw) == 0) 109fb2f18f8Sesaxe return (0); 110fb2f18f8Sesaxe 111fb2f18f8Sesaxe return (pg_plat_hw_instance_id(cpu_a, hw) == 112fb2f18f8Sesaxe pg_plat_hw_instance_id(cpu_b, hw)); 113fb2f18f8Sesaxe } 11470f54eadSesaxe 11570f54eadSesaxe id_t 116fb2f18f8Sesaxe pg_plat_hw_instance_id(cpu_t *cpu, pghw_type_t hw) 11770f54eadSesaxe { 118fb2f18f8Sesaxe switch (hw) { 119fb2f18f8Sesaxe case PGHW_IPIPE: 120fb2f18f8Sesaxe return (cpu->cpu_m.cpu_ipipe); 121e853d8c3Sjc25722 case PGHW_CHIP: 122e853d8c3Sjc25722 return (cpu->cpu_m.cpu_chip); 123ce8eb11aSdp78419 case PGHW_MPIPE: 124ce8eb11aSdp78419 return (cpu->cpu_m.cpu_mpipe); 125fb2f18f8Sesaxe case PGHW_FPU: 126fb2f18f8Sesaxe return (cpu->cpu_m.cpu_fpu); 127fb2f18f8Sesaxe default: 128fb2f18f8Sesaxe return (-1); 129fb2f18f8Sesaxe } 130fb2f18f8Sesaxe } 131fb2f18f8Sesaxe 132fb2f18f8Sesaxe /* 1330e751525SEric Saxe * Rank the relative importance of optimizing for hw1 or hw2 134fb2f18f8Sesaxe */ 1350e751525SEric Saxe pghw_type_t 1360e751525SEric Saxe pg_plat_hw_rank(pghw_type_t hw1, pghw_type_t hw2) 137fb2f18f8Sesaxe { 138fb2f18f8Sesaxe int i; 1390e751525SEric Saxe int rank1 = 0; 1400e751525SEric Saxe int rank2 = 0; 1410e751525SEric Saxe 142fb2f18f8Sesaxe static pghw_type_t hw_hier[] = { 143fb2f18f8Sesaxe PGHW_IPIPE, 144fb2f18f8Sesaxe PGHW_FPU, 145ce8eb11aSdp78419 PGHW_MPIPE, 146fb2f18f8Sesaxe PGHW_NUM_COMPONENTS 147fb2f18f8Sesaxe }; 148fb2f18f8Sesaxe 149fb2f18f8Sesaxe for (i = 0; hw_hier[i] != PGHW_NUM_COMPONENTS; i++) { 1500e751525SEric Saxe if (hw_hier[i] == hw1) 1510e751525SEric Saxe rank1 = i; 1520e751525SEric Saxe if (hw_hier[i] == hw2) 1530e751525SEric Saxe rank2 = i; 154fb2f18f8Sesaxe } 1550e751525SEric Saxe if (rank1 > rank2) 1560e751525SEric Saxe return (hw1); 1570e751525SEric Saxe else 1580e751525SEric Saxe return (hw2); 159fb2f18f8Sesaxe } 160fb2f18f8Sesaxe 161d129bde2Sesaxe /* 1620e751525SEric Saxe * Override the default CMT dispatcher policy for the specified 1630e751525SEric Saxe * hardware sharing relationship 164d129bde2Sesaxe */ 1650e751525SEric Saxe /* ARGSUSED */ 1660e751525SEric Saxe pg_cmt_policy_t 1670e751525SEric Saxe pg_plat_cmt_policy(pghw_type_t hw) 168d129bde2Sesaxe { 1690e751525SEric Saxe /* Accept the default policies */ 1700e751525SEric Saxe return (CMT_NO_POLICY); 171d129bde2Sesaxe } 172d129bde2Sesaxe 173fb2f18f8Sesaxe id_t 174fb2f18f8Sesaxe pg_plat_get_core_id(cpu_t *cpu) 175fb2f18f8Sesaxe { 176fb2f18f8Sesaxe return (cpu->cpu_m.cpu_core); 177fb2f18f8Sesaxe } 178fb2f18f8Sesaxe 179fb2f18f8Sesaxe void 180fb2f18f8Sesaxe cmp_set_nosteal_interval(void) 181fb2f18f8Sesaxe { 182fb2f18f8Sesaxe nosteal_nsec = 0; 18370f54eadSesaxe } 184ce8eb11aSdp78419 /* 185ce8eb11aSdp78419 * Return 1 if CMT load balancing policies should be 186ce8eb11aSdp78419 * implemented across instances of the specified hardware 187ce8eb11aSdp78419 * sharing relationship. 188ce8eb11aSdp78419 */ 189ce8eb11aSdp78419 int 190ce8eb11aSdp78419 pg_cmt_load_bal_hw(pghw_type_t hw) 191ce8eb11aSdp78419 { 192ce8eb11aSdp78419 if (hw == PGHW_IPIPE || 193ce8eb11aSdp78419 hw == PGHW_FPU || 194ce8eb11aSdp78419 hw == PGHW_MPIPE) 195ce8eb11aSdp78419 return (1); 196ce8eb11aSdp78419 else 197ce8eb11aSdp78419 return (0); 198ce8eb11aSdp78419 } 199ce8eb11aSdp78419 /* 2000e751525SEric Saxe * Return 1 if thread affinity policies should be implemented 201ce8eb11aSdp78419 * for instances of the specifed hardware sharing relationship. 202ce8eb11aSdp78419 */ 203ce8eb11aSdp78419 int 204ce8eb11aSdp78419 pg_cmt_affinity_hw(pghw_type_t hw) 205ce8eb11aSdp78419 { 206ce8eb11aSdp78419 if (hw == PGHW_CACHE) 207ce8eb11aSdp78419 return (1); 208ce8eb11aSdp78419 else 209ce8eb11aSdp78419 return (0); 210ce8eb11aSdp78419 } 211*b885580bSAlexander Kolbasov 212*b885580bSAlexander Kolbasov /* 213*b885580bSAlexander Kolbasov * Return number of counter events requested to measure hardware capacity and 214*b885580bSAlexander Kolbasov * utilization and setup CPC requests for specified CPU if list where to add 215*b885580bSAlexander Kolbasov * CPC requests is given 216*b885580bSAlexander Kolbasov */ 217*b885580bSAlexander Kolbasov int 218*b885580bSAlexander Kolbasov /* LINTED E_FUNC_ARG_UNUSED */ 219*b885580bSAlexander Kolbasov cu_plat_cpc_init(cpu_t *cp, kcpc_request_list_t *reqs, int nreqs) 220*b885580bSAlexander Kolbasov { 221*b885580bSAlexander Kolbasov /* 222*b885580bSAlexander Kolbasov * Return error to tell common code to decide what counter events to 223*b885580bSAlexander Kolbasov * program on this CPU for measuring hardware capacity and utilization 224*b885580bSAlexander Kolbasov */ 225*b885580bSAlexander Kolbasov return (-1); 226*b885580bSAlexander Kolbasov } 227