diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-02-27 21:15:46 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-02-27 21:15:46 +0000 |
commit | ff57b30819373fd7e2135484db1c3b0cd874fcd3 (patch) | |
tree | 8a7894b15573209222d27febbcf31bb6af2a8626 /sys | |
parent | 7e8c2ed9cc5ceb5d64086482a297efa79f805523 (diff) |
Introduce simple priorities mechanism so that concurrent
hw.setperf handlers don't override each other.
Problem reported and tested by danh@.
ok tedu@ deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/i386/est.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/i386/p4tcc.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/pci/pcib.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 3 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 3 |
5 files changed, 17 insertions, 7 deletions
diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c index 0ac6b4c7137..b543ea4f7f7 100644 --- a/sys/arch/i386/i386/est.c +++ b/sys/arch/i386/i386/est.c @@ -1,4 +1,4 @@ -/* $OpenBSD: est.c,v 1.5 2004/02/14 15:09:22 grange Exp $ */ +/* $OpenBSD: est.c,v 1.6 2004/02/27 21:15:45 grange Exp $ */ /* * Copyright (c) 2003 Michael Eriksson. * All rights reserved. @@ -201,6 +201,9 @@ est_init(const char *cpu_device) const struct fqlist *fql; extern char cpu_brandstr[]; + if (setperf_prio > 3) + return; + if ((cpu_ecxfeature & CPUIDECX_EST) == 0) return; @@ -256,6 +259,7 @@ est_init(const char *cpu_device) cpu_setperf = est_setperf; cpu_cpuspeed = est_cpuspeed; + setperf_prio = 3; } int diff --git a/sys/arch/i386/i386/p4tcc.c b/sys/arch/i386/i386/p4tcc.c index de896265b05..3e0c3b41795 100644 --- a/sys/arch/i386/i386/p4tcc.c +++ b/sys/arch/i386/i386/p4tcc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p4tcc.c,v 1.2 2004/02/14 15:09:22 grange Exp $ */ +/* $OpenBSD: p4tcc.c,v 1.3 2004/02/27 21:15:45 grange Exp $ */ /* * Copyright (c) 2003 Ted Unangst * All rights reserved. @@ -62,6 +62,8 @@ static struct { void p4tcc_init(int model, int step) { + if (setperf_prio > 1) + return; switch (step) { case 0x22: /* errata O50 P44 and Z21 */ @@ -85,7 +87,7 @@ p4tcc_init(int model, int step) } cpu_setperf = p4tcc_setperf; - + setperf_prio = 1; } #if 0 diff --git a/sys/arch/i386/pci/pcib.c b/sys/arch/i386/pci/pcib.c index 39994a6558e..2dc4c12138f 100644 --- a/sys/arch/i386/pci/pcib.c +++ b/sys/arch/i386/pci/pcib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcib.c,v 1.12 2004/02/19 21:38:44 grange Exp $ */ +/* $OpenBSD: pcib.c,v 1.13 2004/02/27 21:15:45 grange Exp $ */ /* $NetBSD: pcib.c,v 1.6 1997/06/06 23:29:16 thorpej Exp $ */ /*- @@ -125,7 +125,8 @@ pcibattach(parent, self, aux) /* * Detect and activate SpeedStep on ICHx-M chipsets. */ - if (ichss_match(aux) && ichss_attach(self, aux) == 0) + if (setperf_prio < 2 && ichss_match(aux) && + ichss_attach(self, aux) == 0) printf(": SpeedStep"); #endif @@ -226,6 +227,7 @@ ichss_attach(struct device *self, void *aux) /* Hook into hw.setperf sysctl */ ichss_cookie = sc; cpu_setperf = ichss_setperf; + setperf_prio = 2; return (0); } diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 472d9f645b9..b1521a30465 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.101 2004/02/15 11:14:45 markus Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.102 2004/02/27 21:15:45 grange Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -98,6 +98,7 @@ int sysctl_emul(int *, u_int, void *, size_t *, void *, size_t); int (*cpu_cpuspeed)(int *); int (*cpu_setperf)(int); +int setperf_prio = 0; /* for concurrent handlers */ /* * Lock to avoid too many processes vslocking a large amount of memory diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index dd744013255..a4fe6a574b6 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.74 2004/02/24 21:43:56 tedu Exp $ */ +/* $OpenBSD: sysctl.h,v 1.75 2004/02/27 21:15:45 grange Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -680,6 +680,7 @@ int sysctl_wdog(int *, u_int, void *, size_t *, void *, size_t); extern int (*cpu_cpuspeed)(int *); extern int (*cpu_setperf)(int); +extern int setperf_prio; int bpf_sysctl(int *, u_int, void *, size_t *, void *, size_t); |