Module Name: src Committed By: jruoho Date: Wed Sep 28 15:52:48 UTC 2011
Modified Files: src/sys/kern: init_main.c subr_cpufreq.c src/sys/sys: cpufreq.h Log Message: Initialize cpufreq(9) normally from main(). To generate a diff of this commit: cvs rdiff -u -r1.435 -r1.436 src/sys/kern/init_main.c cvs rdiff -u -r1.1 -r1.2 src/sys/kern/subr_cpufreq.c cvs rdiff -u -r1.1 -r1.2 src/sys/sys/cpufreq.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.435 src/sys/kern/init_main.c:1.436 --- src/sys/kern/init_main.c:1.435 Sun Aug 7 13:33:01 2011 +++ src/sys/kern/init_main.c Wed Sep 28 15:52:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.435 2011/08/07 13:33:01 rmind Exp $ */ +/* $NetBSD: init_main.c,v 1.436 2011/09/28 15:52:47 jruoho Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.435 2011/08/07 13:33:01 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.436 2011/09/28 15:52:47 jruoho Exp $"); #include "opt_ddb.h" #include "opt_ipsec.h" @@ -130,6 +130,7 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c, #include <sys/errno.h> #include <sys/callout.h> #include <sys/cpu.h> +#include <sys/cpufreq.h> #include <sys/spldebug.h> #include <sys/kernel.h> #include <sys/mount.h> @@ -417,6 +418,9 @@ main(void) /* Initialize processor-sets */ psets_init(); + /* Initialize cpufreq(9) */ + cpufreq_init(); + /* MI initialization of the boot cpu */ error = mi_cpu_attach(curcpu()); KASSERT(error == 0); Index: src/sys/kern/subr_cpufreq.c diff -u src/sys/kern/subr_cpufreq.c:1.1 src/sys/kern/subr_cpufreq.c:1.2 --- src/sys/kern/subr_cpufreq.c:1.1 Wed Sep 28 10:55:48 2011 +++ src/sys/kern/subr_cpufreq.c Wed Sep 28 15:52:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_cpufreq.c,v 1.1 2011/09/28 10:55:48 jruoho Exp $ */ +/* $NetBSD: subr_cpufreq.c,v 1.2 2011/09/28 15:52:48 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -30,18 +30,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.1 2011/09/28 10:55:48 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.2 2011/09/28 15:52:48 jruoho Exp $"); #include <sys/param.h> #include <sys/cpu.h> #include <sys/cpufreq.h> #include <sys/kmem.h> #include <sys/mutex.h> -#include <sys/once.h> #include <sys/time.h> #include <sys/xcall.h> -static int cpufreq_init(void); static int cpufreq_latency(void); static uint32_t cpufreq_get_max(void); static uint32_t cpufreq_get_min(void); @@ -53,25 +51,19 @@ static void cpufreq_set_all_raw(uint32_ static kmutex_t cpufreq_lock __cacheline_aligned; static struct cpufreq *cf_backend __read_mostly = NULL; -static int +void cpufreq_init(void) { mutex_init(&cpufreq_lock, MUTEX_DEFAULT, IPL_NONE); - - return 0; } int cpufreq_register(struct cpufreq *cf) { - static ONCE_DECL(cpufreq_once); uint32_t count, i, j, k, m; int rv; - rv = RUN_ONCE(&cpufreq_once, cpufreq_init); - - KASSERT(rv == 0); KASSERT(cf != NULL); KASSERT(cf->cf_get_freq != NULL); KASSERT(cf->cf_set_freq != NULL); Index: src/sys/sys/cpufreq.h diff -u src/sys/sys/cpufreq.h:1.1 src/sys/sys/cpufreq.h:1.2 --- src/sys/sys/cpufreq.h:1.1 Wed Sep 28 10:55:48 2011 +++ src/sys/sys/cpufreq.h Wed Sep 28 15:52:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufreq.h,v 1.1 2011/09/28 10:55:48 jruoho Exp $ */ +/* $NetBSD: cpufreq.h,v 1.2 2011/09/28 15:52:47 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -46,8 +46,8 @@ #define CPUFREQ_STATE_MAX 64 #define CPUFREQ_LATENCY_MAX UINT16_MAX /* Maximum per-CPU latency */ -#define CPUFREQ_STATE_ENABLED UINT32_MAX -#define CPUFREQ_STATE_DISABLED UINT32_MAX - 1 +#define CPUFREQ_STATE_ENABLED UINT32_MAX +#define CPUFREQ_STATE_DISABLED UINT32_MAX - 1 struct cpufreq_state { uint32_t cfs_freq; /* MHz */ @@ -76,6 +76,7 @@ struct cpufreq { }; #ifdef _KERNEL +void cpufreq_init(void); int cpufreq_register(struct cpufreq *); void cpufreq_deregister(void); void cpufreq_suspend(struct cpu_info *);