diff options
author | 2010-09-09 04:13:15 +0000 | |
---|---|---|
committer | 2010-09-09 04:13:15 +0000 | |
commit | 2422124b87b60708604a53f82574bd716b0a8f86 (patch) | |
tree | a13af6f6e4fcdd935349e3188af03e46d4947c2d | |
parent | when I fixed the ruleset matching on rules that had more than one condition (diff) | |
download | wireguard-openbsd-2422124b87b60708604a53f82574bd716b0a8f86.tar.xz wireguard-openbsd-2422124b87b60708604a53f82574bd716b0a8f86.zip |
The resume powerhooks were always in the wrong place. Then when replaced
by the device-tree activate walk it even worse since we were doing so much
more work. apm_suspend() could return into the event handler and thus
tsleep() -- all this while we are supposedly trying to maintain splhigh
because our DVACT_SUSPEND mechanism has temporarily totally wrecked the
machine.
Move the hardware restoration code (DVACT_RESUME + other goo) to the same
function, and recognize that apm_resume() is just a boring event handler
which punts the event to userland.
ok oga
-rw-r--r-- | sys/arch/i386/i386/apm.c | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index 13b631cd3af..2499dc6a556 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.93 2010/09/08 21:38:43 deraadt Exp $ */ +/* $OpenBSD: apm.c,v 1.94 2010/09/09 04:13:15 deraadt Exp $ */ /*- * Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved. @@ -315,52 +315,35 @@ apm_power_print(struct apm_softc *sc, struct apmregs *regs) #endif } -int apm_saved_spl; - void apm_suspend(int state) { + extern int perflevel; + int s; + #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif /* NWSDISPLAY > 0 */ bufq_quiesce(); config_suspend(TAILQ_FIRST(&alldevs), DVACT_QUIESCE); - apm_saved_spl = splhigh(); + s = splhigh(); disable_intr(); config_suspend(TAILQ_FIRST(&alldevs), DVACT_SUSPEND); - (void)apm_set_powstate(APM_DEV_ALLDEVS, state); -} + /* Send machine to sleep */ + apm_set_powstate(APM_DEV_ALLDEVS, state); + /* Wake up */ -void -apm_resume(struct apm_softc *sc, struct apmregs *regs) -{ - extern int perflevel; - - apm_resumes = APM_RESUME_HOLDOFF; - - /* Some machines resume with interrupts on */ - (void) splhigh(); - disable_intr(); - - /* they say that some machines may require reinitializing the clocks */ + /* They say that some machines may require reinitializing the clocks */ i8254_startclock(); if (initclock_func == i8254_initclocks) rtcstart(); /* in i8254 mode, rtc is profclock */ - inittodr(time_second); - /* lower bit in cx means pccard was powered down */ config_suspend(TAILQ_FIRST(&alldevs), DVACT_RESUME); - enable_intr(); - splx(apm_saved_spl); - - apm_record_event(sc, regs->bx); - - /* acknowledge any rtc interrupt we may have missed */ - rtcdrain(NULL); + splx(s); /* restore hw.setperf */ if (cpu_setperf != NULL) @@ -371,6 +354,17 @@ apm_resume(struct apm_softc *sc, struct apmregs *regs) #endif /* NWSDISPLAY > 0 */ } +void +apm_resume(struct apm_softc *sc, struct apmregs *regs) +{ + + apm_resumes = APM_RESUME_HOLDOFF; + + /* lower bit in cx means pccard was powered down */ + + apm_record_event(sc, regs->bx); +} + int apm_record_event(struct apm_softc *sc, u_int type) { |