Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Remove X86_IPI_WRITE_MSR (and msr_ipifuncs.c), repl...
details: https://anonhg.NetBSD.org/src/rev/8f18d0b6b274
branches: trunk
changeset: 747931:8f18d0b6b274
user: rmind <rmind%NetBSD.org@localhost>
date: Mon Oct 05 23:59:30 2009 +0000
description:
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.
diffstat:
sys/arch/amd64/amd64/machdep.c | 7 +-
sys/arch/i386/i386/machdep.c | 8 +-
sys/arch/x86/conf/files.x86 | 3 +-
sys/arch/x86/include/cpu_msr.h | 38 +++++++---
sys/arch/x86/include/intrdefs.h | 8 +-
sys/arch/x86/x86/est.c | 23 ++++--
sys/arch/x86/x86/iclockmod.c | 21 +++--
sys/arch/x86/x86/ipi.c | 8 +-
sys/arch/x86/x86/msr_ipifuncs.c | 139 ----------------------------------------
sys/arch/x86/x86/powernow_k8.c | 54 ++++++++------
sys/arch/x86/x86/x86_machdep.c | 14 +---
sys/arch/xen/conf/files.xen | 4 +-
12 files changed, 97 insertions(+), 230 deletions(-)
diffs (truncated from 682 to 300 lines):
diff -r 59c853c80a80 -r 8f18d0b6b274 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Mon Oct 05 23:49:46 2009 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Mon Oct 05 23:59:30 2009 +0000
@@ -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 @@
#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 @@
splraise(IPL_HIGH);
x86_enable_intr();
- x86_init();
-
#ifdef DDB
if (boothowto & RB_KDB)
Debugger();
diff -r 59c853c80a80 -r 8f18d0b6b274 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Mon Oct 05 23:49:46 2009 +0000
+++ b/sys/arch/i386/i386/machdep.c Mon Oct 05 23:59:30 2009 +0000
@@ -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 @@
#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_init_tss(&cpu_info_primary);
ltr(cpu_info_primary.ci_tss_sel);
#endif
-
- x86_init();
}
/*
diff -r 59c853c80a80 -r 8f18d0b6b274 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86 Mon Oct 05 23:49:46 2009 +0000
+++ b/sys/arch/x86/conf/files.x86 Mon Oct 05 23:59:30 2009 +0000
@@ -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/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
diff -r 59c853c80a80 -r 8f18d0b6b274 sys/arch/x86/include/cpu_msr.h
--- a/sys/arch/x86/include/cpu_msr.h Mon Oct 05 23:49:46 2009 +0000
+++ b/sys/arch/x86/include/cpu_msr.h Mon Oct 05 23:59:30 2009 +0000
@@ -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 {
- int msr_read;
- int msr_type;
- uint64_t msr_value;
- uint64_t msr_mask;
+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 */
diff -r 59c853c80a80 -r 8f18d0b6b274 sys/arch/x86/include/intrdefs.h
--- a/sys/arch/x86/include/intrdefs.h Mon Oct 05 23:49:46 2009 +0000
+++ b/sys/arch/x86/include/intrdefs.h Mon Oct 05 23:59:30 2009 +0000
@@ -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
diff -r 59c853c80a80 -r 8f18d0b6b274 sys/arch/x86/x86/est.c
--- a/sys/arch/x86/x86/est.c Mon Oct 05 23:49:46 2009 +0000
+++ b/sys/arch/x86/x86/est.c Mon Oct 05 23:59:30 2009 +0000
@@ -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 @@
#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 int
est_sysctl_helper(SYSCTLFN_ARGS)
{
- struct msr_cpu_broadcast mcb;
struct sysctlnode node;
int fq, oldfq, error;
@@ -1033,17 +1033,22 @@
/* support writing to ...frequency.target */
if (rnode->sysctl_num == est_node_target && fq != oldfq) {
- int i;
+ 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;
diff -r 59c853c80a80 -r 8f18d0b6b274 sys/arch/x86/x86/iclockmod.c
--- a/sys/arch/x86/x86/iclockmod.c Mon Oct 05 23:49:46 2009 +0000
+++ b/sys/arch/x86/x86/iclockmod.c Mon Oct 05 23:59:30 2009 +0000
@@ -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 @@
#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 @@
#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 @@
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 @@
}
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 */
Home |
Main Index |
Thread Index |
Old Index