Skip to contentSkip to conversation

coretemp - digital temperature driver for Intel Core

lm-sensors Rudolf Marek 3 participants 19 messages Sep 26, 2006 – Sep 30, 2006

lore
Share & tools
lore
#0 lore raw

Hello all,

I had today some time and coded the driver for Core 2 processors which will read the temperature from the CPU. (precisely I worked on it from 16:36 to 23:59 with some preemptions ;)

I dont have such CPU so I'm looking for brave testers!

The code is "virgin" it compiles but that is all I know. Testers should expect oops, panic or simple crash... Or maybe if I did not make any mistake (hehe) the temperature in /sys/class/hwmon/correcthwmondir/temp1_input

To compile:
make -C /lib/modules/uname -r/build SUBDIRS=$PWD modules

Again this should be for either brave testers or persons with the knowledge of C ... I will review the code tomorrow again.

Good luck and thanks!

regards
Rudolf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coretemp.c
Type: application/octet
Size: 8780 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060927/5ad49cd3/attachment.bin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile
Url: http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060927/5ad49cd3/attachment.pl

#1 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

Hi again,

Sorry for one more email. I should really go sleep... It should work on Core Duo/Solo without "2" too.

cat /proc/cpuinfo should show:
cpu family : 6
model : 14

or:

cpu family : 6
model : 15

It does not support CPU hotplug yet...

Rudolf

#2 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 13 lines · Rudolf Marek

Hello all,

I had today some time and coded the driver for Core 2 processors which will read the temperature from the CPU. (precisely I worked on it from 16:36 to 23:59 with some preemptions ;)

I dont have such CPU so I'm looking for brave testers!

The code is "virgin" it compiles but that is all I know. Testers should expect oops, panic or simple crash... Or maybe if I did not make any mistake (hehe) the temperature in /sys/class/hwmon/correcthwmondir/temp1_input

Quoted 5 lines

To compile:
make -C /lib/modules/uname -r/build SUBDIRS=$PWD modules

Again this should be for either brave testers or persons with the knowledge of C ... I will review the code tomorrow again.

Doesn't seem to work here with a Core2 Duo 6400 and kernel 2.6.18:

cat /sys/class/hwmon/hwmon1/device/temp1_input
0

Thanks for the effort though!

Michael

Signature · 1 line
San Francisco, CA
#3 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek

Hello,

Thanks for the test. It is cool but it does not work ;)

Quoted 4 lines

Doesn't seem to work here with a Core2 Duo 6400 and kernel 2.6.18:

cat /sys/class/hwmon/hwmon1/device/temp1_input
0

Ehm.

