Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi On second thought, rename the mutex so it can b...



details:   https://anonhg.NetBSD.org/src/rev/d420248b0082
branches:  trunk
changeset: 756723:d420248b0082
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Fri Jul 30 06:11:14 2010 +0000

description:
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.

diffstat:

 sys/dev/acpi/acpi_cpu.c        |   9 +++++++--
 sys/dev/acpi/acpi_cpu.h        |  39 +++++++++++++++++++++------------------
 sys/dev/acpi/acpi_cpu_cstate.c |  19 ++++++++-----------
 3 files changed, 36 insertions(+), 31 deletions(-)

diffs (189 lines):

diff -r b021fbaa8e7e -r d420248b0082 sys/dev/acpi/acpi_cpu.c
--- a/sys/dev/acpi/acpi_cpu.c   Thu Jul 29 22:48:11 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.c   Fri Jul 30 06:11:14 2010 +0000
@@ -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 <jruohonen%iki.fi@localhost>
@@ -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;
 }
 
diff -r b021fbaa8e7e -r d420248b0082 sys/dev/acpi/acpi_cpu.h
--- a/sys/dev/acpi/acpi_cpu.h   Thu Jul 29 22:48:11 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.h   Fri Jul 30 06:11:14 2010 +0000
@@ -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 <jruohonen%iki.fi@localhost>
@@ -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);
diff -r b021fbaa8e7e -r d420248b0082 sys/dev/acpi/acpi_cpu_cstate.c
--- a/sys/dev/acpi/acpi_cpu_cstate.c    Thu Jul 29 22:48:11 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_cstate.c    Fri Jul 30 06:11:14 2010 +0000
@@ -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 <jruohonen%iki.fi@localhost>
@@ -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();
 }



Home | Main Index | Thread Index | Old Index