Re: ktemp(8) on Phenom II

From: Randi Harper <randi_at_freebsd.org>
Date: Wed, 11 Mar 2009 19:38:01 -0700
I'm not subscribed to current, so if you reply, make sure you include me in
the CC. :)

This adds support for all 4 cores of the Phenom II - although I'm not really
sure why you'd need it. Please test, as I have no idea if this is going to
break anything or if I did something obviously wrong. Works fine on my box,
but I am *so* not a developer. Also, I didn't try it on current. Apply the
patch referred to earlier in this thread before applying this one, or
clearly it's not going to work.

[root_at_deviant ~]# uname -a
FreeBSD deviant.freebsdgirl.com 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan
1 08:58:24 UTC 2009
root_at_driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
amd64

[root_at_deviant ~]# sysctl dev.cpu | grep temperature
dev.cpu.0.temperature: 40.0C
dev.cpu.1.temperature: 40.0C
dev.cpu.2.temperature: 40.0C
dev.cpu.3.temperature: 40.0C


-- randi



--- k8temp.c.orig       2009-03-12 10:25:41.000000000 -0700
+++ k8temp.c    2009-03-12 10:21:54.000000000 -0700
_at__at_ -51,10 +51,16 _at__at_
 typedef enum {
        SENSOR0_CORE0,
        SENSOR0_CORE1,
+       SENSOR0_CORE2,
+       SENSOR0_CORE3,
        SENSOR1_CORE0,
        SENSOR1_CORE1,
+       SENSOR1_CORE2,
+       SENSOR1_CORE3,
        CORE0,
-       CORE1
+       CORE1,
+       CORE2,
+       CORE3
 } k8sensor_t;

 struct k8temp_softc {
_at__at_ -62,7 +68,7 _at__at_
        int             sc_temps[4];
        int             sc_ntemps;
        struct sysctl_oid *sc_oid;
-       struct sysctl_oid *sc_sysctl_cpu[2];
+       struct sysctl_oid *sc_sysctl_cpu[4];
        struct intr_config_hook sc_ich;
        int32_t (*sc_gettemp)(device_t, k8sensor_t);
 };
_at__at_ -227,6 +233,18 _at__at_
            OID_AUTO, "core1", CTLTYPE_INT | CTLFLAG_RD,
            dev, SENSOR0_CORE1, k8temp_sysctl, "IK",
            "Sensor 0 / Core 1 temperature");
+
+        SYSCTL_ADD_PROC(sysctlctx,
+            SYSCTL_CHILDREN(sysctlnode),
+            OID_AUTO, "core2", CTLTYPE_INT | CTLFLAG_RD,
+            dev, SENSOR0_CORE2, k8temp_sysctl, "IK",
+            "Sensor 0 / Core 2 temperature");
+
+        SYSCTL_ADD_PROC(sysctlctx,
+            SYSCTL_CHILDREN(sysctlnode),
+            OID_AUTO, "core3", CTLTYPE_INT | CTLFLAG_RD,
+            dev, SENSOR0_CORE3, k8temp_sysctl, "IK",
+            "Sensor 0 / Core 3 temperature");

        sysctlnode = SYSCTL_ADD_NODE(sysctlctx,
            SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
"sensor1",
_at__at_ -244,6 +262,18 _at__at_
            dev, SENSOR1_CORE1, k8temp_sysctl, "IK",
            "Sensor 1 / Core 1 temperature");

+        SYSCTL_ADD_PROC(sysctlctx,
+            SYSCTL_CHILDREN(sysctlnode),
+            OID_AUTO, "core2", CTLTYPE_INT | CTLFLAG_RD,
+            dev, SENSOR1_CORE2, k8temp_sysctl, "IK",
+            "Sensor 1 / Core 2 temperature");
+
+        SYSCTL_ADD_PROC(sysctlctx,
+            SYSCTL_CHILDREN(sysctlnode),
+            OID_AUTO, "core3", CTLTYPE_INT | CTLFLAG_RD,
+            dev, SENSOR1_CORE3, k8temp_sysctl, "IK",
+            "Sensor 1 / Core 3 temperature");
+
        return (0);
 }

_at__at_ -264,7 +294,7 _at__at_
        nexus = device_find_child(root_bus, "nexus", 0);
        acpi = device_find_child(nexus, "acpi", 0);

-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < 4; i++) {
                cpu = device_find_child(acpi, "cpu",
                    device_get_unit(dev) * 2 + i);
                if (cpu) {
_at__at_ -315,6 +345,16 _at__at_
                auxtemp[1] = sc->sc_gettemp(dev, SENSOR1_CORE1);
                temp = imax(auxtemp[0], auxtemp[1]);
                break;
+       case CORE2:
+               auxtemp[0] = sc->sc_gettemp(dev, SENSOR0_CORE2);
+               auxtemp[1] = sc->sc_gettemp(dev, SENSOR1_CORE2);
+               temp = imax(auxtemp[0], auxtemp[1]);
+               break;
+       case CORE3:
+               auxtemp[0] = sc->sc_gettemp(dev, SENSOR0_CORE3);
+               auxtemp[1] = sc->sc_gettemp(dev, SENSOR1_CORE3);
+               temp = imax(auxtemp[0], auxtemp[1]);
+               break;
        default:
                temp = sc->sc_gettemp(dev, arg2);
                break;
Received on Thu Mar 12 2009 - 02:00:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:43 UTC