From 67fcddd62762610d5b2fbefaf3846e3f045e7190 Mon Sep 17 00:00:00 2001 From: jruoho Date: Thu, 27 Oct 2011 05:25:07 +0000 Subject: [PATCH] Revert the revision 1.5 in cpufreq(9). Instead, document that the KPI can not be used before interrupts have been enabled. Suggested by macallan@. --- share/man/man9/cpufreq.9 | 10 +++++++--- sys/dev/acpi/acpi_cpu.c | 10 ++-------- sys/kern/subr_cpufreq.c | 12 +++++++++--- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/share/man/man9/cpufreq.9 b/share/man/man9/cpufreq.9 index 00ad629f5251..8e04e1e71d18 100644 --- a/share/man/man9/cpufreq.9 +++ b/share/man/man9/cpufreq.9 @@ -1,4 +1,4 @@ -.\" $NetBSD: cpufreq.9,v 1.5 2011/10/20 06:48:24 jruoho Exp $ */ +.\" $NetBSD: cpufreq.9,v 1.6 2011/10/27 05:25:08 jruoho Exp $ */ .\" .\" Copyright (c) 2011 Jukka Ruohonen .\" All rights reserved. @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 20, 2011 +.Dd October 27, 2011 .Dt CPUFREQ 9 .Os .Sh NAME @@ -115,7 +115,11 @@ a machine-dependent backend with the framework. Only one backend can be registered. Upon successful completion, .Fn cpufreq_register -returns 0. +returns 0 and sets the frequency of all processors +to the maximum available level. +Note that the registration can be done +only after interrupts have been enabled; cf. +.Xr config_interrupts 9 . .Pp The following elements in .Vt struct cpufreq diff --git a/sys/dev/acpi/acpi_cpu.c b/sys/dev/acpi/acpi_cpu.c index 185d7e10fc6c..3d51ff9e1a89 100644 --- a/sys/dev/acpi/acpi_cpu.c +++ b/sys/dev/acpi/acpi_cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu.c,v 1.46 2011/10/20 06:57:23 jruoho Exp $ */ +/* $NetBSD: acpi_cpu.c,v 1.47 2011/10/27 05:25:07 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.46 2011/10/20 06:57:23 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.47 2011/10/27 05:25:07 jruoho Exp $"); #include #include @@ -327,12 +327,6 @@ acpicpu_start(device_t self) if (cpufreq_register(&cf) != 0) aprint_error_dev(self, "failed to register cpufreq\n"); - else { - /* - * Initialize the states to P0. - */ - cpufreq_set_all(sc->sc_pstate[0].ps_freq); - } } } diff --git a/sys/kern/subr_cpufreq.c b/sys/kern/subr_cpufreq.c index d4b7a5a66513..4e8b050cdad1 100644 --- a/sys/kern/subr_cpufreq.c +++ b/sys/kern/subr_cpufreq.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_cpufreq.c,v 1.7 2011/10/25 18:26:09 christos Exp $ */ +/* $NetBSD: subr_cpufreq.c,v 1.8 2011/10/27 05:25:07 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -30,11 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.7 2011/10/25 18:26:09 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.8 2011/10/27 05:25:07 jruoho Exp $"); #include #include #include +#include #include #include #include @@ -62,9 +63,12 @@ cpufreq_init(void) int cpufreq_register(struct cpufreq *cf) { - uint32_t c, i, j, k; + uint32_t c, i, j, k, m; int rv; + if (cold != 0) + return EBUSY; + KASSERT(cf != NULL); KASSERT(cf_backend != NULL); KASSERT(cf->cf_get_freq != NULL); @@ -138,6 +142,8 @@ cpufreq_register(struct cpufreq *cf) return rv; } + m = cpufreq_get_max(); + cpufreq_set_all_raw(m); mutex_exit(&cpufreq_lock); return 0;