Source-Changes-HG archive

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

[src/trunk]: src/sys Move the PIIX4-quirk to the MD file and disable T-states...



details:   https://anonhg.NetBSD.org/src/rev/d6517691f645
branches:  trunk
changeset: 757078:d6517691f645
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sat Aug 14 05:13:20 2010 +0000

description:
Move the PIIX4-quirk to the MD file and disable T-states for PIIX4.

diffstat:

 sys/arch/x86/acpi/acpi_cpu_md.c |  38 +++++++++++++++++++--
 sys/dev/acpi/acpi_cpu.h         |  15 ++++---
 sys/dev/acpi/acpi_cpu_cstate.c  |  72 +++++++++++++---------------------------
 sys/dev/acpi/acpi_cpu_tstate.c  |  10 ++++-
 4 files changed, 74 insertions(+), 61 deletions(-)

diffs (272 lines):

diff -r ce977be3c64d -r d6517691f645 sys/arch/x86/acpi/acpi_cpu_md.c
--- a/sys/arch/x86/acpi/acpi_cpu_md.c   Fri Aug 13 19:56:34 2010 +0000
+++ b/sys/arch/x86/acpi/acpi_cpu_md.c   Sat Aug 14 05:13:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_md.c,v 1.11 2010/08/13 18:44:24 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_md.c,v 1.12 2010/08/14 05:13:20 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_md.c,v 1.11 2010/08/13 18:44:24 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.12 2010/08/14 05:13:20 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -45,10 +45,14 @@
 #include <dev/acpi/acpica.h>
 #include <dev/acpi/acpi_cpu.h>
 
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcidevs.h>
+
 static char      native_idle_text[16];
 void           (*native_idle)(void) = NULL;
 void           (*native_cpu_freq_init)(int) = NULL;
 
+static int      acpicpu_md_quirks_piix4(struct pci_attach_args *);
 static int      acpicpu_md_pstate_sysctl_get(SYSCTLFN_PROTO);
 static int      acpicpu_md_pstate_sysctl_set(SYSCTLFN_PROTO);
 static int      acpicpu_md_pstate_sysctl_all(SYSCTLFN_PROTO);
@@ -94,6 +98,7 @@
 acpicpu_md_quirks(void)
 {
        struct cpu_info *ci = curcpu();
+       struct pci_attach_args pa;
        uint32_t val = 0;
 
        if (acpicpu_md_cpus_running() == 1)
@@ -106,14 +111,14 @@
 
        case CPUVENDOR_INTEL:
 
-               val |= ACPICPU_FLAG_C_BM | ACPICPU_FLAG_C_ARB;
-
                if ((ci->ci_feat_val[1] & CPUID2_EST) != 0)
                        val |= ACPICPU_FLAG_P_FFH;
 
                if ((ci->ci_feat_val[0] & CPUID_ACPI) != 0)
                        val |= ACPICPU_FLAG_T_FFH;
 
+               val |= ACPICPU_FLAG_C_BM | ACPICPU_FLAG_C_ARB;
+
                /*
                 * Bus master arbitration is not
                 * needed on some recent Intel CPUs.
@@ -135,9 +140,34 @@
                break;
        }
 
+       /*
+        * There are several erratums for PIIX4.
+        */
+       if (pci_find_device(&pa, acpicpu_md_quirks_piix4) != 0)
+               val |= ACPICPU_FLAG_PIIX4;
+
        return val;
 }
 
