Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 01 Apr 2005 10:42:46 -0800
From:      Nate Lawson <nate@root.org>
To:        acpi@FreeBSD.org
Subject:   patch: enable MSR support for EST
Message-ID:  <424D9626.4080302@root.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------000804000906060002080607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

The attached patch calls an acpi 3.0 method that on some laptops, 
exposes the SpeedStep MSRs via the acpi_perf driver.  If you have a 
laptop that supports SpeedStep but it doesn't appear to work right, 
please try this patch and see if it fixes things.

-- 
Nate

--------------000804000906060002080607
Content-Type: text/plain;
 name="acpi_pdc.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="acpi_pdc.diff"

Index: sys/dev/acpica/acpi_cpu.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_cpu.c,v
retrieving revision 1.54
diff -u -r1.54 acpi_cpu.c
--- sys/dev/acpica/acpi_cpu.c	27 Mar 2005 03:37:43 -0000	1.54
+++ sys/dev/acpica/acpi_cpu.c	1 Apr 2005 18:22:51 -0000
@@ -79,6 +79,7 @@
     struct acpi_cx	 cpu_cx_states[MAX_CX_STATES];
     int			 cpu_cx_count;	/* Number of valid Cx states. */
     int			 cpu_prev_sleep;/* Last idle sleep duration. */
+    int			 cpu_features;	/* Child driver supported features. */
 };
 
 struct acpi_cpu_device {
@@ -138,6 +139,7 @@
 static int	acpi_cpu_read_ivar(device_t dev, device_t child, int index,
 		    uintptr_t *result);
 static int	acpi_cpu_shutdown(device_t dev);
+static int	acpi_cpu_feature(device_t bus, device_t dev, int features);
 static int	acpi_cpu_cx_probe(struct acpi_cpu_softc *sc);
 static int	acpi_cpu_cx_cst(struct acpi_cpu_softc *sc);
 static void	acpi_cpu_startup(void *arg);
@@ -171,6 +173,9 @@
     DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
     DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
 
+    /* ACPI methods */
+    DEVMETHOD(acpi_enable_feature, acpi_cpu_feature),
+
     {0, 0}
 };
 
@@ -324,8 +329,13 @@
     } else
 	sysctl_ctx_free(&acpi_cpu_sysctl_ctx);
 
-    /* Call identify and then probe/attach for cpu child drivers. */
+    /*
+     * Call identify, collecting CPU feature hints from children, notify
+     * ACPI of them, and then probe/attach cpu child drivers.
+     */
     bus_generic_probe(dev);
+    if (sc->cpu_features)
+	acpi_SetInteger(sc->cpu_dev, "_PDC", sc->cpu_features);
     bus_generic_attach(dev);
 
     return (0);
@@ -434,6 +444,16 @@
 }
 
 static int
+acpi_cpu_feature(device_t bus, device_t dev, int features)
+{
+    struct acpi_cpu_softc *sc;
+
+    sc = device_get_softc(bus);
+    sc->cpu_features |= features;
+    return (0);
+}
+
+static int
 acpi_cpu_cx_probe(struct acpi_cpu_softc *sc)
 {
     ACPI_GENERIC_ADDRESS gas;
Index: sys/dev/acpica/acpi_if.m
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_if.m,v
retrieving revision 1.5
diff -u -r1.5 acpi_if.m
--- sys/dev/acpica/acpi_if.m	20 Mar 2005 01:27:27 -0000	1.5
+++ sys/dev/acpica/acpi_if.m	1 Apr 2005 02:50:11 -0000
@@ -156,6 +156,23 @@
 };
 
 #
+# Notify ACPI that a given driver supports some feature(s).  This should be
+# called by the driver before it expects to probe or use the desired
+# features.
+#
+# device_t bus:  parent bus for the device
+#
+# device_t dev:  device requesting the feature(s)
+#
+# int features:  bitmask of all desired features
+#
+METHOD int enable_feature {
+	device_t	bus;
+	device_t	dev;
+	u_int		features;
+};
+
+#
 # Read embedded controller (EC) address space
 #
 # device_t dev:  EC device
