Module Name: src Committed By: jruoho Date: Thu Mar 17 15:59:36 UTC 2011
Modified Files: src/sys/dev/acpi: acpi_cpu.h acpi_cpu_pstate.c Log Message: Properly set the frequency during suspend and resume. Should fix problems introduced in the revision 1.42. Pointed out by Taylor C. Campbell. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/dev/acpi/acpi_cpu.h cvs rdiff -u -r1.45 -r1.46 src/sys/dev/acpi/acpi_cpu_pstate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/acpi/acpi_cpu.h diff -u src/sys/dev/acpi/acpi_cpu.h:1.37 src/sys/dev/acpi/acpi_cpu.h:1.38 --- src/sys/dev/acpi/acpi_cpu.h:1.37 Sat Mar 5 09:47:19 2011 +++ src/sys/dev/acpi/acpi_cpu.h Thu Mar 17 15:59:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu.h,v 1.37 2011/03/05 09:47:19 jruoho Exp $ */ +/* $NetBSD: acpi_cpu.h,v 1.38 2011/03/17 15:59:36 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen <jruoho...@iki.fi> @@ -210,6 +210,7 @@ uint64_t sc_pstate_aperf; /* ACPICPU_FLAG_P_HW */ uint64_t sc_pstate_mperf; /* ACPICPU_FLAG_P_HW*/ uint32_t sc_pstate_current; + uint32_t sc_pstate_saved; uint32_t sc_pstate_count; uint32_t sc_pstate_max; uint32_t sc_pstate_min; Index: src/sys/dev/acpi/acpi_cpu_pstate.c diff -u src/sys/dev/acpi/acpi_cpu_pstate.c:1.45 src/sys/dev/acpi/acpi_cpu_pstate.c:1.46 --- src/sys/dev/acpi/acpi_cpu_pstate.c:1.45 Sat Mar 5 09:47:19 2011 +++ src/sys/dev/acpi/acpi_cpu_pstate.c Thu Mar 17 15:59:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_pstate.c,v 1.45 2011/03/05 09:47:19 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_pstate.c,v 1.46 2011/03/17 15:59:36 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen <jruoho...@iki.fi> @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.45 2011/03/05 09:47:19 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.46 2011/03/17 15:59:36 jruoho Exp $"); #include <sys/param.h> #include <sys/kmem.h> @@ -56,7 +56,6 @@ static void acpicpu_pstate_bios(void); static void acpicpu_pstate_set_xcall(void *, void *); -static uint32_t acpicpu_pstate_saved = 0; extern struct acpicpu_softc **acpicpu_sc; void @@ -216,14 +215,15 @@ { struct acpicpu_softc *sc = device_private(self); struct acpicpu_pstate *ps = NULL; + struct cpu_info *ci = sc->sc_ci; + uint64_t xc; int32_t i; + /* + * Reset any dynamic limits. + */ mutex_enter(&sc->sc_mtx); acpicpu_pstate_reset(sc); - mutex_exit(&sc->sc_mtx); - - if (acpicpu_pstate_saved != 0) - return true; /* * Following design notes for Windows, we set the highest @@ -233,6 +233,8 @@ * Microsoft Corporation: Windows Native Processor * Performance Control. Version 1.1a, November, 2002. */ + sc->sc_pstate_saved = sc->sc_pstate_current; + for (i = sc->sc_pstate_count - 1; i >= 0; i--) { if (sc->sc_pstate[i].ps_freq != 0) { @@ -241,17 +243,16 @@ } } + mutex_exit(&sc->sc_mtx); + if (__predict_false(ps == NULL)) return true; - mutex_enter(&sc->sc_mtx); - acpicpu_pstate_saved = sc->sc_pstate_current; - mutex_exit(&sc->sc_mtx); - - if (acpicpu_pstate_saved == ps->ps_freq) + if (sc->sc_pstate_saved == ps->ps_freq) return true; - acpicpu_pstate_set(sc->sc_ci, ps->ps_freq); + xc = xc_unicast(0, acpicpu_pstate_set_xcall, &ps->ps_freq, NULL, ci); + xc_wait(xc); return true; } @@ -260,11 +261,11 @@ acpicpu_pstate_resume(device_t self) { struct acpicpu_softc *sc = device_private(self); + uint32_t freq = sc->sc_pstate_saved; + uint64_t xc; - if (acpicpu_pstate_saved != 0) { - acpicpu_pstate_set(sc->sc_ci, acpicpu_pstate_saved); - acpicpu_pstate_saved = 0; - } + xc = xc_unicast(0, acpicpu_pstate_set_xcall, &freq, NULL, sc->sc_ci); + xc_wait(xc); return true; }