Module Name:    src
Committed By:   jruoho
Date:           Fri Apr  1 11:46:57 UTC 2011

Modified Files:
        src/sys/dev/acpi: acpi_cpu_pstate.c

Log Message:
Maintain the state properly during firmware-based DVFS.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 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_pstate.c
diff -u src/sys/dev/acpi/acpi_cpu_pstate.c:1.47 src/sys/dev/acpi/acpi_cpu_pstate.c:1.48
--- src/sys/dev/acpi/acpi_cpu_pstate.c:1.47	Sat Mar 19 12:57:31 2011
+++ src/sys/dev/acpi/acpi_cpu_pstate.c	Fri Apr  1 11:46:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.47 2011/03/19 12:57:31 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.48 2011/04/01 11:46:57 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <[email protected]>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.47 2011/03/19 12:57:31 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.48 2011/04/01 11:46:57 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -247,13 +247,17 @@
 		}
 	}
 
-	mutex_exit(&sc->sc_mtx);
-
-	if (__predict_false(ps == NULL))
+	if (__predict_false(ps == NULL)) {
+		mutex_exit(&sc->sc_mtx);
 		return;
+	}
 
-	if (sc->sc_pstate_saved == ps->ps_freq)
+	if (sc->sc_pstate_saved == ps->ps_freq) {
+		mutex_exit(&sc->sc_mtx);
 		return;
+	}
+
+	mutex_exit(&sc->sc_mtx);
 
 	xc = xc_unicast(0, acpicpu_pstate_set_xcall, &ps->ps_freq, NULL, ci);
 	xc_wait(xc);
@@ -279,29 +283,28 @@
 {
 	struct acpicpu_softc *sc;
 	device_t self = aux;
-	uint32_t old, new;
+	uint32_t freq;
+	uint64_t xc;
 
 	sc = device_private(self);
 
 	mutex_enter(&sc->sc_mtx);
-
-	old = sc->sc_pstate_max;
 	acpicpu_pstate_change(sc);
-	new = sc->sc_pstate_max;
 
-	if (old == new) {
-		mutex_exit(&sc->sc_mtx);
-		return;
+	freq = sc->sc_pstate[sc->sc_pstate_max].ps_freq;
+
+	if (sc->sc_pstate_saved == 0)
+		sc->sc_pstate_saved = sc->sc_pstate_current;
+
+	if (sc->sc_pstate_saved <= freq) {
+		freq = sc->sc_pstate_saved;
+		sc->sc_pstate_saved = 0;
 	}
 
 	mutex_exit(&sc->sc_mtx);
 
-	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "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));
-
-	acpicpu_pstate_set(sc->sc_ci, sc->sc_pstate[new].ps_freq);
+	xc = xc_unicast(0, acpicpu_pstate_set_xcall, &freq, NULL, sc->sc_ci);
+	xc_wait(xc);
 }
 
 ACPI_STATUS

Reply via email to