Index: sys/dev/acpica/acpivar.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v
retrieving revision 1.91
diff -u -r1.91 acpivar.h
--- sys/dev/acpica/acpivar.h	27 Mar 2005 21:30:33 -0000	1.91
+++ sys/dev/acpica/acpivar.h	1 Apr 2005 03:04:08 -0000
@@ -166,6 +166,20 @@
 #define	ACPI_INTR_SAPIC		2
 
 /*
+ * Various features and capabilities for the acpi_enable_feature() method.
+ * In particular, these are used for the ACPI 3.0 _PDC and _OSC methods.
+ */
+#define ACPI_CAP_PERF_MSRS	(1 << 0) /* Intel SpeedStep PERF_CTL MSRs */
+#define ACPI_CAP_C1_IO_HALT	(1 << 1) /* Intel C1 "IO then halt" sequence */
+#define ACPI_CAP_THR_MSRS	(1 << 2) /* Intel OnDemand throttling MSRs */
+#define ACPI_CAP_SMP_SAME	(1 << 3) /* MP C1, Px, and Tx (all the same) */
+#define ACPI_CAP_SMP_SAME_C3	(1 << 4) /* MP C2 and C3 (all the same) */
+#define ACPI_CAP_SMP_DIFF_PX	(1 << 5) /* MP Px (different, using _PSD) */
+#define ACPI_CAP_SMP_DIFF_CX	(1 << 6) /* MP Cx (different, using _CSD) */
+#define ACPI_CAP_SMP_DIFF_TX	(1 << 7) /* MP Tx (different, using _TSD) */
+#define ACPI_CAP_SMP_C1_NATIVE	(1 << 8) /* MP C1 support other than halt */
+
+/*
  * Quirk flags.
  *
  * ACPI_Q_BROKEN: Disables all ACPI support.
Index: sys/i386/cpufreq/est.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/cpufreq/est.c,v
retrieving revision 1.5
diff -u -r1.5 est.c
--- sys/i386/cpufreq/est.c	21 Mar 2005 06:43:25 -0000	1.5
+++ sys/i386/cpufreq/est.c	1 Apr 2005 18:13:00 -0000
@@ -40,6 +40,10 @@
 #include "cpufreq_if.h"
 #include <machine/md_var.h>
 
+#include <contrib/dev/acpica/acpi.h>
+#include <dev/acpica/acpivar.h>
+#include "acpi_if.h"
+
 /* Status/control registers (from the IA-32 System Programming Guide). */
 #define MSR_PERF_STATUS		0x198
 #define MSR_PERF_CTL		0x199
@@ -572,6 +576,7 @@
 static void
 est_identify(driver_t *driver, device_t parent)
 {
+	device_t child;
 	u_int p[4];
 
 	/* Make sure we're not being doubly invoked. */
@@ -591,8 +596,14 @@
 	 * We add a child for each CPU since settings must be performed
 	 * on each CPU in the SMP case.
 	 */
-	if (BUS_ADD_CHILD(parent, 0, "est", -1) == NULL)
+	child = BUS_ADD_CHILD(parent, 0, "est", -1);
+	if (child == NULL) {
 		device_printf(parent, "add est child failed\n");
+		return;
+	}
+
+	/* Notify the ACPI CPU that we support direct access to MSRs */
+	ACPI_ENABLE_FEATURE(parent, child, ACPI_CAP_PERF_MSRS);
 }
 
 static int
Index: sys/modules/cpufreq/Makefile
===================================================================
RCS file: /home/ncvs/src/sys/modules/cpufreq/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- sys/modules/cpufreq/Makefile	31 Mar 2005 18:51:06 -0000	1.6
+++ sys/modules/cpufreq/Makefile	1 Apr 2005 18:16:55 -0000
@@ -8,13 +8,11 @@
 SRCS=	ichss.c
 SRCS+=	bus_if.h cpufreq_if.h device_if.h pci_if.h
 
-.if ${MACHINE} == "i386"
+.if ${MACHINE} == "i386" || ${MACHINE} == "amd64"
+.PATH:	${.CURDIR}/../../i386/cpufreq
+CFLAGS+= -I${.CURDIR}/../../contrib/dev/acpica
+SRCS+=	acpi_if.h opt_acpi.h
 SRCS+=	est.c p4tcc.c powernow.c
 .endif
 
-.if ${MACHINE} == "amd64"
-.PATH: ${.CURDIR}/../../i386/cpufreq
-SRCS+=	powernow.c
-.endif
-
 .include <bsd.kmod.mk>

--------------000804000906060002080607--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?424D9626.4080302>