acpi_cpu.c (243761) | acpi_cpu.c (247454) |
---|---|
1/*- 2 * Copyright (c) 2003-2005 Nate Lawson (SDG) 3 * Copyright (c) 2001 Michael Smith 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003-2005 Nate Lawson (SDG) 3 * Copyright (c) 2001 Michael Smith 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_cpu.c 243761 2012-12-01 18:06:05Z avg $"); | 29__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_cpu.c 247454 2013-02-28 10:46:54Z davide $"); |
30 31#include "opt_acpi.h" 32#include <sys/param.h> 33#include <sys/bus.h> 34#include <sys/cpu.h> 35#include <sys/kernel.h> 36#include <sys/malloc.h> 37#include <sys/module.h> --- 125 unchanged lines hidden (view full) --- 163 uintptr_t *result); 164static int acpi_cpu_shutdown(device_t dev); 165static void acpi_cpu_cx_probe(struct acpi_cpu_softc *sc); 166static void acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc); 167static int acpi_cpu_cx_cst(struct acpi_cpu_softc *sc); 168static void acpi_cpu_startup(void *arg); 169static void acpi_cpu_startup_cx(struct acpi_cpu_softc *sc); 170static void acpi_cpu_cx_list(struct acpi_cpu_softc *sc); | 30 31#include "opt_acpi.h" 32#include <sys/param.h> 33#include <sys/bus.h> 34#include <sys/cpu.h> 35#include <sys/kernel.h> 36#include <sys/malloc.h> 37#include <sys/module.h> --- 125 unchanged lines hidden (view full) --- 163 uintptr_t *result); 164static int acpi_cpu_shutdown(device_t dev); 165static void acpi_cpu_cx_probe(struct acpi_cpu_softc *sc); 166static void acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc); 167static int acpi_cpu_cx_cst(struct acpi_cpu_softc *sc); 168static void acpi_cpu_startup(void *arg); 169static void acpi_cpu_startup_cx(struct acpi_cpu_softc *sc); 170static void acpi_cpu_cx_list(struct acpi_cpu_softc *sc); |
171static void acpi_cpu_idle(void); | 171static void acpi_cpu_idle(sbintime_t sbt); |
172static void acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context); 173static int acpi_cpu_quirks(void); 174static int acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS); 175static int acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc); 176static int acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS); 177static int acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS); 178 179static device_method_t acpi_cpu_methods[] = { --- 769 unchanged lines hidden (view full) --- 949 950/* 951 * Idle the CPU in the lowest state possible. This function is called with 952 * interrupts disabled. Note that once it re-enables interrupts, a task 953 * switch can occur so do not access shared data (i.e. the softc) after 954 * interrupts are re-enabled. 955 */ 956static void | 172static void acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context); 173static int acpi_cpu_quirks(void); 174static int acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS); 175static int acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc); 176static int acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS); 177static int acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS); 178 179static device_method_t acpi_cpu_methods[] = { --- 769 unchanged lines hidden (view full) --- 949 950/* 951 * Idle the CPU in the lowest state possible. This function is called with 952 * interrupts disabled. Note that once it re-enables interrupts, a task 953 * switch can occur so do not access shared data (i.e. the softc) after 954 * interrupts are re-enabled. 955 */ 956static void |
957acpi_cpu_idle() | 957acpi_cpu_idle(sbintime_t sbt) |
958{ 959 struct acpi_cpu_softc *sc; 960 struct acpi_cx *cx_next; 961 uint64_t cputicks; 962 uint32_t start_time, end_time; | 958{ 959 struct acpi_cpu_softc *sc; 960 struct acpi_cx *cx_next; 961 uint64_t cputicks; 962 uint32_t start_time, end_time; |
963 int bm_active, cx_next_idx, i; | 963 int bm_active, cx_next_idx, i, us; |
964 965 /* 966 * Look up our CPU id to get our softc. If it's NULL, we'll use C1 967 * since there is no ACPI processor object for this CPU. This occurs 968 * for logical CPUs in the HTT case. 969 */ 970 sc = cpu_softc[PCPU_GET(cpuid)]; 971 if (sc == NULL) { 972 acpi_cpu_c1(); 973 return; 974 } 975 976 /* If disabled, take the safe path. */ 977 if (is_idle_disabled(sc)) { 978 acpi_cpu_c1(); 979 return; 980 } 981 982 /* Find the lowest state that has small enough latency. */ | 964 965 /* 966 * Look up our CPU id to get our softc. If it's NULL, we'll use C1 967 * since there is no ACPI processor object for this CPU. This occurs 968 * for logical CPUs in the HTT case. 969 */ 970 sc = cpu_softc[PCPU_GET(cpuid)]; 971 if (sc == NULL) { 972 acpi_cpu_c1(); 973 return; 974 } 975 976 /* If disabled, take the safe path. */ 977 if (is_idle_disabled(sc)) { 978 acpi_cpu_c1(); 979 return; 980 } 981 982 /* Find the lowest state that has small enough latency. */ |
983 us = sc->cpu_prev_sleep; 984 if (sbt >= 0 && us > sbt / SBT_1US) 985 us = sbt / SBT_1US; |
|
983 cx_next_idx = 0; 984 if (cpu_disable_deep_sleep) 985 i = min(sc->cpu_cx_lowest, sc->cpu_non_c3); 986 else 987 i = sc->cpu_cx_lowest; 988 for (; i >= 0; i--) { | 986 cx_next_idx = 0; 987 if (cpu_disable_deep_sleep) 988 i = min(sc->cpu_cx_lowest, sc->cpu_non_c3); 989 else 990 i = sc->cpu_cx_lowest; 991 for (; i >= 0; i--) { |
989 if (sc->cpu_cx_states[i].trans_lat * 3 <= sc->cpu_prev_sleep) { | 992 if (sc->cpu_cx_states[i].trans_lat * 3 <= us) { |
990 cx_next_idx = i; 991 break; 992 } 993 } 994 995 /* 996 * Check for bus master activity. If there was activity, clear 997 * the bit and use the lowest non-C3 state. Note that the USB --- 324 unchanged lines hidden --- | 993 cx_next_idx = i; 994 break; 995 } 996 } 997 998 /* 999 * Check for bus master activity. If there was activity, clear 1000 * the bit and use the lowest non-C3 state. Note that the USB --- 324 unchanged lines hidden --- |