Module Name: src
Committed By: jruoho
Date: Tue Mar 1 05:57:05 UTC 2011
Modified Files:
src/sys/dev/acpi: acpi_cpu.c acpi_cpu_cstate.c acpi_cpu_pstate.c
acpi_cpu_tstate.c
Log Message:
Move also the evcnt(9) event counters to one place. No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/acpi/acpi_cpu.c
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/acpi/acpi_cpu_cstate.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/acpi/acpi_cpu_pstate.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/acpi/acpi_cpu_tstate.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.32 src/sys/dev/acpi/acpi_cpu.c:1.33
--- src/sys/dev/acpi/acpi_cpu.c:1.32 Tue Mar 1 05:32:03 2011
+++ src/sys/dev/acpi/acpi_cpu.c Tue Mar 1 05:57:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.c,v 1.32 2011/03/01 05:32:03 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.c,v 1.33 2011/03/01 05:57:04 jruoho Exp $ */
/*-
* Copyright (c) 2010, 2011 Jukka Ruohonen <[email protected]>
@@ -27,10 +27,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.32 2011/03/01 05:32:03 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.33 2011/03/01 05:57:04 jruoho Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
+#include <sys/evcnt.h>
#include <sys/kernel.h>
#include <sys/kmem.h>
#include <sys/module.h>
@@ -53,9 +54,6 @@
static int acpicpu_once_attach(void);
static int acpicpu_once_detach(void);
static void acpicpu_start(device_t);
-static void acpicpu_debug_print(device_t);
-static const char *acpicpu_debug_print_method(uint8_t);
-static const char *acpicpu_debug_print_dep(uint32_t);
static void acpicpu_sysctl(device_t);
static ACPI_STATUS acpicpu_object(ACPI_HANDLE, struct acpicpu_object *);
@@ -68,6 +66,11 @@
static void acpicpu_notify(ACPI_HANDLE, uint32_t, void *);
static bool acpicpu_suspend(device_t, const pmf_qual_t *);
static bool acpicpu_resume(device_t, const pmf_qual_t *);
+static void acpicpu_evcnt_attach(device_t);
+static void acpicpu_evcnt_detach(device_t);
+static void acpicpu_debug_print(device_t);
+static const char *acpicpu_debug_print_method(uint8_t);
+static const char *acpicpu_debug_print_dep(uint32_t);
static uint32_t acpicpu_count = 0;
struct acpicpu_softc **acpicpu_sc = NULL;
@@ -166,6 +169,7 @@
acpicpu_tstate_attach(self);
acpicpu_debug_print(self);
+ acpicpu_evcnt_attach(self);
(void)config_interrupts(self, acpicpu_start);
(void)acpi_register_notify(sc->sc_node, acpicpu_notify);
@@ -200,6 +204,8 @@
return rv;
mutex_destroy(&sc->sc_mtx);
+ acpicpu_evcnt_detach(self);
+
sc->sc_node->ad_device = NULL;
acpicpu_count--;
@@ -677,6 +683,101 @@
}
static void
+acpicpu_evcnt_attach(device_t self)
+{
+ struct acpicpu_softc *sc = device_private(self);
+ struct acpicpu_cstate *cs;
+ struct acpicpu_pstate *ps;
+ struct acpicpu_tstate *ts;
+ const char *str;
+ uint32_t i;
+
+ for (i = 0; i < __arraycount(sc->sc_cstate); i++) {
+
+ cs = &sc->sc_cstate[i];
+
+ if (cs->cs_method == 0)
+ continue;
+
+ str = "HALT";
+
+ if (cs->cs_method == ACPICPU_C_STATE_FFH)
+ str = "MWAIT";
+
+ if (cs->cs_method == ACPICPU_C_STATE_SYSIO)
+ str = "I/O";
+
+ (void)snprintf(cs->cs_name, sizeof(cs->cs_name),
+ "C%d (%s)", i, str);
+
+ evcnt_attach_dynamic(&cs->cs_evcnt, EVCNT_TYPE_MISC,
+ NULL, device_xname(sc->sc_dev), cs->cs_name);
+ }
+
+ for (i = 0; i < sc->sc_pstate_count; i++) {
+
+ ps = &sc->sc_pstate[i];
+
+ if (ps->ps_freq == 0)
+ continue;
+
+ (void)snprintf(ps->ps_name, sizeof(ps->ps_name),
+ "P%u (%u MHz)", i, ps->ps_freq);
+
+ evcnt_attach_dynamic(&ps->ps_evcnt, EVCNT_TYPE_MISC,
+ NULL, device_xname(sc->sc_dev), ps->ps_name);
+ }
+
+ for (i = 0; i < sc->sc_tstate_count; i++) {
+
+ ts = &sc->sc_tstate[i];
+
+ if (ts->ts_percent == 0)
+ continue;
+
+ (void)snprintf(ts->ts_name, sizeof(ts->ts_name),
+ "T%u (%u %%)", i, ts->ts_percent);
+
+ evcnt_attach_dynamic(&ts->ts_evcnt, EVCNT_TYPE_MISC,
+ NULL, device_xname(sc->sc_dev), ts->ts_name);
+ }
+}
+
+static void
+acpicpu_evcnt_detach(device_t self)
+{
+ struct acpicpu_softc *sc = device_private(self);
+ struct acpicpu_cstate *cs;
+ struct acpicpu_pstate *ps;
+ struct acpicpu_tstate *ts;
+ uint32_t i;
+
+ for (i = 0; i < __arraycount(sc->sc_cstate); i++) {
+
+ cs = &sc->sc_cstate[i];
+
+ if (cs->cs_method != 0)
+ evcnt_detach(&cs->cs_evcnt);
+ }
+
+ for (i = 0; i < sc->sc_pstate_count; i++) {
+
+ ps = &sc->sc_pstate[i];
+
+ if (ps->ps_freq != 0)
+ evcnt_detach(&ps->ps_evcnt);
+ }
+
+ for (i = 0; i < sc->sc_tstate_count; i++) {
+
+ ts = &sc->sc_tstate[i];
+
+ if (ts->ts_percent != 0)
+ evcnt_detach(&ts->ts_evcnt);
+ }
+}
+
+static void
acpicpu_debug_print(device_t self)
{
struct acpicpu_softc *sc = device_private(self);
Index: src/sys/dev/acpi/acpi_cpu_cstate.c
diff -u src/sys/dev/acpi/acpi_cpu_cstate.c:1.48 src/sys/dev/acpi/acpi_cpu_cstate.c:1.49
--- src/sys/dev/acpi/acpi_cpu_cstate.c:1.48 Tue Mar 1 05:37:02 2011
+++ src/sys/dev/acpi/acpi_cpu_cstate.c Tue Mar 1 05:57:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_cstate.c,v 1.48 2011/03/01 05:37:02 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_cstate.c,v 1.49 2011/03/01 05:57:04 jruoho Exp $ */
/*-
* Copyright (c) 2010, 2011 Jukka Ruohonen <[email protected]>
@@ -27,12 +27,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.48 2011/03/01 05:37:02 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.49 2011/03/01 05:57:04 jruoho Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
#include <sys/device.h>
-#include <sys/evcnt.h>
#include <sys/kernel.h>
#include <sys/once.h>
#include <sys/mutex.h>
@@ -48,8 +47,6 @@
#define _COMPONENT ACPI_BUS_COMPONENT
ACPI_MODULE_NAME ("acpi_cpu_cstate")
-static void acpicpu_cstate_attach_evcnt(struct acpicpu_softc *);
-static void acpicpu_cstate_detach_evcnt(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_cstate_cst(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_cstate_cst_add(struct acpicpu_softc *,
ACPI_OBJECT *, int );
@@ -110,37 +107,6 @@
sc->sc_flags |= ACPICPU_FLAG_C;
acpicpu_cstate_quirks(sc);
- acpicpu_cstate_attach_evcnt(sc);
-}
-
-static void
-acpicpu_cstate_attach_evcnt(struct acpicpu_softc *sc)
-{
- struct acpicpu_cstate *cs;
- const char *str;
- uint8_t i;
-
- for (i = 0; i < __arraycount(sc->sc_cstate); i++) {
-
- cs = &sc->sc_cstate[i];
-
- if (cs->cs_method == 0)
- continue;
-
- str = "HALT";
-
- if (cs->cs_method == ACPICPU_C_STATE_FFH)
- str = "MWAIT";
-
- if (cs->cs_method == ACPICPU_C_STATE_SYSIO)
- str = "I/O";
-
- (void)snprintf(cs->cs_name, sizeof(cs->cs_name),
- "C%d (%s)", i, str);
-
- evcnt_attach_dynamic(&cs->cs_evcnt, EVCNT_TYPE_MISC,
- NULL, device_xname(sc->sc_dev), cs->cs_name);
- }
}
int
@@ -156,26 +122,10 @@
return rv;
sc->sc_flags &= ~ACPICPU_FLAG_C;
- acpicpu_cstate_detach_evcnt(sc);
return 0;
}
-static void
-acpicpu_cstate_detach_evcnt(struct acpicpu_softc *sc)
-{
- struct acpicpu_cstate *cs;
- uint8_t i;
-
- for (i = 0; i < __arraycount(sc->sc_cstate); i++) {
-
- cs = &sc->sc_cstate[i];
-
- if (cs->cs_method != 0)
- evcnt_detach(&cs->cs_evcnt);
- }
-}
-
void
acpicpu_cstate_start(device_t self)
{
Index: src/sys/dev/acpi/acpi_cpu_pstate.c
diff -u src/sys/dev/acpi/acpi_cpu_pstate.c:1.43 src/sys/dev/acpi/acpi_cpu_pstate.c:1.44
--- src/sys/dev/acpi/acpi_cpu_pstate.c:1.43 Tue Mar 1 05:32:03 2011
+++ src/sys/dev/acpi/acpi_cpu_pstate.c Tue Mar 1 05:57:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.43 2011/03/01 05:32:03 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.44 2011/03/01 05:57:04 jruoho Exp $ */
/*-
* Copyright (c) 2010, 2011 Jukka Ruohonen <[email protected]>
@@ -27,10 +27,9 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.43 2011/03/01 05:32:03 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.44 2011/03/01 05:57:04 jruoho Exp $");
#include <sys/param.h>
-#include <sys/evcnt.h>
#include <sys/kmem.h>
#include <sys/once.h>
#include <sys/xcall.h>
@@ -42,8 +41,6 @@
#define _COMPONENT ACPI_BUS_COMPONENT
ACPI_MODULE_NAME ("acpi_cpu_pstate")
-static void acpicpu_pstate_attach_evcnt(struct acpicpu_softc *);
-static void acpicpu_pstate_detach_evcnt(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_pstate_pss(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_pstate_pss_add(struct acpicpu_pstate *,
ACPI_OBJECT *);
@@ -139,7 +136,6 @@
acpicpu_pstate_bios();
acpicpu_pstate_reset(sc);
- acpicpu_pstate_attach_evcnt(sc);
return;
@@ -159,27 +155,6 @@
}
}
-static void
-acpicpu_pstate_attach_evcnt(struct acpicpu_softc *sc)
-{
- struct acpicpu_pstate *ps;
- uint32_t i;
-
- for (i = 0; i < sc->sc_pstate_count; i++) {
-
- ps = &sc->sc_pstate[i];
-
- if (ps->ps_freq == 0)
- continue;
-
- (void)snprintf(ps->ps_name, sizeof(ps->ps_name),
- "P%u (%u MHz)", i, ps->ps_freq);
-
- evcnt_attach_dynamic(&ps->ps_evcnt, EVCNT_TYPE_MISC,
- NULL, device_xname(sc->sc_dev), ps->ps_name);
- }
-}
-
int
acpicpu_pstate_detach(device_t self)
{
@@ -202,26 +177,10 @@
kmem_free(sc->sc_pstate, size);
sc->sc_flags &= ~ACPICPU_FLAG_P;
- acpicpu_pstate_detach_evcnt(sc);
return 0;
}
-static void
-acpicpu_pstate_detach_evcnt(struct acpicpu_softc *sc)
-{
- struct acpicpu_pstate *ps;
- uint32_t i;
-
- for (i = 0; i < sc->sc_pstate_count; i++) {
-
- ps = &sc->sc_pstate[i];
-
- if (ps->ps_freq != 0)
- evcnt_detach(&ps->ps_evcnt);
- }
-}
-
void
acpicpu_pstate_start(device_t self)
{
Index: src/sys/dev/acpi/acpi_cpu_tstate.c
diff -u src/sys/dev/acpi/acpi_cpu_tstate.c:1.25 src/sys/dev/acpi/acpi_cpu_tstate.c:1.26
--- src/sys/dev/acpi/acpi_cpu_tstate.c:1.25 Tue Mar 1 05:32:03 2011
+++ src/sys/dev/acpi/acpi_cpu_tstate.c Tue Mar 1 05:57:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_tstate.c,v 1.25 2011/03/01 05:32:03 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_tstate.c,v 1.26 2011/03/01 05:57:04 jruoho Exp $ */
/*-
* Copyright (c) 2010 Jukka Ruohonen <[email protected]>
@@ -27,10 +27,9 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.25 2011/03/01 05:32:03 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.26 2011/03/01 05:57:04 jruoho Exp $");
#include <sys/param.h>
-#include <sys/evcnt.h>
#include <sys/kmem.h>
#include <sys/xcall.h>
@@ -41,8 +40,6 @@
#define _COMPONENT ACPI_BUS_COMPONENT
ACPI_MODULE_NAME ("acpi_cpu_tstate")
-static void acpicpu_tstate_attach_evcnt(struct acpicpu_softc *);
-static void acpicpu_tstate_detach_evcnt(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_tstate_tss(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_tstate_tss_add(struct acpicpu_tstate *,
ACPI_OBJECT *);
@@ -121,28 +118,6 @@
sc->sc_flags |= ACPICPU_FLAG_T;
acpicpu_tstate_reset(sc);
- acpicpu_tstate_attach_evcnt(sc);
-}
-
-static void
-acpicpu_tstate_attach_evcnt(struct acpicpu_softc *sc)
-{
- struct acpicpu_tstate *ts;
- uint32_t i;
-
- for (i = 0; i < sc->sc_tstate_count; i++) {
-
- ts = &sc->sc_tstate[i];
-
- if (ts->ts_percent == 0)
- continue;
-
- (void)snprintf(ts->ts_name, sizeof(ts->ts_name),
- "T%u (%u %%)", i, ts->ts_percent);
-
- evcnt_attach_dynamic(&ts->ts_evcnt, EVCNT_TYPE_MISC,
- NULL, device_xname(sc->sc_dev), ts->ts_name);
- }
}
int
@@ -160,26 +135,10 @@
kmem_free(sc->sc_tstate, size);
sc->sc_flags &= ~ACPICPU_FLAG_T;
- acpicpu_tstate_detach_evcnt(sc);
return 0;
}
-static void
-acpicpu_tstate_detach_evcnt(struct acpicpu_softc *sc)
-{
- struct acpicpu_tstate *ts;
- uint32_t i;
-
- for (i = 0; i < sc->sc_tstate_count; i++) {
-
- ts = &sc->sc_tstate[i];
-
- if (ts->ts_percent != 0)
- evcnt_detach(&ts->ts_evcnt);
- }
-}
-
void
acpicpu_tstate_start(device_t self)
{