Module Name: src Committed By: jruoho Date: Fri Jul 30 06:11:14 UTC 2010
Modified Files: src/sys/dev/acpi: acpi_cpu.c acpi_cpu.h acpi_cpu_cstate.c Log Message: On second thought, rename the mutex so it can be (logically) shared. We will not need such granularity that different states would require a different lock. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/acpi_cpu.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/acpi/acpi_cpu.h cvs rdiff -u -r1.12 -r1.13 src/sys/dev/acpi/acpi_cpu_cstate.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.c diff -u src/sys/dev/acpi/acpi_cpu.c:1.9 src/sys/dev/acpi/acpi_cpu.c:1.10 --- src/sys/dev/acpi/acpi_cpu.c:1.9 Thu Jul 29 22:42:58 2010 +++ src/sys/dev/acpi/acpi_cpu.c Fri Jul 30 06:11:14 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu.c,v 1.9 2010/07/29 22:42:58 jruoho Exp $ */ +/* $NetBSD: acpi_cpu.c,v 1.10 2010/07/30 06:11:14 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen <jruoho...@iki.fi> @@ -27,13 +27,14 @@ * SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.9 2010/07/29 22:42:58 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.10 2010/07/30 06:11:14 jruoho Exp $"); #include <sys/param.h> #include <sys/cpu.h> #include <sys/kernel.h> #include <sys/kmem.h> #include <sys/module.h> +#include <sys/mutex.h> #include <sys/once.h> #include <dev/acpi/acpireg.h> @@ -134,6 +135,8 @@ sc->sc_cap = acpicpu_cap(sc); sc->sc_flags |= acpicpu_md_quirks(); + mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_NONE); + aprint_naive("\n"); aprint_normal(": ACPI CPU"); aprint_verbose(", cap 0x%02x, addr 0x%06x, len 0x%02x", @@ -185,6 +188,8 @@ if (sc->sc_ioh != 0) bus_space_unmap(sc->sc_iot, sc->sc_ioh, addr); + mutex_destroy(&sc->sc_mtx); + return 0; } Index: src/sys/dev/acpi/acpi_cpu.h diff -u src/sys/dev/acpi/acpi_cpu.h:1.7 src/sys/dev/acpi/acpi_cpu.h:1.8 --- src/sys/dev/acpi/acpi_cpu.h:1.7 Thu Jul 29 22:42:58 2010 +++ src/sys/dev/acpi/acpi_cpu.h Fri Jul 30 06:11:14 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu.h,v 1.7 2010/07/29 22:42:58 jruoho Exp $ */ +/* $NetBSD: acpi_cpu.h,v 1.8 2010/07/30 06:11:14 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen <jruoho...@iki.fi> @@ -95,6 +95,20 @@ #define ACPICPU_FLAG_C_MWAIT __BIT(9) /* MONITOR/MWAIT supported */ #define ACPICPU_FLAG_C_C1E __BIT(10) /* AMD C1E detected */ +/* + * This is AML_RESOURCE_GENERIC_REGISTER, + * included here separately for convenience. + */ +struct acpicpu_reg { + uint8_t reg_desc; + uint16_t reg_reslen; + uint8_t reg_spaceid; + uint8_t reg_bitwidth; + uint8_t reg_bitoffset; + uint8_t reg_accesssize; + uint64_t reg_addr; +} __packed; + struct acpicpu_cstate { uint64_t cs_stat; uint64_t cs_addr; @@ -121,31 +135,20 @@ device_t sc_dev; struct acpi_devnode *sc_node; struct acpicpu_object sc_object; + struct acpicpu_cstate sc_cstate[ACPI_C_STATE_COUNT]; - kmutex_t sc_cstate_mtx; + uint32_t sc_cstate_sleep; + + kmutex_t sc_mtx; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; - uint32_t sc_sleep; - uint32_t sc_cpuid; + uint32_t sc_cap; uint32_t sc_flags; + cpuid_t sc_cpuid; bool sc_cold; }; -/* - * This is AML_RESOURCE_GENERIC_REGISTER, - * included here separately for convenience. - */ -struct acpicpu_reg { - uint8_t reg_desc; - uint16_t reg_reslen; - uint8_t reg_spaceid; - uint8_t reg_bitwidth; - uint8_t reg_bitoffset; - uint8_t reg_accesssize; - uint64_t reg_addr; -} __packed; - void acpicpu_cstate_attach(device_t); int acpicpu_cstate_detach(device_t); int acpicpu_cstate_start(device_t); Index: src/sys/dev/acpi/acpi_cpu_cstate.c diff -u src/sys/dev/acpi/acpi_cpu_cstate.c:1.12 src/sys/dev/acpi/acpi_cpu_cstate.c:1.13 --- src/sys/dev/acpi/acpi_cpu_cstate.c:1.12 Thu Jul 29 22:42:58 2010 +++ src/sys/dev/acpi/acpi_cpu_cstate.c Fri Jul 30 06:11:14 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_cstate.c,v 1.12 2010/07/29 22:42:58 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_cstate.c,v 1.13 2010/07/30 06:11:14 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen <jruoho...@iki.fi> @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.12 2010/07/29 22:42:58 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.13 2010/07/30 06:11:14 jruoho Exp $"); #include <sys/param.h> #include <sys/cpu.h> @@ -101,8 +101,6 @@ acpicpu_cstate_quirks(sc); acpicpu_cstate_attach_print(sc); - - mutex_init(&sc->sc_cstate_mtx, MUTEX_DEFAULT, IPL_NONE); } void @@ -187,7 +185,6 @@ return rv; sc->sc_flags &= ~ACPICPU_FLAG_C; - mutex_destroy(&sc->sc_cstate_mtx); return 0; } @@ -253,9 +250,9 @@ return; } - mutex_enter(&sc->sc_cstate_mtx); + mutex_enter(&sc->sc_mtx); (void)acpicpu_cstate_cst(sc); - mutex_exit(&sc->sc_cstate_mtx); + mutex_exit(&sc->sc_mtx); } static ACPI_STATUS @@ -697,7 +694,7 @@ * longer than the worst case latency of the * state times an arbitrary multiplier. */ - if (sc->sc_sleep > cs->cs_latency * cs_factor) + if (sc->sc_cstate_sleep > cs->cs_latency * cs_factor) return i; } @@ -734,10 +731,10 @@ if (__predict_false((sc->sc_flags & ACPICPU_FLAG_C) == 0)) goto halt; - if (__predict_false(mutex_tryenter(&sc->sc_cstate_mtx) == 0)) + if (__predict_false(mutex_tryenter(&sc->sc_mtx) == 0)) goto halt; - mutex_exit(&sc->sc_cstate_mtx); + mutex_exit(&sc->sc_mtx); state = acpicpu_cstate_latency(sc); /* @@ -828,7 +825,7 @@ cs->cs_stat++; end = acpitimer_read_safe(NULL); - sc->sc_sleep = hztoms(acpitimer_delta(end, start)) * 1000; + sc->sc_cstate_sleep = hztoms(acpitimer_delta(end, start)) * 1000; acpi_md_OsEnableInterrupt(); }