Source-Changes-HG archive

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

[src/trunk]: src/sys Use the idea from cegger@ and fill the (X)PSS structure ...



details:   https://anonhg.NetBSD.org/src/rev/c8eed95bf6c1
branches:  trunk
changeset: 757196:c8eed95bf6c1
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Aug 18 18:32:20 2010 +0000

description:
Use the idea from cegger@ and fill the (X)PSS structure during initialization.

diffstat:

 sys/arch/x86/acpi/acpi_cpu_md.c |  94 +++++++++++++++++++++++-----------------
 sys/dev/acpi/acpi_cpu.h         |   3 +-
 sys/dev/acpi/acpi_cpu_pstate.c  |  15 +++++-
 3 files changed, 68 insertions(+), 44 deletions(-)

diffs (182 lines):

diff -r 41b650e5f311 -r c8eed95bf6c1 sys/arch/x86/acpi/acpi_cpu_md.c
--- a/sys/arch/x86/acpi/acpi_cpu_md.c   Wed Aug 18 17:49:03 2010 +0000
+++ b/sys/arch/x86/acpi/acpi_cpu_md.c   Wed Aug 18 18:32:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_md.c,v 1.14 2010/08/18 16:08:50 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_md.c,v 1.15 2010/08/18 18:32: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.14 2010/08/18 16:08:50 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.15 2010/08/18 18:32:20 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -452,6 +452,57 @@
 }
 
 int
+acpicpu_md_pstate_pss(struct acpicpu_softc *sc)
+{
+       struct acpicpu_pstate *ps, msr;
+       uint32_t i = 0;
+
+       (void)memset(&msr, 0, sizeof(struct acpicpu_pstate));
+
+       switch (cpu_vendor) {
+
+       case CPUVENDOR_INTEL:
+               msr.ps_control_addr = MSR_PERF_CTL;
+               msr.ps_control_mask = __BITS(0, 15);
+
+               msr.ps_status_addr  = MSR_PERF_STATUS;
+               msr.ps_status_mask  = __BITS(0, 15);
+               break;
+
+       case CPUVENDOR_AMD:
+
+               if ((sc->sc_flags & ACPICPU_FLAG_P_XPSS) == 0)
+                       return EOPNOTSUPP;
+
+               break;
+
+       default:
+               return ENODEV;
+       }
+
+       while (i < sc->sc_pstate_count) {
+
+               ps = &sc->sc_pstate[i];
+
+               if (ps->ps_status_addr == 0)
+                       ps->ps_status_addr = msr.ps_status_addr;
+
+               if (ps->ps_status_mask == 0)
+                       ps->ps_status_mask = msr.ps_status_mask;
+
+               if (ps->ps_control_addr == 0)
+                       ps->ps_control_addr = msr.ps_control_addr;
+
+               if (ps->ps_control_mask == 0)
+                       ps->ps_control_mask = msr.ps_control_mask;
+
+               i++;
+       }
+
+       return 0;
+}
+
+int
 acpicpu_md_pstate_get(struct acpicpu_softc *sc, uint32_t *freq)
 {
        struct acpicpu_pstate *ps = NULL;
@@ -469,24 +520,6 @@
        if (__predict_false(ps == NULL))
                return EINVAL;
 
-       switch (cpu_vendor) {
-
-       case CPUVENDOR_INTEL:
-               ps->ps_status_addr = MSR_PERF_STATUS;
-               ps->ps_status_mask = __BITS(0, 15);
-               break;
-
-       case CPUVENDOR_AMD:
-
-               if ((ps->ps_flags & ACPICPU_FLAG_P_XPSS) == 0)
-                       return EOPNOTSUPP;
-
-               break;
-
-       default:
-               return ENODEV;
-       }
-
        if (ps->ps_status_addr == 0)
                return EINVAL;
 
@@ -518,27 +551,6 @@
        uint64_t xc;
        int rv = 0;
 
-       switch (cpu_vendor) {
-
-       case CPUVENDOR_INTEL:
-               ps->ps_control_addr = MSR_PERF_CTL;
-               ps->ps_control_mask = __BITS(0, 15);
-
-               ps->ps_status_addr  = MSR_PERF_STATUS;
-               ps->ps_status_mask  = __BITS(0, 15);
-               break;
-
-       case CPUVENDOR_AMD:
-
-               if ((ps->ps_flags & ACPICPU_FLAG_P_XPSS) == 0)
-                       return EOPNOTSUPP;
-
-               break;
-
-       default:
-               return ENODEV;
-       }
-
        msr.msr_read  = false;
        msr.msr_type  = ps->ps_control_addr;
        msr.msr_value = ps->ps_control;
diff -r 41b650e5f311 -r c8eed95bf6c1 sys/dev/acpi/acpi_cpu.h
--- a/sys/dev/acpi/acpi_cpu.h   Wed Aug 18 17:49:03 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.h   Wed Aug 18 18:32:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.h,v 1.18 2010/08/17 10:17:52 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.h,v 1.19 2010/08/18 18:32:20 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -241,6 +241,7 @@
 void           acpicpu_md_idle_enter(int, int);
 int            acpicpu_md_pstate_start(void);
 int            acpicpu_md_pstate_stop(void);
+int            acpicpu_md_pstate_pss(struct acpicpu_softc *);
 int            acpicpu_md_pstate_get(struct acpicpu_softc *, uint32_t *);
 int            acpicpu_md_pstate_set(struct acpicpu_pstate *);
 int            acpicpu_md_tstate_get(struct acpicpu_softc *, uint32_t *);
diff -r 41b650e5f311 -r c8eed95bf6c1 sys/dev/acpi/acpi_cpu_pstate.c
--- a/sys/dev/acpi/acpi_cpu_pstate.c    Wed Aug 18 17:49:03 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_pstate.c    Wed Aug 18 18:32:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.29 2010/08/17 10:57:30 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.30 2010/08/18 18:32: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_pstate.c,v 1.29 2010/08/17 10:57:30 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.30 2010/08/18 18:32:20 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -112,6 +112,17 @@
        if (ACPI_FAILURE(rv))
                aprint_debug_dev(self, "_PPC missing\n");
 
+       /*
+        * Employ the XPSS structure by filling
+        * it with MD information required for FFH.
+        */
+       rv = acpicpu_md_pstate_pss(sc);
+
+       if (rv != 0) {
+               rv = AE_SUPPORT;
+               goto fail;
+       }
+
        sc->sc_flags |= ACPICPU_FLAG_P;
 
        acpicpu_pstate_bios();



Home | Main Index | Thread Index | Old Index