diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2004-05-27 08:20:00 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2004-05-27 08:20:00 +0000 |
commit | 0a99ac541c9efe82ecb3093e40ca49530a202dc7 (patch) | |
tree | 93111016767b67292593c45fd03945c0fd5f20a2 | |
parent | 14332f808c3174e10546d505a5a7e7828c34c1f8 (diff) |
apm restores perflevel after resume; some cpus are forgetful.
update cpu even with 100 -> 100 setperf changes, in case saved value
has gotten out of sync. from grange@ ok deraadt@ grange@
-rw-r--r-- | sys/arch/i386/i386/apm.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 13 |
2 files changed, 13 insertions, 8 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index fe90a90dd5a..1ade5dfb400 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.61 2004/03/11 17:20:33 millert Exp $ */ +/* $OpenBSD: apm.c,v 1.62 2004/05/27 08:19:59 tedu Exp $ */ /*- * Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved. @@ -347,6 +347,8 @@ apm_resume(sc, regs) struct apm_softc *sc; struct apmregs *regs; { + extern int perflevel; + apm_resumes = APM_RESUME_HOLDOFF; /* they say that some machines may require reinitializing the clock */ @@ -359,6 +361,10 @@ apm_resume(sc, regs) /* acknowledge any rtc interrupt we may have missed */ rtcdrain(NULL); + + /* restore hw.setperf */ + if (cpu_setperf != NULL) + cpu_setperf(perflevel); } int diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index f19f9f63e88..68c513b1815 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.108 2004/05/23 19:41:23 tedu Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.109 2004/05/27 08:19:59 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -100,6 +100,7 @@ int sysctl_emul(int *, u_int, void *, size_t *, void *, size_t); int (*cpu_cpuspeed)(int *); int (*cpu_setperf)(int); +int perflevel = 100; /* * Lock to avoid too many processes vslocking a large amount of memory @@ -524,8 +525,6 @@ hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) extern char machine[], cpu_model[]; int err; int cpuspeed; - static int perflevel = 100; - int operflevel; /* all sysctl names at this level except sensors are terminal */ if (name[0] != HW_SENSORS && namelen != 1) @@ -577,17 +576,17 @@ hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) case HW_SETPERF: if (!cpu_setperf) return (EOPNOTSUPP); - operflevel = perflevel; err = sysctl_int(oldp, oldlenp, newp, newlen, &perflevel); if (err) return err; - if (perflevel == operflevel) - return (0); if (perflevel > 100) perflevel = 100; if (perflevel < 0) perflevel = 0; - return (cpu_setperf(perflevel)); + if (newp) + return (cpu_setperf(perflevel)); + else + return (0); default: return (EOPNOTSUPP); } |