Mon Aug 9 04:27:07 2010 UTC ()
When retrieving the current frequency, scan all available P-states.
Only use the dynamic maximum when setting a frequency.


(jruoho)
diff -r1.6 -r1.7 src/sys/arch/x86/acpi/acpi_cpu_md.c
diff -r1.4 -r1.5 src/sys/dev/acpi/acpi_cpu_pstate.c

cvs diff -r1.6 -r1.7 src/sys/arch/x86/acpi/acpi_cpu_md.c (expand / switch to unified diff)

--- src/sys/arch/x86/acpi/acpi_cpu_md.c 2010/08/09 04:18:48 1.6
+++ src/sys/arch/x86/acpi/acpi_cpu_md.c 2010/08/09 04:27:07 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_cpu_md.c,v 1.6 2010/08/09 04:18:48 jruoho Exp $ */ 1/* $NetBSD: acpi_cpu_md.c,v 1.7 2010/08/09 04:27:07 jruoho Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> 4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.6 2010/08/09 04:18:48 jruoho Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.7 2010/08/09 04:27:07 jruoho Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/bus.h> 33#include <sys/bus.h>
34#include <sys/kcore.h> 34#include <sys/kcore.h>
35#include <sys/sysctl.h> 35#include <sys/sysctl.h>
36#include <sys/xcall.h> 36#include <sys/xcall.h>
37 37
38#include <x86/cpu.h> 38#include <x86/cpu.h>
39#include <x86/cpufunc.h> 39#include <x86/cpufunc.h>
40#include <x86/cputypes.h> 40#include <x86/cputypes.h>
41#include <x86/cpuvar.h> 41#include <x86/cpuvar.h>
42#include <x86/cpu_msr.h> 42#include <x86/cpu_msr.h>
43#include <x86/machdep.h> 43#include <x86/machdep.h>
@@ -355,27 +355,27 @@ acpicpu_md_pstate_get(struct acpicpu_sof @@ -355,27 +355,27 @@ acpicpu_md_pstate_get(struct acpicpu_sof
355 struct acpicpu_pstate *ps; 355 struct acpicpu_pstate *ps;
356 uint64_t val; 356 uint64_t val;
357 uint32_t i; 357 uint32_t i;
358 358
359 switch (cpu_vendor) { 359 switch (cpu_vendor) {
360 360
361 case CPUVENDOR_INTEL: 361 case CPUVENDOR_INTEL:
362 362
363 val = rdmsr(MSR_PERF_STATUS); 363 val = rdmsr(MSR_PERF_STATUS);
364 val = val & 0xffff; 364 val = val & 0xffff;
365 365
366 mutex_enter(&sc->sc_mtx); 366 mutex_enter(&sc->sc_mtx);
367 367
368 for (i = sc->sc_pstate_max; i < sc->sc_pstate_count; i++) { 368 for (i = 0; i < sc->sc_pstate_count; i++) {
369 369
370 ps = &sc->sc_pstate[i]; 370 ps = &sc->sc_pstate[i];
371 371
372 if (ps->ps_freq == 0) 372 if (ps->ps_freq == 0)
373 continue; 373 continue;
374 374
375 if (val == ps->ps_status) { 375 if (val == ps->ps_status) {
376 mutex_exit(&sc->sc_mtx); 376 mutex_exit(&sc->sc_mtx);
377 *freq = ps->ps_freq; 377 *freq = ps->ps_freq;
378 return 0; 378 return 0;
379 } 379 }
380 } 380 }
381 381

cvs diff -r1.4 -r1.5 src/sys/dev/acpi/acpi_cpu_pstate.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_cpu_pstate.c 2010/08/08 18:25:06 1.4
+++ src/sys/dev/acpi/acpi_cpu_pstate.c 2010/08/09 04:27:07 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_cpu_pstate.c,v 1.4 2010/08/08 18:25:06 jruoho Exp $ */ 1/* $NetBSD: acpi_cpu_pstate.c,v 1.5 2010/08/09 04:27:07 jruoho Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> 4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.4 2010/08/08 18:25:06 jruoho Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.5 2010/08/09 04:27:07 jruoho Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/kmem.h> 33#include <sys/kmem.h>
34#include <sys/once.h> 34#include <sys/once.h>
35 35
36#include <dev/acpi/acpireg.h> 36#include <dev/acpi/acpireg.h>
37#include <dev/acpi/acpivar.h> 37#include <dev/acpi/acpivar.h>
38#include <dev/acpi/acpi_cpu.h> 38#include <dev/acpi/acpi_cpu.h>
39 39
40#define _COMPONENT ACPI_BUS_COMPONENT 40#define _COMPONENT ACPI_BUS_COMPONENT
41ACPI_MODULE_NAME ("acpi_cpu_pstate") 41ACPI_MODULE_NAME ("acpi_cpu_pstate")
42 42
43static void acpicpu_pstate_attach_print(struct acpicpu_softc *); 43static void acpicpu_pstate_attach_print(struct acpicpu_softc *);
@@ -515,27 +515,27 @@ acpicpu_pstate_get(struct acpicpu_softc  @@ -515,27 +515,27 @@ acpicpu_pstate_get(struct acpicpu_softc
515 515
516 addr = sc->sc_pstate_status.reg_addr; 516 addr = sc->sc_pstate_status.reg_addr;
517 width = sc->sc_pstate_status.reg_bitwidth; 517 width = sc->sc_pstate_status.reg_bitwidth;
518 518
519 (void)AcpiOsReadPort(addr, &val, width); 519 (void)AcpiOsReadPort(addr, &val, width);
520 520
521 if (val == 0) { 521 if (val == 0) {
522 rv = EIO; 522 rv = EIO;
523 goto fail; 523 goto fail;
524 } 524 }
525 525
526 mutex_enter(&sc->sc_mtx); 526 mutex_enter(&sc->sc_mtx);
527 527
528 for (i = sc->sc_pstate_max; i < sc->sc_pstate_count; i++) { 528 for (i = 0; i < sc->sc_pstate_count; i++) {
529 529
530 if (sc->sc_pstate[i].ps_freq == 0) 530 if (sc->sc_pstate[i].ps_freq == 0)
531 continue; 531 continue;
532 532
533 if (val == sc->sc_pstate[i].ps_status) { 533 if (val == sc->sc_pstate[i].ps_status) {
534 ps = &sc->sc_pstate[i]; 534 ps = &sc->sc_pstate[i];
535 break; 535 break;
536 } 536 }
537 } 537 }
538 538
539 mutex_exit(&sc->sc_mtx); 539 mutex_exit(&sc->sc_mtx);
540 540
541 if (ps == NULL) { 541 if (ps == NULL) {