17aec1d6eScindi /* 27aec1d6eScindi * CDDL HEADER START 37aec1d6eScindi * 47aec1d6eScindi * The contents of this file are subject to the terms of the 5a307a255Sgavinm * Common Development and Distribution License (the "License"). 6a307a255Sgavinm * You may not use this file except in compliance with the License. 77aec1d6eScindi * 87aec1d6eScindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97aec1d6eScindi * or http://www.opensolaris.org/os/licensing. 107aec1d6eScindi * See the License for the specific language governing permissions 117aec1d6eScindi * and limitations under the License. 127aec1d6eScindi * 137aec1d6eScindi * When distributing Covered Code, include this CDDL HEADER in each 147aec1d6eScindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157aec1d6eScindi * If applicable, add the following below this CDDL HEADER, with the 167aec1d6eScindi * fields enclosed by brackets "[]" replaced with your own identifying 177aec1d6eScindi * information: Portions Copyright [yyyy] [name of copyright owner] 187aec1d6eScindi * 197aec1d6eScindi * CDDL HEADER END 207aec1d6eScindi */ 217aec1d6eScindi 227aec1d6eScindi /* 23*20c794b3Sgavinm * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247aec1d6eScindi * Use is subject to license terms. 257aec1d6eScindi */ 267aec1d6eScindi 277aec1d6eScindi /* 28*20c794b3Sgavinm * AMD Athlon64/Opteron Model-Specific Poller Implementation 297aec1d6eScindi */ 307aec1d6eScindi 317aec1d6eScindi #include <sys/types.h> 327aec1d6eScindi 337aec1d6eScindi #include "ao.h" 347aec1d6eScindi 358a40a695Sgavinm /* 36*20c794b3Sgavinm * Decide whether the caller should poll the NB. The decision is made 37*20c794b3Sgavinm * and any poll is performed under protection of the chip-wide mutex 38*20c794b3Sgavinm * enforced at the caller's level. That mutex already ensures that all 39*20c794b3Sgavinm * pollers on a chip are serialized - the following is simply to 40*20c794b3Sgavinm * avoid the NB poll ping-ponging between different detectors. 418a40a695Sgavinm */ 42*20c794b3Sgavinm uint64_t ao_ms_poll_ownermask(cmi_hdl_t hdl,hrtime_t pintvl)43*20c794b3Sgavinmao_ms_poll_ownermask(cmi_hdl_t hdl, hrtime_t pintvl) 447aec1d6eScindi { 45*20c794b3Sgavinm ao_ms_data_t *ao = cms_hdl_getcmsdata(hdl); 46*20c794b3Sgavinm hrtime_t now = gethrtime_waitfree(); 47*20c794b3Sgavinm hrtime_t last = ao->ao_ms_shared->aos_nb_poll_timestamp; 48*20c794b3Sgavinm int dopoll = 0; 497aec1d6eScindi 50*20c794b3Sgavinm if (now - last > 2 * pintvl || last == 0) { 517aec1d6eScindi /* 52*20c794b3Sgavinm * If no last value has been recorded assume ownership. 53*20c794b3Sgavinm * Otherwise only take over if the current "owner" seems 54*20c794b3Sgavinm * to be making little progress. 557aec1d6eScindi */ 56*20c794b3Sgavinm ao->ao_ms_shared->aos_nb_poll_owner = hdl; 57*20c794b3Sgavinm dopoll = 1; 58*20c794b3Sgavinm } else if (ao->ao_ms_shared->aos_nb_poll_owner == hdl) { 59*20c794b3Sgavinm /* 60*20c794b3Sgavinm * This is the current owner and it is making progress. 61*20c794b3Sgavinm */ 62*20c794b3Sgavinm dopoll = 1; 637aec1d6eScindi } 647aec1d6eScindi 65*20c794b3Sgavinm if (dopoll) 66*20c794b3Sgavinm ao->ao_ms_shared->aos_nb_poll_timestamp = now; 677aec1d6eScindi 68*20c794b3Sgavinm return (dopoll ? -1ULL : ~(1 << AMD_MCA_BANK_NB)); 697aec1d6eScindi } 70