summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2007-06-02 20:01:40 +0000
committernjl <njl@FreeBSD.org>2007-06-02 20:01:40 +0000
commit3bced3f67c0085a561bf577a400ebf240f53c99f (patch)
tree02cab2038da690252fa53c68a5dde15bc0a52ba5
parent9d0fbd0af19e3574d08f785d167045a8e33ed485 (diff)
downloadFreeBSD-src-3bced3f67c0085a561bf577a400ebf240f53c99f.zip
FreeBSD-src-3bced3f67c0085a561bf577a400ebf240f53c99f.tar.gz
Fix a bug introduced in the per-CPU Cx states commit. The wrong loop var
(j/i) was being used and it was being incremented, not decremented as before. Factor out this code into a common function and call it from both the common and per-CPU case. MFC after: 1 day
-rw-r--r--sys/dev/acpica/acpi_cpu.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 95f71df..a3a4a98 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -1045,11 +1045,33 @@ acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS)
}
static int
+acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc, int val)
+{
+ int i;
+
+ ACPI_SERIAL_ASSERT(cpu);
+ sc->cpu_cx_lowest = val;
+
+ /* If not disabling, cache the new lowest non-C3 state. */
+ sc->cpu_non_c3 = 0;
+ for (i = sc->cpu_cx_lowest; i >= 0; i--) {
+ if (sc->cpu_cx_states[i].type < ACPI_STATE_C3) {
+ sc->cpu_non_c3 = i;
+ break;
+ }
+ }
+
+ /* Reset the statistics counters. */
+ bzero(sc->cpu_cx_stats, sizeof(sc->cpu_cx_stats));
+ return (0);
+}
+
+static int
acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS)
{
struct acpi_cpu_softc *sc;
char state[8];
- int val, error, i;
+ int val, error;
sc = (struct acpi_cpu_softc *) arg1;
snprintf(state, sizeof(state), "C%d", sc->cpu_cx_lowest + 1);
@@ -1063,19 +1085,7 @@ acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS)
return (EINVAL);
ACPI_SERIAL_BEGIN(cpu);
- sc->cpu_cx_lowest = val;
-
- /* If not disabling, cache the new lowest non-C3 state. */
- sc->cpu_non_c3 = 0;
- for (i = sc->cpu_cx_lowest; i >= 0; i--) {
- if (sc->cpu_cx_states[i].type < ACPI_STATE_C3) {
- sc->cpu_non_c3 = i;
- break;
- }
- }
-
- /* Reset the statistics counters. */
- bzero(sc->cpu_cx_stats, sizeof(sc->cpu_cx_stats));
+ acpi_cpu_set_cx_lowest(sc, val);
ACPI_SERIAL_END(cpu);
return (0);
@@ -1086,7 +1096,7 @@ acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS)
{
struct acpi_cpu_softc *sc;
char state[8];
- int val, error, i, j;
+ int val, error, i;
snprintf(state, sizeof(state), "C%d", cpu_cx_lowest + 1);
error = sysctl_handle_string(oidp, state, sizeof(state), req);
@@ -1097,26 +1107,13 @@ acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS)
val = (int) strtol(state + 1, NULL, 10) - 1;
if (val < 0 || val > cpu_cx_count - 1)
return (EINVAL);
-
cpu_cx_lowest = val;
- /*
- * Update the new lowest useable Cx state for all CPUs
- */
+ /* Update the new lowest useable Cx state for all CPUs. */
ACPI_SERIAL_BEGIN(cpu);
for (i = 0; i < cpu_ndevices; i++) {
sc = device_get_softc(cpu_devices[i]);
- sc->cpu_cx_lowest = cpu_cx_lowest;
- sc->cpu_non_c3 = 0;
- for (j = sc->cpu_cx_lowest; j >= 0; j++) {
- if (sc->cpu_cx_states[i].type < ACPI_STATE_C3) {
- sc->cpu_non_c3 = i;
- break;
- }
- }
-
- /* Reset the statistics counters. */
- bzero(sc->cpu_cx_stats, sizeof(sc->cpu_cx_stats));
+ acpi_cpu_set_cx_lowest(sc, val);
}
ACPI_SERIAL_END(cpu);
OpenPOWER on IntegriCloud