Please add this two printk to this code:

              data->therm_status = eax;
              printk("EAX from  MSR %x\n", eax);

                 /* update only if data has been valid */
                 if (eax & 0x80000000) {
			printk("in temp condition\n");

Run it again, to see the 0 but check the log...

Thanks,

regards
Rudolf

#4 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 8 lines · Rudolf Marek

Please add this two printk to this code:

              data->therm_status = eax;
              printk("EAX from  MSR %x\n", eax);

                 /* update only if data has been valid */
                 if (eax & 0x80000000) {
			printk("in temp condition\n");

Uhhhh... add them WHERE?

BTW, the hw monitoring chip on my motherboard (Asus P5B Deluxe WiFi) already does report CPU temp.

Michael

Signature · 1 line
San Francisco, CA
#5 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 8 lines · Michael Nelson
Quoted 5 lines · Rudolf Marek

Please add this two printk to this code:

              data->therm_status = eax;
              printk("EAX from  MSR %x\n", eax);
Quoted 8 lines
Quoted 4 lines
                 /* update only if data has been valid */
                 if (eax & 0x80000000) {
			printk("in temp condition\n");

Uhhhh... add them WHERE?

Find this line:

  data->therm_status = eax;

on next line add

printk("EAX from MSR %x\n", eax);

and find this line:
if (eax & 0x80000000) {
and on next line add

printk("in temp condition\n");

Thanks.

Quoted 3 lines

BTW, the hw monitoring chip on my motherboard (Asus P5B Deluxe WiFi) already does report CPU temp.

Yes but I need to test this ;)

Thanks,
Rudolf

#6 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 6 lines · Rudolf Marek

Find this line:

  data->therm_status = eax;

on next line add

Quoted 7 lines

printk("EAX from MSR %x\n", eax);

and find this line:
if (eax & 0x80000000) {
and on next line add

printk("in temp condition\n");

Ok, I did that, recompiled it using

make -C /lib/modules/uname -r/build SUBDIRS=$PWD modules

Then copied it to:

/lib/modules/2.6.18/kernel/drivers/hwmon/coretemp.ko

depmod -a

# modprobe coretemp
# lsmod | grep core
#

Hmmmm

The end of dmesg says:

kobject_add failed for coretemp.0 with -EEXIST, don't try to register things with the same name in the same directory.

 [<c01b32fd>] kobject_add+0x10d/0x180
 [<c02109f6>] device_add+0x86/0x2c0
 [<c0213c24>] platform_device_add+0xe4/0x150
 [<f92640c5>] coretemp_init+0xc5/0x15f [coretemp]
 [<c0135d4c>] sys_init_module+0x12c/0x1ac0
 [<c0102c5d>] sysenter_past_esp+0x56/0x79

coretemp: Device addition failed (-17)

What's next?

Michael

Signature · 1 line
San Francisco, CA
#7 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 44 lines · Michael Nelson
Quoted 6 lines · Rudolf Marek

Find this line:

  data->therm_status = eax;

on next line add

Quoted 8 lines

printk("EAX from MSR %x\n", eax);

and find this line:
if (eax & 0x80000000) {
and on next line add

printk("in temp condition\n");

Ok, I did that, recompiled it using

make -C /lib/modules/uname -r/build SUBDIRS=$PWD modules

Then copied it to:

/lib/modules/2.6.18/kernel/drivers/hwmon/coretemp.ko

depmod -a

# modprobe coretemp
# lsmod | grep core
#

Hmmmm

The end of dmesg says:

kobject_add failed for coretemp.0 with -EEXIST, don't try to register things with the same name in the same directory.

 [<c01b32fd>] kobject_add+0x10d/0x180
 [<c02109f6>] device_add+0x86/0x2c0
 [<c0213c24>] platform_device_add+0xe4/0x150
 [<f92640c5>] coretemp_init+0xc5/0x15f [coretemp]
 [<c0135d4c>] sys_init_module+0x12c/0x1ac0
 [<c0102c5d>] sysenter_past_esp+0x56/0x79
Quoted 4 lines

coretemp: Device addition failed (-17)

What's next?

I think something has been left out in kernel. Did you rmmoded the driver before inserting the new one?
If you rmmoded, there is some problem. Please reboot and try to load the driver again.

Thanks
Regards
Rudolf

#8 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 4 lines · Rudolf Marek

I think something has been left out in kernel. Did you rmmoded the driver before inserting the new one?
If you rmmoded, there is some problem. Please reboot and try to load the driver again.

OK I did, and it loaded.

seahunt:/var/log # cat /sys/class/hwmon/hwmon0/device/temp1_input 29000
seahunt:/var/log # cat /sys/class/hwmon/hwmon1/device/temp1_input 0
seahunt:/var/log # cat /sys/class/hwmon/hwmon2/device/temp1_input 0

So does that 29000 mean it's working? The hwmon chip says 53.0C right now.

Michael

Signature · 1 line
San Francisco, CA
#9 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek

I also get this:

# grep EAX /var/log/messages
Sep 27 07:15:46 seahunt kernel: EAX from  MSR 2
Sep 27 07:16:07 seahunt kernel: EAX from  MSR 2
Sep 27 07:16:12 seahunt kernel: EAX from  MSR 2
Signature · 1 line
San Francisco, CA
#10 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 6 lines · Michael Nelson

I also get this:

# grep EAX /var/log/messages
Sep 27 07:15:46 seahunt kernel: EAX from  MSR 2
Sep 27 07:16:07 seahunt kernel: EAX from  MSR 2

Did you add the second printk too?

Is it displayed?

I think there is something wrong I will take a look maybe in the evening...

regards
Rudolf

#11 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 1 line · Rudolf Marek

Did you add the second printk too?

I did.

Quoted 1 line

Is it displayed?

No:

# grep condition /var/log/messages
# 
Quoted 1 line

I think there is something wrong I will take a look maybe in the evening...

OK, I will be glad to test further.

Thank you
Michael

Signature · 1 line
San Francisco, CA
#12 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 3 lines

OK, I will be glad to test further.

Ok I think I found it.:

Please change this:

             do_rdmsr(data->id, MSR_IA32_THERM_CONTROL, &eax, &edx);

Into this:

             do_rdmsr(data->id, MSR_IA32_THERM_STATUS, &eax, &edx);

It should work ...

Thanks,

Rudolf

#13 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 6 lines · Rudolf Marek
Quoted 3 lines

OK, I will be glad to test further.

Ok I think I found it.:

Quoted 8 lines

Please change this:

             do_rdmsr(data->id, MSR_IA32_THERM_CONTROL, &eax, &edx);

Into this:

             do_rdmsr(data->id, MSR_IA32_THERM_STATUS, &eax, &edx);

It should work ...

I made the change and recompiled, and even after verifying that the previous one had been rmmodded, the new one won't insert, gives the same error as before when I try to modprobe it.

Can you please fix it so it can be modprobed and rmmodded without having to reboot? I was going to test this while ssh'd in from work but don't want to reboot the machine.

Thank you
Michael

Signature · 1 line
San Francisco, CA
#14 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek

t.

Quoted 4 lines

Can you please fix it so it can be modprobed and rmmodded without having to reboot? I was going to test this while ssh'd in from work but don't want to reboot the machine.

I think I found that, please use attached version.

Thanks,
Rudolf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coretemp.c
Type: application/octet
Size: 8867 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060928/1a9f30ad/attachment.bin

#15 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek
Quoted 1 line · Rudolf Marek

I think I found that, please use attached version.

OK, here's the latest:

seahunt:/var/log # cat /sys/class/hwmon/hwmon0/device/temp1_input 31000
seahunt:/var/log # cat /sys/class/hwmon/hwmon1/device/temp1_input 58000
seahunt:/var/log # cat /sys/class/hwmon/hwmon2/device/temp1_input 58000
seahunt:/var/log # sensors | grep Temp

MB Temp:     +31??C  (high =   +35??C, hyst =   +40??C)
CPU Temp:  +55.5??C  (high = +70.0??C, hyst = +40.0??C)

Assuming 58000 means 58 degrees C and 31000 means 31 degrees C, it looks OK?

Thanks
Michael

Signature · 1 line
San Francisco, CA
#16 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek

Hello all,

Please check the new version on http://assembler.cz/download/coretemp/

It has:

1) code improvements
2) support for critical temperature alarm
3) shows the TjMax temperature
4) hotplug CPU support
5) new bugs? ;)

