Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Three small things: (1) fix off by one, (2) pro...



details:   https://anonhg.NetBSD.org/src/rev/b94293f0a80e
branches:  trunk
changeset: 757054:b94293f0a80e
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Thu Aug 12 06:17:14 2010 +0000

description:
Three small things: (1) fix off by one, (2) protect the cached P-state
(required for interaction with T-states), and (3) use aprint_debug(9)
instead of the ACPI_DEBUG_PRINT(x) macro for the dynamic frequency changes
(for the time being, people need easier way to observe the dynamic changes).

diffstat:

 sys/dev/acpi/acpi_cpu_pstate.c |  33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diffs (119 lines):

diff -r 8482bd895073 -r b94293f0a80e sys/dev/acpi/acpi_cpu_pstate.c
--- a/sys/dev/acpi/acpi_cpu_pstate.c    Wed Aug 11 20:10:55 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_pstate.c    Thu Aug 12 06:17:14 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.13 2010/08/11 18:15:52 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.14 2010/08/12 06:17:14 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.13 2010/08/11 18:15:52 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.14 2010/08/12 06:17:14 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -242,20 +242,21 @@
 
        mutex_exit(&sc->sc_mtx);
 
-#if 0
        if (old != new) {
 
+               aprint_debug_dev(sc->sc_dev, "maximum frequency "
+                   "changed from P%u (%u MHz) to P%u (%u MHz)\n",
+                   old, sc->sc_pstate[old].ps_freq, new,
+                   sc->sc_pstate[sc->sc_pstate_max].ps_freq);
+#if 0
                /*
                 * If the maximum changed, proactively
                 * raise or lower the target frequency.
                 */
                acpicpu_pstate_set(sc, sc->sc_pstate[new].ps_freq);
 
-               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "frequency changed from "
-                       "%u MHz to %u MHz\n", sc->sc_pstate[old].ps_freq,
-                       sc->sc_pstate[sc->sc_pstate_max].ps_freq));
+#endif
        }
-#endif
 }
 
 ACPI_STATUS
@@ -494,13 +495,13 @@
        if (ACPI_FAILURE(rv))
                return 1;
 
-       if (val > (uint64_t)sc->sc_pstate_count)
+       if (val > sc->sc_pstate_count - 1)
                return 1;
 
        if (sc->sc_pstate[val].ps_freq == 0)
                return 1;
 
-       sc->sc_pstate_max = val;                /* XXX: sysctl(8) knob?  */
+       sc->sc_pstate_max = val;
 
        return 0;
 }
@@ -555,11 +556,16 @@
                goto fail;
        }
 
+       mutex_enter(&sc->sc_mtx);
+
        if (sc->sc_pstate_current != ACPICPU_P_STATE_UNKNOWN) {
                *freq = sc->sc_pstate_current;
+               mutex_exit(&sc->sc_mtx);
                return 0;
        }
 
+       mutex_exit(&sc->sc_mtx);
+
        switch (method) {
 
        case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -611,7 +617,9 @@
                goto fail;
        }
 
+       mutex_enter(&sc->sc_mtx);
        sc->sc_pstate_current = *freq;
+       mutex_exit(&sc->sc_mtx);
 
        return 0;
 
@@ -619,7 +627,9 @@
        aprint_error_dev(sc->sc_dev, "failed "
            "to get frequency (err %d)\n", rv);
 
+       mutex_enter(&sc->sc_mtx);
        *freq = sc->sc_pstate_current = ACPICPU_P_STATE_UNKNOWN;
+       mutex_exit(&sc->sc_mtx);
 
        return rv;
 }
@@ -712,7 +722,10 @@
        }
 
        ps->ps_evcnt.ev_count++;
+
+       mutex_enter(&sc->sc_mtx);
        sc->sc_pstate_current = freq;
+       mutex_exit(&sc->sc_mtx);
 
        return 0;
 
@@ -720,7 +733,9 @@
        aprint_error_dev(sc->sc_dev, "failed to set "
            "frequency to %u (err %d)\n", freq, rv);
 
+       mutex_enter(&sc->sc_mtx);
        sc->sc_pstate_current = ACPICPU_P_STATE_UNKNOWN;
+       mutex_exit(&sc->sc_mtx);
 
        return rv;
 }



Home | Main Index | Thread Index | Old Index