cpudrv_throttle.c revision 7f606acec863be28b51fb0f694ca86b41ca76e6d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/x86_archext.h>
#include <sys/machsystm.h>
#include <sys/cpu_acpi.h>
#include <sys/cpudrv_throttle.h>
static int cpudrv_throttle_init(cpudrv_devstate_t *);
static void cpudrv_throttle_fini(cpudrv_devstate_t *);
"Generic ACPI T-state Support",
};
/*
* Error returns
*/
#define THROTTLE_RET_SUCCESS 0x00
#define THROTTLE_RET_INCOMPLETE_DATA 0x01
#define THROTTLE_RET_UNSUP_STATE 0x02
#define THROTTLE_RET_TRANS_INCOMPLETE 0x03
#define THROTTLE_LATENCY_WAIT 1
/*
* MSR register for clock modulation
*/
#define IA32_CLOCK_MODULATION_MSR 0x19A
/*
* Debugging support
*/
#ifdef DEBUG
volatile int cpudrv_throttle_debug = 0;
#else
#endif
/*
* Allocate a new domain node.
*/
static void
{
} else {
}
break;
}
/* new domain is created and linked at the head */
}
/* new domain node is created and linked at the head of the domain */
}
static void
{
while (this_domain != NULL) {
/* discard CPU node chain */
sizeof (cpudrv_tstate_domain_node_t));
}
kmem_free((void *)this_domain,
sizeof (cpudrv_tstate_domain_t));
}
}
/*
* Write the _PTC ctrl register. How it is written, depends upon the _PTC
* APCI object value.
*/
static int
{
int ret = 0;
switch (ptc_ctrl->cr_addrspace_id) {
/*
* Read current thermal state because reserved bits must be
* preserved, compose new value, and write it.The writable
* bits are 4:1 (1 to 4).
* Bits 3:1 => On-Demand Clock Modulation Duty Cycle
* Bit 4 => On-Demand Clock Modulation Enable
* Left shift ctrl by 1 to allign with bits 1-4 of MSR
*/
break;
case ACPI_ADR_SPACE_SYSTEM_IO:
break;
default:
ret = -1;
}
return (ret);
}
static int
{
int ret = 0;
switch (ptc_stat->cr_addrspace_id) {
ret = 0;
break;
case ACPI_ADR_SPACE_SYSTEM_IO:
break;
default:
return (-1);
}
return (ret);
}
/*
* Transition the current processor to the requested throttling state.
*/
static void
{
int i;
req_tstate += req_state;
/*
* Initiate the processor t-state change.
*/
return;
}
/*
* If status is zero, then transition is synchronous and
* no status value comparison is required.
*/
if (CPU_ACPI_TSTATE_STAT(req_tstate) == 0) {
return;
}
/* Wait until switch is complete, but bound the loop just in case. */
i -= THROTTLE_LATENCY_WAIT) {
break;
}
} else {
}
}
static int
{
int ret;
return (ret);
}
static int
{
if (cpu_acpi_cache_tstate_data(handle) != 0) {
CTDEBUG(("Failed to cache T-state ACPI data\n"));
return (THROTTLE_RET_INCOMPLETE_DATA);
}
/*
* Check the address space used for transitions
*/
switch (ptc_stat->cr_addrspace_id) {
CTDEBUG(("T-State transitions will use fixed hardware\n"));
break;
case ACPI_ADR_SPACE_SYSTEM_IO:
CTDEBUG(("T-State transitions will use System IO\n"));
break;
default:
return (THROTTLE_RET_INCOMPLETE_DATA);
}
return (THROTTLE_RET_SUCCESS);
}
static void
{
}