Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Aug 2007 23:39:44 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        src-committers@FreeBSD.org
Cc:        cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/amd64/include specialreg.h src/sys/conf files.amd64 files.i386 src/sys/dev/coretemp coretemp.c src/sys/i386/include specialreg.h src/sys/modules Makefile src/sys/modules/coretemp Makefile src/sys/amd64/conf NOTES ...
Message-ID:  <864pj0qxy7.fsf@ds4.des.no>
In-Reply-To: <20070815204708.GA11724@tirith.brixandersen.dk> (Henrik Brix Andersen's message of "Wed\, 15 Aug 2007 22\:47\:08 %2B0200")
References:  <200708151926.l7FJQ3Md029693@repoman.freebsd.org> <20070815204708.GA11724@tirith.brixandersen.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Henrik Brix Andersen <henrik@brixandersen.dk> writes:
> $ dmesg | grep coretemp
> coretemp0: <CPU On-Die Thermal Sensors> on cpu0
> coretemp1: <CPU On-Die Thermal Sensors> on cpu1
>
> $ sysctl dev.cpu.0.temperature
> dev.cpu.0.temperature: -50
>
> $ sysctl dev.cpu.1.temperature
> dev.cpu.1.temperature: -49

This means Tj(max) is not properly detected.  The CPU actually reports
the temperature as a delta from the maximum rated operating temperature
in degrees Celsius; you're seeing the raw value.

Actually, the bug is easy to see:

	if ((cpu_model =3D=3D 0xf && cpu_mask > 3) || cpu_model =3D=3D 0xe) {
		msr =3D rdmsr(MSR_IA32_EXT_CONFIG);
		if ((msr >> 30) & 0x1)
			sc->sc_tjmax =3D 85;
	} else
		sc->sc_tjmax =3D 100;

Initializing sc->sc_tjmax to 100 before the outer if test should fix
this.  Could you please test the attached patch?

> The ACPI thermal zones seem to provide much more realistic readings:
>
> $ sysctl hw.acpi.thermal.tz0.temperature
> hw.acpi.thermal.tz0.temperature: 65.0C
>
> $ sysctl hw.acpi.thermal.tz1.temperature
> hw.acpi.thermal.tz1.temperature: 67.0C

Those are not the same temperature sensors.  The actual temperature in
your CPU is around 50 degrees Celsius.  The ACPI thermal zones are
probably sensors on the motherboard.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=tjmax.diff

Index: sys/dev/coretemp/coretemp.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/coretemp/coretemp.c,v
retrieving revision 1.1
diff -u -r1.1 coretemp.c
--- sys/dev/coretemp/coretemp.c	15 Aug 2007 19:26:02 -0000	1.1
+++ sys/dev/coretemp/coretemp.c	15 Aug 2007 21:35:31 -0000
@@ -168,12 +168,12 @@
 	 * The if-clause for CPUs having the MSR_IA32_EXT_CONFIG was adapted
 	 * from the Linux coretemp driver.
 	 */
+	sc->sc_tjmax = 100;
 	if ((cpu_model == 0xf && cpu_mask > 3) || cpu_model == 0xe) {
 		msr = rdmsr(MSR_IA32_EXT_CONFIG);
-		if ((msr >> 30) & 0x1)
+		if (msr & (1 << 30))
 			sc->sc_tjmax = 85;
-	} else
-		sc->sc_tjmax = 100;
+	}
 		
 	/*
 	 * Add the "temperature" MIB to dev.cpu.N.

--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?864pj0qxy7.fsf>