Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Initialize cpufreq(9) normally from main().



details:   https://anonhg.NetBSD.org/src/rev/b11554384c8b
branches:  trunk
changeset: 769977:b11554384c8b
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Sep 28 15:52:47 2011 +0000

description:
Initialize cpufreq(9) normally from main().

diffstat:

 sys/kern/init_main.c    |   8 ++++++--
 sys/kern/subr_cpufreq.c |  14 +++-----------
 sys/sys/cpufreq.h       |   7 ++++---
 3 files changed, 13 insertions(+), 16 deletions(-)

diffs (120 lines):

diff -r e0282c7119e8 -r b11554384c8b sys/kern/init_main.c
--- a/sys/kern/init_main.c      Wed Sep 28 15:38:21 2011 +0000
+++ b/sys/kern/init_main.c      Wed Sep 28 15:52:47 2011 +0000
@@ -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 @@
 #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 @@
        /* Initialize processor-sets */
        psets_init();
 
+       /* Initialize cpufreq(9) */
+       cpufreq_init();
+
        /* MI initialization of the boot cpu */
        error = mi_cpu_attach(curcpu());
        KASSERT(error == 0);
diff -r e0282c7119e8 -r b11554384c8b sys/kern/subr_cpufreq.c
--- a/sys/kern/subr_cpufreq.c   Wed Sep 28 15:38:21 2011 +0000
+++ b/sys/kern/subr_cpufreq.c   Wed Sep 28 15:52:47 2011 +0000
@@ -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 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);
diff -r e0282c7119e8 -r b11554384c8b sys/sys/cpufreq.h
--- a/sys/sys/cpufreq.h Wed Sep 28 15:38:21 2011 +0000
+++ b/sys/sys/cpufreq.h Wed Sep 28 15:52:47 2011 +0000
@@ -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 @@
 };
 
 #ifdef _KERNEL
+void           cpufreq_init(void);
 int            cpufreq_register(struct cpufreq *);
 void           cpufreq_deregister(void);
 void           cpufreq_suspend(struct cpu_info *);



Home | Main Index | Thread Index | Old Index