Remove X86_IPI_WRITE_MSR (and msr_ipifuncs.c), replace all uses in drivers
with xc_broadcast(). AMD K8 PowerNow driver tested by <jakllsch>, thanks! Closes PR/37665.
This commit is contained in:
parent
c9a5a18df3
commit
b619d660f4
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.132 2009/08/18 16:41:02 jmcneill Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.133 2009/10/05 23:59:30 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
|
||||
@ -112,7 +112,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.132 2009/08/18 16:41:02 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.133 2009/10/05 23:59:30 rmind Exp $");
|
||||
|
||||
/* #define XENDEBUG_LOW */
|
||||
|
||||
@ -180,7 +180,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.132 2009/08/18 16:41:02 jmcneill Exp $
|
||||
#include <machine/mpbiosvar.h>
|
||||
|
||||
#include <x86/cputypes.h>
|
||||
#include <x86/cpu_msr.h>
|
||||
#include <x86/cpuvar.h>
|
||||
#include <x86/machdep.h>
|
||||
|
||||
@ -1535,8 +1534,6 @@ init_x86_64(paddr_t first_avail)
|
||||
splraise(IPL_HIGH);
|
||||
x86_enable_intr();
|
||||
|
||||
x86_init();
|
||||
|
||||
#ifdef DDB
|
||||
if (boothowto & RB_KDB)
|
||||
Debugger();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.671 2009/08/18 16:41:02 jmcneill Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.672 2009/10/05 23:59:30 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
|
||||
@ -67,7 +67,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.671 2009/08/18 16:41:02 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.672 2009/10/05 23:59:30 rmind Exp $");
|
||||
|
||||
#include "opt_beep.h"
|
||||
#include "opt_compat_ibcs2.h"
|
||||
@ -131,8 +131,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.671 2009/08/18 16:41:02 jmcneill Exp $
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <x86/cpu_msr.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/cpuvar.h>
|
||||
@ -516,8 +514,6 @@ cpu_startup(void)
|
||||
cpu_init_tss(&cpu_info_primary);
|
||||
ltr(cpu_info_primary.ci_tss_sel);
|
||||
#endif
|
||||
|
||||
x86_init();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.x86,v 1.53 2009/10/02 18:50:03 jmcneill Exp $
|
||||
# $NetBSD: files.x86,v 1.54 2009/10/05 23:59:31 rmind Exp $
|
||||
|
||||
# options for MP configuration through the MP spec
|
||||
defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
|
||||
@ -61,7 +61,6 @@ file arch/x86/x86/intr.c
|
||||
file arch/x86/x86/nmi.c
|
||||
file arch/x86/x86/idt.c
|
||||
file arch/x86/x86/ipi.c
|
||||
file arch/x86/x86/msr_ipifuncs.c
|
||||
file arch/x86/x86/mtrr_i686.c mtrr
|
||||
file arch/x86/x86/patch.c
|
||||
file arch/x86/x86/platform.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu_msr.h,v 1.6 2007/10/17 19:58:14 garbled Exp $ */
|
||||
/* $NetBSD: cpu_msr.h,v 1.7 2009/10/05 23:59:31 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Juan Romero Pardines.
|
||||
@ -29,22 +29,36 @@
|
||||
#define _X86_CPU_MSR_H
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
struct msr_cpu_broadcast {
|
||||
struct msr_rw_info {
|
||||
int msr_read;
|
||||
int msr_type;
|
||||
uint64_t msr_value;
|
||||
uint64_t msr_mask;
|
||||
};
|
||||
|
||||
void x86_init(void);
|
||||
void msr_write_ipi(struct cpu_info *);
|
||||
void msr_cpu_broadcast_initmtx(void);
|
||||
void msr_cpu_broadcast(struct msr_cpu_broadcast *);
|
||||
static inline void
|
||||
x86_msr_xcall(void *arg1, void *arg2)
|
||||
{
|
||||
struct msr_rw_info *msrdat = arg1;
|
||||
uint64_t msr = 0;
|
||||
|
||||
KASSERT(msrdat->msr_type != 0);
|
||||
|
||||
/* Read the MSR requested and apply the mask if defined. */
|
||||
if (msrdat->msr_read) {
|
||||
msr = rdmsr(msrdat->msr_type);
|
||||
if (msrdat->msr_mask) {
|
||||
msr &= ~msrdat->msr_mask;
|
||||
}
|
||||
}
|
||||
/* Assign (or extract, on read) the value and perform the write. */
|
||||
msr |= msrdat->msr_value;
|
||||
wrmsr(msrdat->msr_type, msr);
|
||||
}
|
||||
|
||||
#endif /* ! _KERNEL */
|
||||
|
||||
#endif /* ! _X86_CPU_MSR_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: intrdefs.h,v 1.14 2008/11/11 13:45:10 ad Exp $ */
|
||||
/* $NetBSD: intrdefs.h,v 1.15 2009/10/05 23:59:31 rmind Exp $ */
|
||||
|
||||
#ifndef _X86_INTRDEFS_H_
|
||||
#define _X86_INTRDEFS_H_
|
||||
@ -58,11 +58,11 @@
|
||||
|
||||
#define X86_IPI_HALT 0x00000001
|
||||
#define X86_IPI_MICROSET 0x00000002
|
||||
#define X86_IPI__UNUSED 0x00000004
|
||||
#define X86_IPI__UNUSED1 0x00000004
|
||||
#define X86_IPI_SYNCH_FPU 0x00000008
|
||||
#define X86_IPI_MTRR 0x00000010
|
||||
#define X86_IPI_GDT 0x00000020
|
||||
#define X86_IPI_WRITE_MSR 0x00000040
|
||||
#define X86_IPI__UNUSED2 0x00000040
|
||||
#define X86_IPI_ACPI_CPU_SLEEP 0x00000080
|
||||
#define X86_IPI_KPREEMPT 0x00000100
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
|
||||
#define X86_IPI_NAMES { "halt IPI", "timeset IPI", "unused", \
|
||||
"FPU synch IPI", "MTRR update IPI", \
|
||||
"GDT update IPI", "MSR write IPI", \
|
||||
"GDT update IPI", "unused", \
|
||||
"ACPI CPU sleep IPI", "kpreempt IPI" }
|
||||
|
||||
#define IREENT_MAGIC 0x18041969
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: est.c,v 1.12 2009/10/02 15:05:42 jmcneill Exp $ */
|
||||
/* $NetBSD: est.c,v 1.13 2009/10/05 23:59:31 rmind Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2003 Michael Eriksson.
|
||||
* All rights reserved.
|
||||
@ -81,7 +81,7 @@
|
||||
/* #define EST_DEBUG */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.12 2009/10/02 15:05:42 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.13 2009/10/05 23:59:31 rmind Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: est.c,v 1.12 2009/10/02 15:05:42 jmcneill Exp $");
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/xcall.h>
|
||||
|
||||
#include <x86/cpuvar.h>
|
||||
#include <x86/cputypes.h>
|
||||
@ -1009,7 +1010,6 @@ static void est_init_main(int);
|
||||
static int
|
||||
est_sysctl_helper(SYSCTLFN_ARGS)
|
||||
{
|
||||
struct msr_cpu_broadcast mcb;
|
||||
struct sysctlnode node;
|
||||
int fq, oldfq, error;
|
||||
|
||||
@ -1033,17 +1033,22 @@ est_sysctl_helper(SYSCTLFN_ARGS)
|
||||
|
||||
/* support writing to ...frequency.target */
|
||||
if (rnode->sysctl_num == est_node_target && fq != oldfq) {
|
||||
struct msr_rw_info msr;
|
||||
uint64_t where;
|
||||
int i;
|
||||
|
||||
for (i = est_fqlist->n - 1; i > 0; i--)
|
||||
if (MSR2MHZ(est_fqlist->table[i], bus_clock) >= fq)
|
||||
break;
|
||||
fq = MSR2MHZ(est_fqlist->table[i], bus_clock);
|
||||
mcb.msr_read = true;
|
||||
mcb.msr_type = MSR_PERF_CTL;
|
||||
mcb.msr_mask = 0xffffULL;
|
||||
mcb.msr_value = est_fqlist->table[i];
|
||||
msr_cpu_broadcast(&mcb);
|
||||
|
||||
msr.msr_read = true;
|
||||
msr.msr_type = MSR_PERF_CTL;
|
||||
msr.msr_mask = 0xffffULL;
|
||||
msr.msr_value = est_fqlist->table[i];
|
||||
|
||||
where = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL);
|
||||
xc_wait(where);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: iclockmod.c,v 1.12 2008/05/11 14:44:54 ad Exp $ */
|
||||
/* $NetBSD: iclockmod.c,v 1.13 2009/10/05 23:59:31 rmind Exp $ */
|
||||
/* $OpenBSD: p4tcc.c,v 1.13 2006/12/20 17:50:40 gwk Exp $ */
|
||||
|
||||
/*
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: iclockmod.c,v 1.12 2008/05/11 14:44:54 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: iclockmod.c,v 1.13 2009/10/05 23:59:31 rmind Exp $");
|
||||
|
||||
#include "opt_intel_odcm.h"
|
||||
|
||||
@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: iclockmod.c,v 1.12 2008/05/11 14:44:54 ad Exp $");
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/xcall.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cpuvar.h>
|
||||
@ -60,7 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: iclockmod.c,v 1.12 2008/05/11 14:44:54 ad Exp $");
|
||||
#define ODCM_REGOFFSET 1
|
||||
#define ODCM_MAXSTATES 8
|
||||
|
||||
static struct msr_cpu_broadcast mcb;
|
||||
static int clockmod_level;
|
||||
static int clockmod_state_target;
|
||||
static int clockmod_state_current;
|
||||
@ -111,6 +111,8 @@ clockmod_getstate(void)
|
||||
static void
|
||||
clockmod_setstate(int level)
|
||||
{
|
||||
struct msr_rw_info msr;
|
||||
uint64_t where;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < __arraycount(state); i++) {
|
||||
@ -119,16 +121,17 @@ clockmod_setstate(int level)
|
||||
}
|
||||
KASSERT(i != __arraycount(state));
|
||||
|
||||
mcb.msr_read = true;
|
||||
mcb.msr_type = MSR_THERM_CONTROL;
|
||||
mcb.msr_mask = 0x1e;
|
||||
msr.msr_read = true;
|
||||
msr.msr_type = MSR_THERM_CONTROL;
|
||||
msr.msr_mask = 0x1e;
|
||||
|
||||
if (state[i].reg != 0) /* bit 0 reserved */
|
||||
mcb.msr_value = (state[i].reg << ODCM_REGOFFSET) | ODCM_ENABLE;
|
||||
msr.msr_value = (state[i].reg << ODCM_REGOFFSET) | ODCM_ENABLE;
|
||||
else
|
||||
mcb.msr_value = 0; /* max state */
|
||||
msr.msr_value = 0; /* max state */
|
||||
|
||||
msr_cpu_broadcast(&mcb);
|
||||
where = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL);
|
||||
xc_wait(where);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ipi.c,v 1.15 2009/08/18 16:41:03 jmcneill Exp $ */
|
||||
/* $NetBSD: ipi.c,v 1.16 2009/10/05 23:59:31 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2008, 2009 The NetBSD Foundation, Inc.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipi.c,v 1.15 2009/08/18 16:41:03 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipi.c,v 1.16 2009/10/05 23:59:31 rmind Exp $");
|
||||
|
||||
#include "opt_mtrr.h"
|
||||
|
||||
@ -53,8 +53,6 @@ __KERNEL_RCSID(0, "$NetBSD: ipi.c,v 1.15 2009/08/18 16:41:03 jmcneill Exp $");
|
||||
#include <machine/mtrr.h>
|
||||
#include <machine/gdt.h>
|
||||
|
||||
#include <x86/cpu_msr.h>
|
||||
|
||||
#include "acpica.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
@ -94,7 +92,7 @@ void (*ipifunc[X86_NIPI])(struct cpu_info *) =
|
||||
x86_ipi_synch_fpu,
|
||||
x86_ipi_reload_mtrr,
|
||||
gdt_reload_cpu,
|
||||
msr_write_ipi,
|
||||
NULL,
|
||||
acpi_cpu_sleep,
|
||||
x86_ipi_kpreempt
|
||||
};
|
||||
|
@ -1,139 +0,0 @@
|
||||
/* $NetBSD: msr_ipifuncs.c,v 1.15 2008/01/04 21:17:45 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Generic IPI handler to make writes to a MSR on x86, in all
|
||||
* CPUs available in the system.
|
||||
*
|
||||
* Thanks to Andrew Doran, Michael Van Elst and Quentin Garnier for
|
||||
* help and information provided.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: msr_ipifuncs.c,v 1.15 2008/01/04 21:17:45 ad Exp $");
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/cpu.h>
|
||||
|
||||
#include <x86/cpu_msr.h>
|
||||
|
||||
#include <machine/intrdefs.h>
|
||||
#include <machine/cpufunc.h>
|
||||
|
||||
static kmutex_t msr_mtx;
|
||||
static volatile uint64_t msr_setvalue, msr_setmask;
|
||||
static volatile int msr_type, msr_read;
|
||||
static volatile u_int msr_runcount;
|
||||
|
||||
|
||||
/*
|
||||
* This function will write the value of msr_setvalue in the MSR msr_type
|
||||
* and if a mask is provided, the value will be masked with msr_setmask.
|
||||
*/
|
||||
void
|
||||
msr_write_ipi(struct cpu_info *ci)
|
||||
{
|
||||
uint64_t msr = 0;
|
||||
|
||||
/* Read the MSR requested and apply the mask if defined. */
|
||||
if (msr_read)
|
||||
msr = rdmsr(msr_type);
|
||||
|
||||
if (msr_setmask)
|
||||
msr &= ~msr_setmask;
|
||||
|
||||
/* Ok, assign value now.*/
|
||||
if (msr_read)
|
||||
msr |= msr_setvalue;
|
||||
else
|
||||
msr = msr_setvalue;
|
||||
|
||||
/* Write it now */
|
||||
wrmsr(msr_type, msr);
|
||||
|
||||
/* This cpu has finished making all tasks, update the counter. */
|
||||
atomic_inc_uint(&msr_runcount);
|
||||
}
|
||||
|
||||
/*
|
||||
* Main function. Assigns values provided by the driver into the global
|
||||
* variables, necessary for the IPI handler.
|
||||
*/
|
||||
void
|
||||
msr_cpu_broadcast(struct msr_cpu_broadcast *mcb)
|
||||
{
|
||||
|
||||
if (!mcb->msr_type)
|
||||
panic("msr_type not defined");
|
||||
|
||||
/* We only want one CPU at a time sending these IPIs out. */
|
||||
mutex_enter(&msr_mtx);
|
||||
|
||||
/* Initialize counter, the task has not run in any cpu yet. */
|
||||
msr_runcount = 0;
|
||||
|
||||
/* Assign requested MSR type, value and mask. */
|
||||
msr_type = mcb->msr_type;
|
||||
msr_setvalue = mcb->msr_value;
|
||||
msr_setmask = mcb->msr_mask;
|
||||
msr_read = mcb->msr_read;
|
||||
|
||||
/*
|
||||
* Issue a full memory barrier, to make sure the operations
|
||||
* are done in a serialized way.
|
||||
*/
|
||||
membar_sync();
|
||||
|
||||
/* Run the IPI write handler in the CPUs. */
|
||||
msr_write_ipi(curcpu());
|
||||
|
||||
#ifdef MULTIPROCESSOR
|
||||
if (ncpu > 1)
|
||||
x86_broadcast_ipi(X86_IPI_WRITE_MSR);
|
||||
#endif
|
||||
|
||||
while (msr_runcount < ncpu)
|
||||
x86_pause();
|
||||
|
||||
/* We're done, so unlock. */
|
||||
mutex_exit(&msr_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes the mutex very early in the boot process
|
||||
* for future access.
|
||||
*/
|
||||
void
|
||||
msr_cpu_broadcast_initmtx(void)
|
||||
{
|
||||
|
||||
mutex_init(&msr_mtx, MUTEX_DEFAULT, IPL_NONE);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: powernow_k8.c,v 1.25 2009/08/23 16:02:50 ahoka Exp $ */
|
||||
/* $NetBSD: powernow_k8.c,v 1.26 2009/10/05 23:59:31 rmind Exp $ */
|
||||
/* $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */
|
||||
|
||||
/*-
|
||||
@ -59,7 +59,7 @@
|
||||
/* AMD POWERNOW K8 driver */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: powernow_k8.c,v 1.25 2009/08/23 16:02:50 ahoka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: powernow_k8.c,v 1.26 2009/10/05 23:59:31 rmind Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -67,6 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: powernow_k8.c,v 1.25 2009/08/23 16:02:50 ahoka Exp $
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/xcall.h>
|
||||
|
||||
#include <x86/cpu_msr.h>
|
||||
#include <x86/powernow.h>
|
||||
@ -78,12 +79,6 @@ __KERNEL_RCSID(0, "$NetBSD: powernow_k8.c,v 1.25 2009/08/23 16:02:50 ahoka Exp $
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#define WRITE_FIDVID(fid, vid, ctrl) \
|
||||
mcb.msr_read = false; \
|
||||
mcb.msr_value = (((ctrl) << 32) | (1ULL << 16) | ((vid) << 8) | (fid)); \
|
||||
mcb.msr_type = MSR_AMDK7_FIDVID_CTL; \
|
||||
msr_cpu_broadcast(&mcb);
|
||||
|
||||
#ifdef _MODULE
|
||||
static struct sysctllog *sysctllog;
|
||||
#define SYSCTLLOG &sysctllog
|
||||
@ -91,11 +86,6 @@ static struct sysctllog *sysctllog;
|
||||
#define SYSCTLLOG NULL
|
||||
#endif
|
||||
|
||||
#define READ_PENDING_WAIT(status) \
|
||||
do { \
|
||||
(status) = rdmsr(MSR_AMDK7_FIDVID_STATUS); \
|
||||
} while (PN8_STA_PENDING(status))
|
||||
|
||||
static struct powernow_cpu_state *k8pnow_current_state;
|
||||
static unsigned int cur_freq;
|
||||
static int powernow_node_target, powernow_node_current;
|
||||
@ -110,6 +100,26 @@ static int k8_powernow_setperf(unsigned int);
|
||||
static int k8_powernow_init_once(void);
|
||||
static void k8_powernow_init_main(void);
|
||||
|
||||
static uint64_t
|
||||
k8pnow_wr_fidvid(u_int fid, uint64_t vid, uint64_t ctrl)
|
||||
{
|
||||
struct msr_rw_info msr;
|
||||
uint64_t where, status;
|
||||
|
||||
msr.msr_read = false;
|
||||
msr.msr_value = (ctrl << 32) | (1ULL << 16) | (vid << 8) | fid;
|
||||
msr.msr_type = MSR_AMDK7_FIDVID_CTL;
|
||||
|
||||
where = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL);
|
||||
xc_wait(where);
|
||||
|
||||
do {
|
||||
status = rdmsr(MSR_AMDK7_FIDVID_STATUS);
|
||||
} while (PN8_STA_PENDING(status));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
k8pnow_sysctl_helper(SYSCTLFN_ARGS)
|
||||
{
|
||||
@ -151,7 +161,6 @@ k8_powernow_setperf(unsigned int freq)
|
||||
int cfid, cvid, fid = 0, vid = 0;
|
||||
int rvo;
|
||||
struct powernow_cpu_state *cstate;
|
||||
struct msr_cpu_broadcast mcb;
|
||||
|
||||
/*
|
||||
* We dont do a k8pnow_read_pending_wait here, need to ensure that the
|
||||
@ -186,8 +195,7 @@ k8_powernow_setperf(unsigned int freq)
|
||||
*/
|
||||
while (cvid > vid) {
|
||||
val = cvid - (1 << cstate->mvs);
|
||||
WRITE_FIDVID(cfid, (val > 0) ? val : 0, 1ULL);
|
||||
READ_PENDING_WAIT(status);
|
||||
status = k8pnow_wr_fidvid(cfid, (val > 0) ? val : 0, 1ULL);
|
||||
cvid = PN8_STA_CVID(status);
|
||||
COUNT_OFF_VST(cstate->vst);
|
||||
}
|
||||
@ -197,8 +205,7 @@ k8_powernow_setperf(unsigned int freq)
|
||||
/* XXX It's not clear from spec if we have to do that
|
||||
* in 0.25 step or in MVS. Therefore do it as it's done
|
||||
* under Linux */
|
||||
WRITE_FIDVID(cfid, cvid - 1, 1ULL);
|
||||
READ_PENDING_WAIT(status);
|
||||
status = k8pnow_wr_fidvid(cfid, cvid - 1, 1ULL);
|
||||
cvid = PN8_STA_CVID(status);
|
||||
COUNT_OFF_VST(cstate->vst);
|
||||
}
|
||||
@ -218,24 +225,23 @@ k8_powernow_setperf(unsigned int freq)
|
||||
val = FID_TO_VCO_FID(cfid) + 2;
|
||||
} else
|
||||
val = cfid - 2;
|
||||
WRITE_FIDVID(val, cvid, (uint64_t)cstate->pll * 1000 / 5);
|
||||
READ_PENDING_WAIT(status);
|
||||
status = k8pnow_wr_fidvid(val, cvid,
|
||||
(uint64_t)cstate->pll * 1000 / 5);
|
||||
cfid = PN8_STA_CFID(status);
|
||||
COUNT_OFF_IRT(cstate->irt);
|
||||
|
||||
vco_cfid = FID_TO_VCO_FID(cfid);
|
||||
}
|
||||
|
||||
WRITE_FIDVID(fid, cvid, (uint64_t) cstate->pll * 1000 / 5);
|
||||
READ_PENDING_WAIT(status);
|
||||
status = k8pnow_wr_fidvid(fid, cvid,
|
||||
(uint64_t)cstate->pll * 1000 / 5);
|
||||
cfid = PN8_STA_CFID(status);
|
||||
COUNT_OFF_IRT(cstate->irt);
|
||||
}
|
||||
|
||||
/* Phase 3: change to requested voltage */
|
||||
if (cvid != vid) {
|
||||
WRITE_FIDVID(cfid, vid, 1ULL);
|
||||
READ_PENDING_WAIT(status);
|
||||
status = k8pnow_wr_fidvid(cfid, vid, 1ULL);
|
||||
cvid = PN8_STA_CVID(status);
|
||||
COUNT_OFF_VST(cstate->vst);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: x86_machdep.c,v 1.33 2009/08/05 20:15:36 jym Exp $ */
|
||||
/* $NetBSD: x86_machdep.c,v 1.34 2009/10/05 23:59:31 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.33 2009/08/05 20:15:36 jym Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.34 2009/10/05 23:59:31 rmind Exp $");
|
||||
|
||||
#include "opt_modular.h"
|
||||
|
||||
@ -49,7 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.33 2009/08/05 20:15:36 jym Exp $")
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/extent.h>
|
||||
|
||||
#include <x86/cpu_msr.h>
|
||||
#include <x86/cpuvar.h>
|
||||
#include <x86/cputypes.h>
|
||||
#include <x86/machdep.h>
|
||||
@ -124,15 +123,6 @@ check_pa_acc(paddr_t pa, vm_prot_t prot)
|
||||
KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is to initialize the mutex used by x86/msr_ipifuncs.c.
|
||||
*/
|
||||
void
|
||||
x86_init(void)
|
||||
{
|
||||
msr_cpu_broadcast_initmtx();
|
||||
}
|
||||
|
||||
#ifdef MODULAR
|
||||
/*
|
||||
* Push any modules loaded by the boot loader.
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.xen,v 1.104 2009/08/16 15:35:52 manu Exp $
|
||||
# $NetBSD: files.xen,v 1.105 2009/10/05 23:59:31 rmind Exp $
|
||||
# NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp
|
||||
# NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp
|
||||
|
||||
@ -293,8 +293,6 @@ attach vcpu at xendevbus
|
||||
|
||||
file arch/xen/x86/cpu.c cpu | vcpu
|
||||
|
||||
file arch/x86/x86/msr_ipifuncs.c
|
||||
|
||||
#
|
||||
# Compatibility modules
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user