summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2012-09-08 20:58:50 +0000
committerkettenis <kettenis@openbsd.org>2012-09-08 20:58:50 +0000
commit92fcc01d90ea6b4558bdd734bcbd2e920bb1a96f (patch)
tree27e556d958e74cdc87ad2ba55554644d378df66b
parentLink init_priority into the regress tree now that it passes (except (diff)
downloadwireguard-openbsd-92fcc01d90ea6b4558bdd734bcbd2e920bb1a96f.tar.xz
wireguard-openbsd-92fcc01d90ea6b4558bdd734bcbd2e920bb1a96f.zip
On SPARC64 VI/VII CPUs, use the lseep instruction in the idle loop to force a
thread switch in the hope the other thread can do some useful work.
-rw-r--r--sys/arch/sparc64/sparc64/cpu.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c
index bcdf288a3df..29ee24bb25d 100644
--- a/sys/arch/sparc64/sparc64/cpu.c
+++ b/sys/arch/sparc64/sparc64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.56 2011/01/13 22:55:33 matthieu Exp $ */
+/* $OpenBSD: cpu.c,v 1.57 2012/09/08 20:58:50 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.13 2001/05/26 21:27:15 chs Exp $ */
/*
@@ -788,10 +788,24 @@ cpu_idle_cycle(void)
sparc_wrpr(pstate, sparc_rdpr(pstate) & ~PSTATE_IE, 0);
}
#endif
+
+ /*
+ * On processors with multiple threads we simply force a
+ * thread switch. Using the sleep instruction seems to work
+ * just as well as using the suspend instruction and makes the
+ * code a little bit less complicated.
+ */
+ __asm __volatile(
+ "999: nop \n"
+ " .section .sun4u_mtp_patch, \"ax\" \n"
+ " .word 999b \n"
+ " .word 0x81b01060 ! sleep \n"
+ " .previous \n"
+ : : : "memory");
}
void
-cpu_idle_leave()
+cpu_idle_leave(void)
{
if (CPU_ISSUN4V) {
sparc_wrpr(pstate, sparc_rdpr(pstate) | PSTATE_IE, 0);