summaryrefslogtreecommitdiffstats
path: root/sys/x86
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-05-19 14:21:00 +0000
committerkib <kib@FreeBSD.org>2015-05-19 14:21:00 +0000
commit3ca3bb1c2cbcd54ceae0e6323acca390c2737b0f (patch)
tree6aa5b9377300ca1a89860f1d5cf3a2abaf5a6a59 /sys/x86
parentd2cafe1802f18314fd0996775fe5accb88210a4f (diff)
downloadFreeBSD-src-3ca3bb1c2cbcd54ceae0e6323acca390c2737b0f.zip
FreeBSD-src-3ca3bb1c2cbcd54ceae0e6323acca390c2737b0f.tar.gz
When sleeping in Sx state using MWAIT instruction, accept fast wakeup
requests from writes to the monitored line. Submitted by: avg
Diffstat (limited to 'sys/x86')
-rw-r--r--sys/x86/x86/cpu_machdep.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c
index 7925713..f07b97e 100644
--- a/sys/x86/x86/cpu_machdep.c
+++ b/sys/x86/x86/cpu_machdep.c
@@ -101,6 +101,10 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_pager.h>
#include <vm/vm_param.h>
+#define STATE_RUNNING 0x0
+#define STATE_MWAIT 0x1
+#define STATE_SLEEPING 0x2
+
/*
* Machine dependent boot() routine
*
@@ -134,13 +138,24 @@ acpi_cpu_idle_mwait(uint32_t mwait_hint)
{
int *state;
- state = (int *)PCPU_PTR(monitorbuf);
/*
* XXXKIB. Software coordination mode should be supported,
* but all Intel CPUs provide hardware coordination.
*/
+
+ state = (int *)PCPU_PTR(monitorbuf);
+ KASSERT(*state == STATE_SLEEPING,
+ ("cpu_mwait_cx: wrong monitorbuf state"));
+ *state = STATE_MWAIT;
cpu_monitor(state, 0, 0);
- cpu_mwait(MWAIT_INTRBREAK, mwait_hint);
+ if (*state == STATE_MWAIT)
+ cpu_mwait(MWAIT_INTRBREAK, mwait_hint);
+
+ /*
+ * We should exit on any event that interrupts mwait, because
+ * that event might be a wanted interrupt.
+ */
+ *state = STATE_RUNNING;
}
/* Get current clock frequency for the given cpu id. */
@@ -231,10 +246,6 @@ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */
SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait,
0, "Use MONITOR/MWAIT for short idle");
-#define STATE_RUNNING 0x0
-#define STATE_MWAIT 0x1
-#define STATE_SLEEPING 0x2
-
#ifndef PC98
static void
cpu_idle_acpi(sbintime_t sbt)
OpenPOWER on IntegriCloud