| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: subr_cpufreq.c,v 1.3 2011/09/30 04:01:21 jruoho Exp $ */ | | 1 | /* $NetBSD: subr_cpufreq.c,v 1.4 2011/09/30 04:10:54 jruoho Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jukka Ruohonen. | | 8 | * by Jukka Ruohonen. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * | | 13 | * |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.3 2011/09/30 04:01:21 jruoho Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.4 2011/09/30 04:10:54 jruoho Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/cpu.h> | | 36 | #include <sys/cpu.h> |
37 | #include <sys/cpufreq.h> | | 37 | #include <sys/cpufreq.h> |
38 | #include <sys/kmem.h> | | 38 | #include <sys/kmem.h> |
39 | #include <sys/mutex.h> | | 39 | #include <sys/mutex.h> |
40 | #include <sys/time.h> | | 40 | #include <sys/time.h> |
41 | #include <sys/xcall.h> | | 41 | #include <sys/xcall.h> |
42 | | | 42 | |
43 | static int cpufreq_latency(void); | | 43 | static int cpufreq_latency(void); |
44 | static uint32_t cpufreq_get_max(void); | | 44 | static uint32_t cpufreq_get_max(void); |
45 | static uint32_t cpufreq_get_min(void); | | 45 | static uint32_t cpufreq_get_min(void); |
46 | static uint32_t cpufreq_get_raw(struct cpu_info *); | | 46 | static uint32_t cpufreq_get_raw(struct cpu_info *); |
| @@ -467,27 +467,26 @@ cpufreq_set_lower(struct cpu_info *ci) | | | @@ -467,27 +467,26 @@ cpufreq_set_lower(struct cpu_info *ci) |
467 | { | | 467 | { |
468 | cpufreq_set_step(ci, 1); | | 468 | cpufreq_set_step(ci, 1); |
469 | } | | 469 | } |
470 | | | 470 | |
471 | static void | | 471 | static void |
472 | cpufreq_set_step(struct cpu_info *ci, int32_t step) | | 472 | cpufreq_set_step(struct cpu_info *ci, int32_t step) |
473 | { | | 473 | { |
474 | struct cpufreq *cf = cf_backend; | | 474 | struct cpufreq *cf = cf_backend; |
475 | struct cpufreq_state cfs; | | 475 | struct cpufreq_state cfs; |
476 | uint32_t freq; | | 476 | uint32_t freq; |
477 | int32_t index; | | 477 | int32_t index; |
478 | | | 478 | |
479 | mutex_enter(&cpufreq_lock); | | 479 | mutex_enter(&cpufreq_lock); |
480 | cf = cf_backend; | | | |
481 | | | 480 | |
482 | if (__predict_false(cf->cf_init != true)) { | | 481 | if (__predict_false(cf->cf_init != true)) { |
483 | mutex_exit(&cpufreq_lock); | | 482 | mutex_exit(&cpufreq_lock); |
484 | return; | | 483 | return; |
485 | } | | 484 | } |
486 | | | 485 | |
487 | freq = cpufreq_get_raw(ci); | | 486 | freq = cpufreq_get_raw(ci); |
488 | | | 487 | |
489 | if (__predict_false(freq == 0)) { | | 488 | if (__predict_false(freq == 0)) { |
490 | mutex_exit(&cpufreq_lock); | | 489 | mutex_exit(&cpufreq_lock); |
491 | return; | | 490 | return; |
492 | } | | 491 | } |
493 | | | 492 | |