there is also a patch for userspace - should be applied on top of the SVN HEAD.

Please test it and let me know how the output of "sensors" command looks like. I believe this version is less dangerous to use than a first one, but of course I cannot guarantee that. All I know is that it compiles...

Any testing is appreciated.

Thanks,

Rudolf

#17 lore raw

[lm-sensors] coretemp - digital temperature driver for

In reply to Rudolf Marek

Hello Rudolf,

I'm running a C2D (E6600) system here and would be happy to be of assistance.

I've downloaded and compiled your latest version (I think heh) but the resulting temperature is a bit off I think.

The CPU temp as reported by the SuperIO chip is 23.5 degrees, you driver reports about 37000 (37 degrees? and which core? or is that supposed to be the m/b diode?)
a little c program to read the coretemp from the CPU I have found elsewhere on the net reports ~51 degrees for both cores on the same idle system (the little program is attached, it's header says it's GPL).

If you need any testing done let me know. A hwmon sysfs interface to both(!) coretemps would be most welcome =)

Signature · 17 lines
Matthias Hentges 

My OS: Debian SID. Geek by Nature, Linux by Choice
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coretemp.c
Type: text/x-csrc
Size: 2435 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060930/8e36379b/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060930/8e36379b/attachment-0001.bin 
#18 lore raw

[lm-sensors] coretemp - digital temperature driver for Intel

In reply to Rudolf Marek

Hello Matthias,

Quoted 2 lines

I'm running a C2D (E6600) system here and would be happy to be of assistance.

Good thanks. What motherboard is it. Is it the desktop/laptop?

Quoted 6 lines

I've downloaded and compiled your latest version (I think heh) but the resulting temperature is a bit off I think.

The CPU temp as reported by the SuperIO chip is 23.5 degrees, you driver reports about 37000 (37 degrees? and which core? or is that supposed to be the m/b diode?)

This is even better than the diode, it is the value from special build-in digital temperature sensor. The value from superio could be

1) from thermistor bellow the CPU socket
2) thermal diode value

Can you paste the output of "sensors" command please?

Quoted 3 lines

a little c program to read the coretemp from the CPU I have found elsewhere on the net reports ~51 degrees for both cores on the same idle system (the little program is attached, it's header says it's GPL).

Well it there is a bit problem. To calculate the temperature, you need to know so called "TjMax" which that program sets fixed to 100C, however my implementation detect this TjMax and set it to 100C or 85C.

85C should have systems for other than LGA socket.

Toutput = TjMax - registerValue

So If the TjMax is wrong, output temperature is also wrong (offset 15C)

Quoted 2 lines

If you need any testing done let me know. A hwmon sysfs interface to both(!) coretemps would be most welcome =)

I think it very good to have such driver so I "donated" my time for this driver development ;)

Well it should be for both cores. Have you used this version?
http://assembler.cz/download/coretemp/

There is a patch for lm-sensors so you just need to run "sensors" and it should show the temps for both cores. Please can you cut&paste the output of sensors command to the mail?

Quoted 1 line
    return 100 - data[2];

It uses fixed 100 value.

Please can you provide output of following files:
cat /sys/class/hwmon/hwmon0/device/temp1_input
cat /sys/class/hwmon/hwmon0/device/temp1_crit

cat /sys/class/hwmon/hwmon1/device/temp1_input
cat /sys/class/hwmon/hwmon1/device/temp1_crit

cat /sys/class/hwmon/hwmon2/device/temp1_input
cat /sys/class/hwmon/hwmon2/device/temp1_crit

I think we will see the crit temperature as 85000 (so it is 85C).

Question is what is correct. Please can you try to reboot and check the BIOS? Also how much the temperature grows when you run in linux when running following command:
dd if=/dev/zero of=/dev/null bs=1M count@00

I'm also on IRC irc.freenode.net #linux-sensors

Thank you for help,
Regards
Rudolf