Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Improve comments. Move the #ifdef around.



details:   https://anonhg.NetBSD.org/src/rev/da36f03b430c
branches:  trunk
changeset: 756590:da36f03b430c
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sun Jul 25 17:44:01 2010 +0000

description:
Improve comments. Move the #ifdef around.

diffstat:

 sys/dev/acpi/acpi_cpu.c        |   9 ++----
 sys/dev/acpi/acpi_cpu_cstate.c |  58 +++++++++++++++++------------------------
 2 files changed, 27 insertions(+), 40 deletions(-)

diffs (168 lines):

diff -r 31eb7ae60e6c -r da36f03b430c sys/dev/acpi/acpi_cpu.c
--- a/sys/dev/acpi/acpi_cpu.c   Sun Jul 25 16:23:51 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.c   Sun Jul 25 17:44:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.c,v 1.6 2010/07/24 22:44:00 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.c,v 1.7 2010/07/25 17:44:01 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.c,v 1.6 2010/07/24 22:44:00 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.7 2010/07/25 17:44:01 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -141,10 +141,7 @@
 
        /*
         * We should claim the bus space. However, we do this only
-        * to announce that the space is in use. This is unnecessary
-        * if system I/O type C-states are not used. Many systems also
-        * report invalid values in the processor object. Finally, this
-        * is known to conflict with other devices. But as is noted in
+        * to announce that the space is in use. As is noted in
         * ichlpcib(4), we can continue our I/O without bus_space(9).
         */
        if (sc->sc_object.ao_pblklen == 6 && sc->sc_object.ao_pblkaddr != 0) {
diff -r 31eb7ae60e6c -r da36f03b430c sys/dev/acpi/acpi_cpu_cstate.c
--- a/sys/dev/acpi/acpi_cpu_cstate.c    Sun Jul 25 16:23:51 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_cstate.c    Sun Jul 25 17:44:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_cstate.c,v 1.9 2010/07/24 22:44:00 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_cstate.c,v 1.10 2010/07/25 17:44:01 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.9 2010/07/24 22:44:00 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.10 2010/07/25 17:44:01 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -79,6 +79,16 @@
 extern struct acpicpu_softc **acpicpu_sc;
 extern int                   acpi_suspended;
 
+/*
+ * XXX:        The local APIC timer (as well as TSC) is typically
+ *     stopped in C3. For now, we cannot but disable C3.
+ */
+#ifdef ACPICPU_ENABLE_C3
+static int cs_state_max = ACPI_STATE_C3;
+#else
+static int cs_state_max = ACPI_STATE_C2;
+#endif
+
 void
 acpicpu_cstate_attach(device_t self)
 {
@@ -399,13 +409,6 @@
                goto out;
        }
 
-       /*
-        * "When specifically directed by the CPU manufacturer, the
-        *  system firmware may define an interface as functional
-        *  fixed hardware by supplying a special address space
-        *  identifier, FfixedHW (0x7F), in the address space ID
-        *  field for register definitions (ACPI 3.0, p. 46)".
-        */
        reg = (struct acpicpu_reg *)obj->Buffer.Pointer;
 
        switch (reg->reg_spaceid) {
@@ -463,6 +466,8 @@
                        /*
                         * The _CST FFH GAS encoding may contain
                         * additional hints on Intel processors.
+                        * Use these to determine whether we can
+                        * avoid the bus master activity check.
                         */
                        if ((reg->reg_accesssize & ACPICPU_PDC_GAS_BM) == 0)
                                state.cs_flags &= ~ACPICPU_FLAG_C_BM_STS;
@@ -480,19 +485,6 @@
                goto out;
        }
 
-#ifndef ACPICPU_ENABLE_C3
-       /*
-        * XXX: The local APIC timer (as well as TSC) is typically
-        *      stopped in C3, causing the timer interrupt to fire
-        *      haphazardly, depending on how long the system slept.
-        *      For now, we disable the C3 state unconditionally.
-        */
-       if (type == ACPI_STATE_C3) {
-               sc->sc_flags |= ACPICPU_FLAG_C_NOC3;
-               goto out;
-       }
-#endif
-
        cs[type].cs_addr = state.cs_addr;
        cs[type].cs_power = state.cs_power;
        cs[type].cs_flags = state.cs_flags;
@@ -623,11 +615,6 @@
 
        if (AcpiGbl_FADT.C3Latency > ACPICPU_C_C3_LATENCY_MAX)
                cs[ACPI_STATE_C3].cs_method = 0;
-
-#ifndef ACPICPU_ENABLE_C3
-       cs[ACPI_STATE_C3].cs_method = 0;
-       sc->sc_flags |= ACPICPU_FLAG_C_NOC3;    /* XXX. */
-#endif
 }
 
 static void
@@ -638,7 +625,9 @@
        struct pci_attach_args pa;
 
        /*
-        * Check bus master arbitration.
+        * Check bus master arbitration. If ARB_DIS
+        * is not available, processor caches must be
+        * flushed before C3 (ACPI 4.0, section 8.2).
         */
        if (reg != 0 && len != 0)
                sc->sc_flags |= ACPICPU_FLAG_C_ARB;
@@ -650,12 +639,13 @@
                        sc->sc_flags |= ACPICPU_FLAG_C_NOC3;
                else {
                        /*
-                        * If WBINVD is present, but not functioning
-                        * properly according to FADT, flush all CPU
-                        * caches before entering the C3 state.
+                        * If WBINVD is present and functioning properly,
+                        * flush all processor caches before entering C3.
                         */
                        if ((AcpiGbl_FADT.Flags & ACPI_FADT_WBINVD_FLUSH) == 0)
                                sc->sc_flags &= ~ACPICPU_FLAG_C_BM;
+                       else
+                               sc->sc_flags |= ACPICPU_FLAG_C_NOC3;
                }
        }
 
@@ -690,7 +680,7 @@
        struct acpicpu_cstate *cs;
        int i;
 
-       for (i = ACPI_STATE_C3; i > 0; i--) {
+       for (i = cs_state_max; i > 0; i--) {
 
                cs = &sc->sc_cstate[i];
 
@@ -773,8 +763,8 @@
                ACPI_FLUSH_CPU_CACHE();
 
        /*
-        * Some chipsets may not return back to C0
-        * from C3 if bus master wake is not enabled.
+        * Allow the bus master to request that any given
+        * CPU should return immediately to C0 from C3.
         */
        if ((sc->sc_flags & ACPICPU_FLAG_C_BM) != 0)
                (void)AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);



Home | Main Index | Thread Index | Old Index