summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-11-29 17:11:31 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-11-29 17:11:31 +0000
commitb8afbe8330050714ea23545de669125c8cd6fb90 (patch)
treea498ce5bd7d856dfb5995a51bec691ec45ccbaaf /sys/arch/i386
parentee8f82e280f39d9319a0bb7063d0412c8125b76d (diff)
Reload mtrr state on all CPUs after updates. Seems to speed up X on MP
systems, at least with Intel graphics. ok marco@, deraadt@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/i686_mem.c39
-rw-r--r--sys/arch/i386/i386/ipifuncs.c36
-rw-r--r--sys/arch/i386/i386/k6_mem.c3
3 files changed, 51 insertions, 27 deletions
diff --git a/sys/arch/i386/i386/i686_mem.c b/sys/arch/i386/i386/i686_mem.c
index 0f746bd30e7..42bc25698e0 100644
--- a/sys/arch/i386/i386/i686_mem.c
+++ b/sys/arch/i386/i386/i686_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i686_mem.c,v 1.10 2007/09/07 15:00:19 art Exp $ */
+/* $OpenBSD: i686_mem.c,v 1.11 2009/11/29 17:11:30 kettenis Exp $ */
/*-
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -34,6 +34,7 @@
#include <sys/memrange.h>
#include <machine/cpufunc.h>
+#include <machine/intr.h>
#include <machine/specialreg.h>
/*
@@ -62,36 +63,35 @@ char *mem_owner_bios = "BIOS";
void i686_mrinit(struct mem_range_softc *sc);
int i686_mrset(struct mem_range_softc *sc,
- struct mem_range_desc *mrd,
- int *arg);
+ struct mem_range_desc *mrd, int *arg);
void i686_mrAPinit(struct mem_range_softc *sc);
+void i686_mrreload(struct mem_range_softc *sc);
struct mem_range_ops i686_mrops = {
i686_mrinit,
i686_mrset,
- i686_mrAPinit
+ i686_mrAPinit,
+ i686_mrreload
};
/* XXX for AP startup hook */
u_int64_t mtrrcap, mtrrdef;
struct mem_range_desc *mem_range_match(struct mem_range_softc *sc,
- struct mem_range_desc *mrd);
+ struct mem_range_desc *mrd);
void i686_mrfetch(struct mem_range_softc *sc);
int i686_mtrrtype(int flags);
int i686_mrt2mtrr(int flags, int oldval);
int i686_mtrr2mrt(int val);
int i686_mtrrconflict(int flag1, int flag2);
void i686_mrstore(struct mem_range_softc *sc);
-void i686_mrstoreone(void *arg);
+void i686_mrstoreone(struct mem_range_softc *sc);
struct mem_range_desc *i686_mtrrfixsearch(struct mem_range_softc *sc,
- u_int64_t addr);
+ u_int64_t addr);
int i686_mrsetlow(struct mem_range_softc *sc,
- struct mem_range_desc *mrd,
- int *arg);
+ struct mem_range_desc *mrd, int *arg);
int i686_mrsetvariable(struct mem_range_softc *sc,
- struct mem_range_desc *mrd,
- int *arg);
+ struct mem_range_desc *mrd, int *arg);
/* i686 MTRR type to memory range type conversion */
int i686_mtrrtomrt[] = {
@@ -264,7 +264,10 @@ void
i686_mrstore(struct mem_range_softc *sc)
{
disable_intr(); /* disable interrupts */
- i686_mrstoreone((void *)sc);
+#ifdef MULTIPROCESSOR
+ i386_broadcast_ipi(I386_IPI_MTRR);
+#endif
+ i686_mrstoreone(sc);
enable_intr();
}
@@ -274,9 +277,8 @@ i686_mrstore(struct mem_range_softc *sc)
* just stuffing one entry; this is simpler (but slower, of course).
*/
void
-i686_mrstoreone(void *arg)
+i686_mrstoreone(struct mem_range_softc *sc)
{
- struct mem_range_softc *sc = (struct mem_range_softc *)arg;
struct mem_range_desc *mrd;
u_int64_t omsrv, msrv;
int i, j, msr;
@@ -595,7 +597,14 @@ i686_mrinit(struct mem_range_softc *sc)
void
i686_mrAPinit(struct mem_range_softc *sc)
{
- i686_mrstoreone((void *)sc); /* set MTRRs to match BSP */
+ i686_mrstoreone(sc); /* set MTRRs to match BSP */
wrmsr(MSR_MTRRdefType, mtrrdef); /* set MTRR behaviour to match BSP */
}
+void
+i686_mrreload(struct mem_range_softc *sc)
+{
+ disable_intr(); /* disable interrupts */
+ i686_mrstoreone(sc); /* set MTRRs to match BSP */
+ enable_intr();
+}
diff --git a/sys/arch/i386/i386/ipifuncs.c b/sys/arch/i386/i386/ipifuncs.c
index 6bf5012a107..aeba0d7df00 100644
--- a/sys/arch/i386/i386/ipifuncs.c
+++ b/sys/arch/i386/i386/ipifuncs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipifuncs.c,v 1.13 2008/06/26 05:42:10 ray Exp $ */
+/* $OpenBSD: ipifuncs.c,v 1.14 2009/11/29 17:11:30 kettenis Exp $ */
/* $NetBSD: ipifuncs.c,v 1.1.2.3 2000/06/26 02:04:06 sommerfeld Exp $ */
/*-
@@ -32,19 +32,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
/*
* Interprocessor interrupt handlers.
*/
+#include "mtrr.h"
#include "npx.h"
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/memrange.h>
#include <sys/systm.h>
+#include <uvm/uvm_extern.h>
+
#include <machine/cpufunc.h>
#include <machine/cpuvar.h>
#include <machine/intr.h>
@@ -52,19 +55,22 @@
#include <machine/i82093var.h>
#include <machine/db_machdep.h>
-#include <uvm/uvm_extern.h>
-
+void i386_ipi_nop(struct cpu_info *);
void i386_ipi_halt(struct cpu_info *);
#if NNPX > 0
void i386_ipi_synch_fpu(struct cpu_info *);
void i386_ipi_flush_fpu(struct cpu_info *);
#else
-#define i386_ipi_synch_fpu 0
-#define i386_ipi_flush_fpu 0
+#define i386_ipi_synch_fpu NULL
+#define i386_ipi_flush_fpu NULL
#endif
-void i386_ipi_nop(struct cpu_info *);
+#if NMTRR > 0
+void i386_ipi_reload_mtrr(struct cpu_info *);
+#else
+#define i386_ipi_reload_mtrr 0
+#endif
void (*ipifunc[I386_NIPI])(struct cpu_info *) =
{
@@ -72,17 +78,16 @@ void (*ipifunc[I386_NIPI])(struct cpu_info *) =
i386_ipi_nop,
i386_ipi_flush_fpu,
i386_ipi_synch_fpu,
+ i386_ipi_reload_mtrr,
#if 0
- i386_reload_mtrr,
gdt_reload_cpu,
#else
- 0,
- 0,
+ NULL,
#endif
#ifdef DDB
i386_ipi_db,
#else
- 0,
+ NULL,
#endif
i386_setperf_ipi,
};
@@ -117,6 +122,15 @@ i386_ipi_synch_fpu(struct cpu_info *ci)
}
#endif
+#if NMTRR > 0
+void
+i386_ipi_reload_mtrr(struct cpu_info *ci)
+{
+ if (mem_range_softc.mr_op != NULL)
+ mem_range_softc.mr_op->reload(&mem_range_softc);
+}
+#endif
+
void
i386_spurious(void)
{
diff --git a/sys/arch/i386/i386/k6_mem.c b/sys/arch/i386/i386/k6_mem.c
index af8e4e38d42..591ee2f4266 100644
--- a/sys/arch/i386/i386/k6_mem.c
+++ b/sys/arch/i386/i386/k6_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: k6_mem.c,v 1.9 2009/08/15 00:34:44 jsg Exp $ */
+/* $OpenBSD: k6_mem.c,v 1.10 2009/11/29 17:11:30 kettenis Exp $ */
/*-
* Copyright (c) 1999 Brian Fundakowski Feldman
* All rights reserved.
@@ -67,6 +67,7 @@ static __inline int k6_mrmake(struct mem_range_desc *, u_int32_t *);
struct mem_range_ops k6_mrops = {
k6_mrinit,
k6_mrset,
+ NULL,
NULL
};