+static int
+acpicpu_md_quirks_piix4(struct pci_attach_args *pa)
+{
+
+       /*
+        * XXX: The pci_find_device(9) function only
+        *      deals with attached devices. Change this
+        *      to use something like pci_device_foreach().
+        */
+       if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL)
+               return 0;
+
+       if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82371AB_ISA ||
+           PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82440MX_PMC)
+               return 1;
+
+       return 0;
+}
+
 uint32_t
 acpicpu_md_cpus_running(void)
 {
diff -r ce977be3c64d -r d6517691f645 sys/dev/acpi/acpi_cpu.h
--- a/sys/dev/acpi/acpi_cpu.h   Fri Aug 13 19:56:34 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.h   Sat Aug 14 05:13:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.h,v 1.14 2010/08/13 16:21:50 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.h,v 1.15 2010/08/14 05:13:21 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -93,12 +93,13 @@
 #define ACPICPU_FLAG_P          __BIT(1)       /* P-states supported        */
 #define ACPICPU_FLAG_T          __BIT(2)       /* T-states supported        */
 
-#define ACPICPU_FLAG_C_FFH      __BIT(3)       /* Native C-states           */
-#define ACPICPU_FLAG_C_FADT     __BIT(4)       /* C-states with FADT        */
-#define ACPICPU_FLAG_C_BM       __BIT(5)       /* Bus master control        */
-#define ACPICPU_FLAG_C_BM_STS   __BIT(6)       /* Bus master check required */
-#define ACPICPU_FLAG_C_ARB      __BIT(7)       /* Bus master arbitration    */
-#define ACPICPU_FLAG_C_NOC3     __BIT(8)       /* C3 disabled (quirk)       */
+#define ACPICPU_FLAG_PIIX4      __BIT(3)       /* Broken (quirk)            */
+
+#define ACPICPU_FLAG_C_FFH      __BIT(4)       /* Native C-states           */
+#define ACPICPU_FLAG_C_FADT     __BIT(5)       /* C-states with FADT        */
+#define ACPICPU_FLAG_C_BM       __BIT(6)       /* Bus master control        */
+#define ACPICPU_FLAG_C_BM_STS   __BIT(7)       /* Bus master check required */
+#define ACPICPU_FLAG_C_ARB      __BIT(8)       /* Bus master arbitration    */
 #define ACPICPU_FLAG_C_C1E      __BIT(9)       /* AMD C1E detected          */
 
 #define ACPICPU_FLAG_P_FFH      __BIT(10)      /* Native P-states           */
diff -r ce977be3c64d -r d6517691f645 sys/dev/acpi/acpi_cpu_cstate.c
--- a/sys/dev/acpi/acpi_cpu_cstate.c    Fri Aug 13 19:56:34 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_cstate.c    Sat Aug 14 05:13:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_cstate.c,v 1.24 2010/08/13 16:21:50 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_cstate.c,v 1.25 2010/08/14 05:13:21 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.24 2010/08/13 16:21:50 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.25 2010/08/14 05:13:21 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -38,9 +38,6 @@
 #include <sys/mutex.h>
 #include <sys/timetc.h>
 
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcidevs.h>
-
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
 #include <dev/acpi/acpi_cpu.h>
@@ -61,7 +58,6 @@
 static void             acpicpu_cstate_memset(struct acpicpu_softc *);
 static void             acpicpu_cstate_fadt(struct acpicpu_softc *);
 static void             acpicpu_cstate_quirks(struct acpicpu_softc *);
-static int              acpicpu_cstate_quirks_piix4(struct pci_attach_args *);
 static int              acpicpu_cstate_latency(struct acpicpu_softc *);
 static bool             acpicpu_cstate_bm_check(void);
 static void             acpicpu_cstate_idle_enter(struct acpicpu_softc *,int);
@@ -596,60 +592,40 @@
 {
        const uint32_t reg = AcpiGbl_FADT.Pm2ControlBlock;
        const uint32_t len = AcpiGbl_FADT.Pm2ControlLength;
-       struct pci_attach_args pa;
+
+       /*
+        * Disable C3 for PIIX4.
+        */
+       if ((sc->sc_flags & ACPICPU_FLAG_PIIX4) != 0) {
+               sc->sc_cstate[ACPI_STATE_C3].cs_method = 0;
+               return;
+       }
 
        /*
         * 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)
+       if (reg != 0 && len != 0) {
                sc->sc_flags |= ACPICPU_FLAG_C_ARB;
-       else {
-               /*
-                * Disable C3 entirely if WBINVD is not present.
-                */
-               if ((AcpiGbl_FADT.Flags & ACPI_FADT_WBINVD) == 0)
-                       sc->sc_flags |= ACPICPU_FLAG_C_NOC3;
-               else {
-                       /*
-                        * 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;
-               }
+               return;
        }
 
        /*
-        * There are several erratums for PIIX4.
+        * Disable C3 entirely if WBINVD is not present.
         */
-       if (pci_find_device(&pa, acpicpu_cstate_quirks_piix4) != 0)
-               sc->sc_flags |= ACPICPU_FLAG_C_NOC3;
-
-       if ((sc->sc_flags & ACPICPU_FLAG_C_NOC3) != 0)
+       if ((AcpiGbl_FADT.Flags & ACPI_FADT_WBINVD) == 0)
                sc->sc_cstate[ACPI_STATE_C3].cs_method = 0;
-}
-
-static int
-acpicpu_cstate_quirks_piix4(struct pci_attach_args *pa)
-{
-
-       /*
-        * XXX: The pci_find_device(9) function only deals with
-        *      attached devices. Change this to use something like
-        *      pci_device_foreach(), and implement it for IA-64.
-        */
-       if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL)
-               return 0;
-
-       if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82371AB_ISA ||
-           PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82440MX_PMC)
-               return 1;
-
-       return 0;
+       else {
+               /*
+                * 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_cstate[ACPI_STATE_C3].cs_method = 0;
+       }
 }
 
 static int
diff -r ce977be3c64d -r d6517691f645 sys/dev/acpi/acpi_cpu_tstate.c
--- a/sys/dev/acpi/acpi_cpu_tstate.c    Fri Aug 13 19:56:34 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_tstate.c    Sat Aug 14 05:13:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_tstate.c,v 1.4 2010/08/13 19:51:54 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_tstate.c,v 1.5 2010/08/14 05:13:21 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_tstate.c,v 1.4 2010/08/13 19:51:54 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.5 2010/08/14 05:13:21 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -60,6 +60,12 @@
        ACPI_STATUS rv;
 
        /*
+        * Disable T-states for PIIX4.
+        */
+       if ((sc->sc_flags & ACPICPU_FLAG_PIIX4) != 0)
+               return;
+
+       /*
         * If either _TSS, _PTC, or _TPC is not
         * available, we have to resort to FADT.
         */



Home | Main Index | Thread Index | Old Index