From owner-svn-src-all@FreeBSD.ORG Mon Jul 2 17:55:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 87A58106566C; Mon, 2 Jul 2012 17:55:30 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 742AE8FC17; Mon, 2 Jul 2012 17:55:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q62HtUTw085419; Mon, 2 Jul 2012 17:55:30 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q62HtUfh085416; Mon, 2 Jul 2012 17:55:30 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201207021755.q62HtUfh085416@svn.freebsd.org> From: Sean Bruno Date: Mon, 2 Jul 2012 17:55:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238009 - in head: etc/rc.d sys/dev/acpica X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jul 2012 17:55:30 -0000 Author: sbruno Date: Mon Jul 2 17:55:29 2012 New Revision: 238009 URL: http://svn.freebsd.org/changeset/base/238009 Log: Revert r238004 as more review has come in and there is now a discussion on how to best proceed. Modified: head/etc/rc.d/power_profile head/sys/dev/acpica/acpi_cpu.c Modified: head/etc/rc.d/power_profile ============================================================================== --- head/etc/rc.d/power_profile Mon Jul 2 17:52:43 2012 (r238008) +++ head/etc/rc.d/power_profile Mon Jul 2 17:55:29 2012 (r238009) @@ -90,7 +90,7 @@ node="dev.cpu.0.freq" highest_value="`(sysctl -n dev.cpu.0.freq_levels | \ awk '{ split($0, a, "[/ ]"); print a[1] }' -) 2> /dev/null`" lowest_value="`(sysctl -n dev.cpu.0.freq_levels | \ - awk '{ split($0, a, "[ /]"); print a[length(a) - 1] }' -) 2> /dev/null`" + awk '{ split($0, a, "[/ ]"); print a[length(a) - 1] }' -) 2> /dev/null`" eval value=\$${profile}_cpu_freq sysctl_set Modified: head/sys/dev/acpica/acpi_cpu.c ============================================================================== --- head/sys/dev/acpica/acpi_cpu.c Mon Jul 2 17:52:43 2012 (r238008) +++ head/sys/dev/acpica/acpi_cpu.c Mon Jul 2 17:55:29 2012 (r238009) @@ -88,7 +88,7 @@ struct acpi_cpu_softc { /* Values for sysctl. */ struct sysctl_ctx_list cpu_sysctl_ctx; struct sysctl_oid *cpu_sysctl_tree; - int cpu_cx_lowest; /* Index of lowest Cx state in cpu_cx_states[] */ + int cpu_cx_lowest; char cpu_cx_supported[64]; int cpu_rid; }; @@ -144,8 +144,7 @@ static int cpu_cx_count; /* Number of static struct sysctl_ctx_list cpu_sysctl_ctx; static struct sysctl_oid *cpu_sysctl_tree; static int cpu_cx_generic; -/* Lowest valid Cstate for all cpus -- Cx */ -static int global_lowest_cstate; +static int cpu_cx_lowest; static device_t *cpu_devices; static int cpu_ndevices; @@ -872,7 +871,7 @@ acpi_cpu_startup(void *arg) "Global lowest Cx sleep state to use"); /* Take over idling from cpu_idle_default(). */ - global_lowest_cstate = 0; + cpu_cx_lowest = 0; cpu_disable_idle = FALSE; cpu_idle_hook = acpi_cpu_idle; } @@ -890,8 +889,7 @@ acpi_cpu_cx_list(struct acpi_cpu_softc * sbuf_new(&sb, sc->cpu_cx_supported, sizeof(sc->cpu_cx_supported), SBUF_FIXEDLEN); for (i = 0; i < sc->cpu_cx_count; i++) { - sbuf_printf(&sb, "C%d/%d ", sc->cpu_cx_states[i].type, - sc->cpu_cx_states[i].trans_lat); + sbuf_printf(&sb, "C%d/%d ", i + 1, sc->cpu_cx_states[i].trans_lat); if (sc->cpu_cx_states[i].type < ACPI_STATE_C3) sc->cpu_non_c3 = i; else @@ -965,10 +963,9 @@ acpi_cpu_idle() /* Find the lowest state that has small enough latency. */ cx_next_idx = 0; - if (cpu_disable_deep_sleep) { - /* Chose the lowest valid index in the cpu_cx_states array */ + if (cpu_disable_deep_sleep) i = min(sc->cpu_cx_lowest, sc->cpu_non_c3); - } else + else i = sc->cpu_cx_lowest; for (; i >= 0; i--) { if (sc->cpu_cx_states[i].trans_lat * 3 <= sc->cpu_prev_sleep) { @@ -1083,8 +1080,8 @@ acpi_cpu_notify(ACPI_HANDLE h, UINT32 no if (isc->cpu_cx_count > cpu_cx_count) cpu_cx_count = isc->cpu_cx_count; } - if (sc->cpu_cx_lowest < global_lowest_cstate) - acpi_cpu_set_cx_lowest(sc, sc->cpu_cx_states[sc->cpu_cx_lowest].type); + if (sc->cpu_cx_lowest < cpu_cx_lowest) + acpi_cpu_set_cx_lowest(sc, min(cpu_cx_lowest, sc->cpu_cx_count - 1)); ACPI_SERIAL_END(cpu); } @@ -1211,31 +1208,13 @@ acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARG return (0); } -/* - * val is the ACPI_STATE_CX enum request by the caller - */ static int acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc, int val) { int i; ACPI_SERIAL_ASSERT(cpu); - /* - * scan list of valid cstates. if we do no - * find a match to the requested val, return - * EINVAL - * once we match, set cpu_cx_lowest to the found - * index i - */ - for (i = 0; i < sc->cpu_cx_count; i++) { - if (sc->cpu_cx_states[i].type == val) { - sc->cpu_cx_lowest = i; - break; - } - } - if (i == sc->cpu_cx_count) - return (EINVAL); - + sc->cpu_cx_lowest = val; /* If not disabling, cache the new lowest non-C3 state. */ sc->cpu_non_c3 = 0; @@ -1259,22 +1238,21 @@ acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER int val, error; sc = (struct acpi_cpu_softc *) arg1; - snprintf(state, sizeof(state), "C%d", - sc->cpu_cx_states[sc->cpu_cx_lowest].type); + snprintf(state, sizeof(state), "C%d", sc->cpu_cx_lowest + 1); error = sysctl_handle_string(oidp, state, sizeof(state), req); if (error != 0 || req->newptr == NULL) return (error); if (strlen(state) < 2 || toupper(state[0]) != 'C') return (EINVAL); - val = (int) strtol(state + 1, NULL, 10); - if (val < 0 || val > MAX_CX_STATES) + val = (int) strtol(state + 1, NULL, 10) - 1; + if (val < 0 || val > sc->cpu_cx_count - 1) return (EINVAL); ACPI_SERIAL_BEGIN(cpu); - error = acpi_cpu_set_cx_lowest(sc, val); + acpi_cpu_set_cx_lowest(sc, val); ACPI_SERIAL_END(cpu); - return (error); + return (0); } static int @@ -1284,28 +1262,24 @@ acpi_cpu_global_cx_lowest_sysctl(SYSCTL_ char state[8]; int val, error, i; - snprintf(state, sizeof(state), "C%d", global_lowest_cstate); + snprintf(state, sizeof(state), "C%d", cpu_cx_lowest + 1); error = sysctl_handle_string(oidp, state, sizeof(state), req); if (error != 0 || req->newptr == NULL) return (error); if (strlen(state) < 2 || toupper(state[0]) != 'C') return (EINVAL); - val = (int) strtol(state + 1, NULL, 10); - if (val < 0 || val > MAX_CX_STATES) + 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. */ ACPI_SERIAL_BEGIN(cpu); for (i = 0; i < cpu_ndevices; i++) { sc = device_get_softc(cpu_devices[i]); - error = acpi_cpu_set_cx_lowest(sc, val); - if (error) { - ACPI_SERIAL_END(cpu); - return(error); - } + acpi_cpu_set_cx_lowest(sc, min(val, sc->cpu_cx_count - 1)); } ACPI_SERIAL_END(cpu); - global_lowest_cstate = val; return (0); }