Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Clarify the initialization of the dynamic maxim...



details:   https://anonhg.NetBSD.org/src/rev/a1867ce87433
branches:  trunk
changeset: 757166:a1867ce87433
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Tue Aug 17 10:35:22 2010 +0000

description:
Clarify the initialization of the dynamic maximums/minimums. Reset these to
defaults upon suspend. As we do not know how well the firmware maintains
state, do not run the callbacks that evaluate the maximum/minimum on resume.

diffstat:

 sys/dev/acpi/acpi_cpu_pstate.c |  25 ++++++++++++++++---------
 sys/dev/acpi/acpi_cpu_tstate.c |  27 ++++++++++++++++-----------
 2 files changed, 32 insertions(+), 20 deletions(-)

diffs (169 lines):

diff -r 8a2f59119cfd -r a1867ce87433 sys/dev/acpi/acpi_cpu_pstate.c
--- a/sys/dev/acpi/acpi_cpu_pstate.c    Tue Aug 17 10:17:52 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_pstate.c    Tue Aug 17 10:35:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.27 2010/08/17 10:17:52 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.28 2010/08/17 10:35:22 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010 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.27 2010/08/17 10:17:52 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.28 2010/08/17 10:35:22 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -54,6 +54,7 @@
 static int              acpicpu_pstate_max(struct acpicpu_softc *);
 static int              acpicpu_pstate_min(struct acpicpu_softc *);
 static void             acpicpu_pstate_change(struct acpicpu_softc *);
+static void             acpicpu_pstate_reset(struct acpicpu_softc *);
 static void             acpicpu_pstate_bios(void);
 
 static uint32_t                 acpicpu_pstate_saved;
@@ -111,12 +112,10 @@
        if (ACPI_FAILURE(rv))
                aprint_debug_dev(self, "_PPC missing\n");
 
-       sc->sc_pstate_max = 0;
-       sc->sc_pstate_min = sc->sc_pstate_count - 1;
-
        sc->sc_flags |= ACPICPU_FLAG_P;
 
        acpicpu_pstate_bios();
+       acpicpu_pstate_reset(sc);
        acpicpu_pstate_attach_evcnt(sc);
        acpicpu_pstate_attach_print(sc);
 
@@ -274,6 +273,8 @@
        struct acpicpu_pstate *ps = NULL;
        int32_t i;
 
+       acpicpu_pstate_reset(sc);
+
        if (acpicpu_pstate_saved != 0)
                return true;
 
@@ -318,8 +319,6 @@
                acpicpu_pstate_saved = 0;
        }
 
-       acpicpu_pstate_callback(self);
-
        return true;
 }
 
@@ -809,8 +808,7 @@
        ACPI_OBJECT_LIST arg;
        ACPI_OBJECT obj[2];
 
-       sc->sc_pstate_max = 0;
-       sc->sc_pstate_min = sc->sc_pstate_count - 1;
+       acpicpu_pstate_reset(sc);
 
        arg.Count = 2;
        arg.Pointer = obj;
@@ -831,6 +829,15 @@
 }
 
 static void
+acpicpu_pstate_reset(struct acpicpu_softc *sc)
+{
+
+       sc->sc_pstate_max = 0;
+       sc->sc_pstate_min = sc->sc_pstate_count - 1;
+
+}
+
+static void
 acpicpu_pstate_bios(void)
 {
        const uint8_t val = AcpiGbl_FADT.PstateControl;
diff -r 8a2f59119cfd -r a1867ce87433 sys/dev/acpi/acpi_cpu_tstate.c
--- a/sys/dev/acpi/acpi_cpu_tstate.c    Tue Aug 17 10:17:52 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_tstate.c    Tue Aug 17 10:35:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_tstate.c,v 1.12 2010/08/17 10:17:52 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_tstate.c,v 1.13 2010/08/17 10:35:22 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.12 2010/08/17 10:17:52 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.13 2010/08/17 10:35:22 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -49,6 +49,7 @@
 static ACPI_STATUS      acpicpu_tstate_ptc(struct acpicpu_softc *);
 static ACPI_STATUS      acpicpu_tstate_fadt(struct acpicpu_softc *);
 static ACPI_STATUS      acpicpu_tstate_change(struct acpicpu_softc *);
+static void             acpicpu_tstate_reset(struct acpicpu_softc *);
 
 void
 acpicpu_tstate_attach(device_t self)
@@ -105,11 +106,9 @@
                sc->sc_flags |= ACPICPU_FLAG_T_FADT;
        }
 
-       sc->sc_tstate_max = 0;
-       sc->sc_tstate_min = sc->sc_tstate_count - 1;
-
        sc->sc_flags |= ACPICPU_FLAG_T;
 
+       acpicpu_tstate_reset(sc);
        acpicpu_tstate_attach_evcnt(sc);
        acpicpu_tstate_attach_print(sc);
 }
@@ -208,6 +207,9 @@
 bool
 acpicpu_tstate_suspend(device_t self)
 {
+       struct acpicpu_softc *sc = device_private(self);
+
+       acpicpu_tstate_reset(sc);
 
        return true;
 }
@@ -215,10 +217,6 @@
 bool
 acpicpu_tstate_resume(device_t self)
 {
-       struct acpicpu_softc *sc = device_private(self);
-
-       if ((sc->sc_flags & ACPICPU_FLAG_T_FADT) == 0)
-               acpicpu_tstate_callback(self);
 
        return true;
 }
@@ -584,8 +582,7 @@
        ACPI_INTEGER val;
        ACPI_STATUS rv;
 
-       sc->sc_tstate_max = 0;
-       sc->sc_tstate_min = sc->sc_tstate_count - 1;
+       acpicpu_tstate_reset(sc);
 
        /*
         * Evaluate the available T-state window:
@@ -621,6 +618,14 @@
        return AE_OK;
 }
 
+static void
+acpicpu_tstate_reset(struct acpicpu_softc *sc)
+{
+
+       sc->sc_tstate_max = 0;
+       sc->sc_tstate_min = sc->sc_tstate_count - 1;
+}
+
 int
 acpicpu_tstate_get(struct acpicpu_softc *sc, uint32_t *percent)
 {



Home | Main Index | Thread Index | Old Index