diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-09-09 04:13:16 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-09-09 04:13:16 +0000 |
commit | 668b4aae47fa6bc71b33fe9ea8f744b878c6c3f1 (patch) | |
tree | ac7594a3b45dde8b0039f289e4c2a050f618de10 /sys/arch | |
parent | 78d832669f3b2fcf5269cd7740e2e7ddf7f5b658 (diff) |
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
Diffstat (limited to 'sys/arch')
-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) { |