Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Properly set the frequency during suspend and r...



details:   https://anonhg.NetBSD.org/src/rev/50be275d75d1
branches:  trunk
changeset: 763350:50be275d75d1
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Thu Mar 17 15:59:36 2011 +0000

description:
Properly set the frequency during suspend and resume. Should fix problems
introduced in the revision 1.42. Pointed out by Taylor C. Campbell.

diffstat:

 sys/dev/acpi/acpi_cpu.h        |   3 ++-
 sys/dev/acpi/acpi_cpu_pstate.c |  35 ++++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 18 deletions(-)

diffs (111 lines):

diff -r 11fea6df2d24 -r 50be275d75d1 sys/dev/acpi/acpi_cpu.h
--- a/sys/dev/acpi/acpi_cpu.h   Thu Mar 17 15:59:32 2011 +0000
+++ b/sys/dev/acpi/acpi_cpu.h   Thu Mar 17 15:59:36 2011 +0000
@@ -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 <jruohonen%iki.fi@localhost>
@@ -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;
diff -r 11fea6df2d24 -r 50be275d75d1 sys/dev/acpi/acpi_cpu_pstate.c
--- a/sys/dev/acpi/acpi_cpu_pstate.c    Thu Mar 17 15:59:32 2011 +0000
+++ b/sys/dev/acpi/acpi_cpu_pstate.c    Thu Mar 17 15:59:36 2011 +0000
@@ -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 <jruohonen%iki.fi@localhost>
@@ -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;
 }



Home | Main Index | Thread Index | Old Index