vt8231.c
Subsystems (2)
Hi Knut,
It looks like it is working on your system too. :-)
Thanks for you help in testing this out.
I posted a revised patch update to the mailing list yesterday - I got a whole load of change requests from Jean. Most of these were cosmetic or minor performance changes, but I would suggest that you update if possible.
The fan is handled correctly, but you have the nasty condition where if you set a minimum speed that is too low, it is set to zero. The Via speed sensor works on period rather than frequency, so there is a 1/x conversion done in the driver. If you select a frequency that is too low, then the conversion to a period creates a period that is too large for the counters and the resulting illegal result is rejected. If you want very slow fan speeds then you must make sure the divider is set high enough so that the resulting period is within the limits of the device.
Personally, I don't like this. It isn't really a massive amount of work to get the driver to automatically either:
1) Automatically select the appropriate divider for the minimum speed that you have requested (i.e. pick the highest divider ratio that can give the speed you want range)
Or
2) Select the lowest possible minimum speed if the one you selected is still too low.
A minimum speed of 0 should always disable the minimum speed detection. Resetting the minimum speed to zero when you select a non-zero minimum speed is just plain wrong, however, as it is not obvious exactly what is happening "behind the scenes". I spent quite a bit of time debugging the system to convince myself it was working "correctly".
What are your thoughts on this?
Anyone else have thoughts on this?
- Roger
-----Original Message-----
From: Knut Petersen [mailto:[email protected]]
Sent: 02 November 2005 08:53
To: Roger Lucas
Subject: Re: vt8231.c
Hi Roger,
Quoted 8 lines
Attached is a patch file for the 2.6.14 kernel tree. I have also attached my sensors.conf file.
Please could you try this and let me know if it works for you?
linux:/etc # sensors
vt8231-isa-6000
Adapter: ISA adapter
+12v: +11.96 V (min = +11.37 V, max = +12.56 V)
+5v: +5.21 V (min = +4.73 V, max = +5.24 V)
+2.5v: +2.46 V (min = +2.42 V, max = +2.57 V)
Vcore1 (1.2v):
+1.22 V (min = +1.14 V, max = +1.25 V)
+3.3V: +3.35 V (min = +3.13 V, max = +3.45 V)
fan1: 11808 RPM (min = 0 RPM, div = 1)
fan2: 0 RPM (min = 0 RPM, div = 2)
Proc Temp: +45.1?C (high = +268?C, hyst = -59?C)
vid: +1.85 Veeprom-i2c-0-51
Adapter: SMBus Via Pro adapter at 5000 Memory type: SDR SDRAM DIMM Memory size (MB): 512
Voltages:
===+5V is within 0.02V with my multimeter, +12V is about 0.16V low according to my multimeter
Temperature:
====The displayed value is believable.
Fans:
==
I connected a fan for tests. It?s a Verax fan with 9 pulses / revolution.
In sensors.conf I used the four dividers 1,2,4,9 instead of the *:
set fan1_div *
set fan1_min 1000
Here are the results
1: fan1: 12024 RPM (min = 0 RPM, div = 1) 2: fan1: 11702 RPM (min = 0 RPM, div = 2) 4: fan1: 11702 RPM (min = 0 RPM, div = 4) 8: fan1: 12603 RPM (min = 999 RPM, div = 8) 9: fan1: 11915 RPM (min = 0 RPM, div = 2)
Obviously the fan1_min are ignored most of the time and dividers are not handled correctly.
The datasheet of the fan lists 1500 rpm for a temperature of 30? Celsius and about 1200 rpm
for 20? Celsius. So 12024/9 = 1336 rpm is believable.
cu,
knut
Hi Roger,
Quoted 4 lines · Roger Lucas
The fan is handled correctly, but you have the nasty condition where if you set a minimum speed that is too low, it is set to zero. The Via speed sensor works on period rather than frequency, so there is a 1/x conversion done in the driver.
Note that this is pretty standard, almost all fan tachometers work that way. The only drivers which do not have to invert the register value are the FSC ones if I remember correctly.
Quoted 3 lines
If you select a frequency that is too low, then the conversion to a period creates a period that is too large for the counters and the resulting illegal result is rejected.
It's not rejected, it's even worse than that: it's rounded to the greatest possible value (255), which in turn is read back as 0 RPM.
Quoted 7 lines
If you want very slow fan
speeds then you must make sure the divider is set high enough so that the resulting period is within the limits of the device.Personally, I don't like this. It isn't really a massive amount of work to get the driver to automatically either:
Quoted 7 lines
1) Automatically select the appropriate divider for the minimum speed that you have requested (i.e. pick the highest divider ratio that can give the speed you want range)
Or
2) Select the lowest possible minimum speed if the one you selected is still too low.
I think that most drivers implement solution 2. We have a (low) number of drivers which implement automatic fan-div switching (pc87360, adm9240), which is a subset of solution 1.
Quoted 1 line
A minimum speed of 0 should always disable the minimum speed detection.
We can't always do that, as it depends on what the chip itself does. Some chips have a dedicated bit to disable the alarm. Some chips disable the alarm if the limit register is set to 0. Some chips disable the alarm if the limit register is set to 255. What does the VT8231 do?
Quoted 6 lines
Resetting the minimum speed to zero when you select a non-zero minimum speed is just plain wrong, however, as it is not obvious exactly what is happening "behind the scenes". I spent quite a bit of time debugging the system to convince myself it was working "correctly".
(...)
Anyone else have thoughts on this?
I completely agree with you. Please fix the driver. We should port the fix back to lm_sensors CVS too. In fact, I think the current behavior is a bug in the original code. Consider the following code:
Quoted 12 lines
/********* FAN RPM CONVERSIONS ********/
/* But this chip saturates back at 0, not at 255 like all the other chips.
So, 0 means 0 RPM */
static inline u8FAN_TO_REG(long rpm, int div){ if (rpm = 0) return 0; rpm = SENSORS_LIMIT(rpm, 1, 1000000); return SENSORS_LIMIT((1310720 + rpm * div / 2) / (rpm * div), 1, 255); }
Quoted 3 lines
#define
MIN_TO_REG(a, b)FAN_TO_REG(a, b)#define FAN_FROM_REG(val, div) \ ((val)=0?0:(val)=255?0:1310720/((val)*(div)))
The comment clearly states that the register value will be 0 if the fan speed is too low to be measured under the currently selected clock divider. I guess this is true for stopped or missing fan as well (can you confirm?) Thus there is no reason to consider the register value 255 any differently from other non-zero values, is there? The FAN_TO_REG function does actually not, but the FAN_FROM_REG macro does, and I believe this is where the bug is.
Try removing the (val)=255 case in FAN_TO_REG, and I think the driver will behave like you described above (solution 2).
While you're there, please delete the MIN_TO_REG macro and use FAN_TO_REG instead.
You could also get rid of the middle SENSORS_LIMIT call in FAN_TO_REG, providing you use strtoul instead of strtol to read the input value (in set_fan_min). The lower bound will be handled by strtoul and the = 0 check. The upper bound is redundant with the next SENSORS_LIMIT call.
If you are willing to implement the solution 1, fine with me. This isn't a requirement for me to accept the driver in Linux 2.6 though.
I will try to review the code further later today. It would be great if we could integrate this ported driver in Linux 2.6 soon, it has been around for too long already.
Thanks a lot for your work,
--
Jean Delvare
Hi Jean,
Updated patch attached. I love it when you inherit loads of code that you end up fixing... :-)
I am not so sure I am very keen on the intelligence for the auto-div calculation moving into the driver. I think this code should be in the sensors utility.
On the other hand, however, the way the DIV_TO_REG() function was coded, it would be almost impossible for any application to determine the legal values for DIV without knowing the details of the device. Any illegal value would end up with DIV set at zero - not very helpful. As an alternative, this attached patch includes a code revision that sets DIV to the smallest legal DIV value that is the same as or larger than the requested DIV value. Hence, the mapping is as below:
Requested DIV Set DIV 1 1 2 2 3 4 4 4 5 8 6 8 7 8 8 8 8+ 8
From this sequence, the DIV returned is predictable and an application can very quickly determine the legal DIV values and make its calculations accordingly.
With this revised code, if you ask for a low limit 1000 RPM with a divisor of 4, you get a low limit of 1285 RPM returned. If you ask for a low limit of 1000 RPM with a divisor of 5 then you get a low limit of 999 RPM returned with a divisor of 8.
Consider the pseudo-code below:
set_div = 1;set_rpm_div(set_div);set_low_limit_rpm(requested_limit_rpm);
while( get_low_limit_rpm() > requested_limit_rpm )
{
true_div = get_rpm_div();
if (set_div > true_div)
{
break; // we have exceeded the DIV range
}
// Try next div value
set_div = true_div + 1;
set_rpm_div(set_div);
set_low_limit_rpm(requested_limit_rpm);
}This will iterate through the valid DIV values and stop when it reaches the best RPM match or the highest valid DIV setting.
I feel that this should be up in the application, however, and not in the driver. IMHO, the drivers should be a simple as possible.
- Roger
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 02 November 2005 13:12
To: [email protected]
Cc: 'LM Sensors'; Knut Petersen
Subject: [lm-sensors] RE: vt8231.c
Hi Roger,
Quoted 4 lines · Roger Lucas
The fan is handled correctly, but you have the nasty condition where if you set a minimum speed that is too low, it is set to zero. The Via speed sensor works on period rather than frequency, so there is a 1/x conversion done in the driver.
Note that this is pretty standard, almost all fan tachometers work that way. The only drivers which do not have to invert the register value are the FSC ones if I remember correctly.
Quoted 3 lines
If you select a frequency that is too low, then the conversion to a period creates a period that is too large for the counters and the resulting illegal result is rejected.
It's not rejected, it's even worse than that: it's rounded to the greatest possible value (255), which in turn is read back as 0 RPM.
Quoted 7 lines
If you want very slow fan
speeds then you must make sure the divider is set high enough so that the resulting period is within the limits of the device.Personally, I don't like this. It isn't really a massive amount of work to get the driver to automatically either:
Quoted 7 lines
1) Automatically select the appropriate divider for the minimum speed that you have requested (i.e. pick the highest divider ratio that can give the speed you want range)
Or
2) Select the lowest possible minimum speed if the one you selected is still too low.
I think that most drivers implement solution 2. We have a (low) number of drivers which implement automatic fan-div switching (pc87360, adm9240), which is a subset of solution 1.
Quoted 1 line
A minimum speed of 0 should always disable the minimum speed detection.
We can't always do that, as it depends on what the chip itself does. Some chips have a dedicated bit to disable the alarm. Some chips disable the alarm if the limit register is set to 0. Some chips disable the alarm if the limit register is set to 255. What does the VT8231 do?
Quoted 6 lines
Resetting the minimum speed to zero when you select a non-zero minimum speed is just plain wrong, however, as it is not obvious exactly what is happening "behind the scenes". I spent quite a bit of time debugging the system to convince myself it was working "correctly".
(...)
Anyone else have thoughts on this?
I completely agree with you. Please fix the driver. We should port the fix back to lm_sensors CVS too. In fact, I think the current behavior is a bug in the original code. Consider the following code:
Quoted 12 lines
/********* FAN RPM CONVERSIONS ********/
/* But this chip saturates back at 0, not at 255 like all the other chips.
So, 0 means 0 RPM */
static inline u8FAN_TO_REG(long rpm, int div){ if (rpm = 0) return 0; rpm = SENSORS_LIMIT(rpm, 1, 1000000); return SENSORS_LIMIT((1310720 + rpm * div / 2) / (rpm * div), 1, 255); }
Quoted 3 lines
#define
MIN_TO_REG(a, b)FAN_TO_REG(a, b)#define FAN_FROM_REG(val, div) \ ((val)=0?0:(val)=255?0:1310720/((val)*(div)))
The comment clearly states that the register value will be 0 if the fan speed is too low to be measured under the currently selected clock divider. I guess this is true for stopped or missing fan as well (can you confirm?) Thus there is no reason to consider the register value 255 any differently from other non-zero values, is there? The FAN_TO_REG function does actually not, but the FAN_FROM_REG macro does, and I believe this is where the bug is.
Try removing the (val)=255 case in FAN_TO_REG, and I think the driver will behave like you described above (solution 2).
While you're there, please delete the MIN_TO_REG macro and use FAN_TO_REG instead.
You could also get rid of the middle SENSORS_LIMIT call in FAN_TO_REG, providing you use strtoul instead of strtol to read the input value (in set_fan_min). The lower bound will be handled by strtoul and the = 0 check. The upper bound is redundant with the next SENSORS_LIMIT call.
If you are willing to implement the solution 1, fine with me. This isn't a requirement for me to accept the driver in Linux 2.6 though.
I will try to review the code further later today. It would be great if we could integrate this ported driver in Linux 2.6 soon, it has been around for too long already.
Thanks a lot for your work,
--
Jean Delvare
-------------- next part --------------
drivers/hwmon/Kconfig +12 -0
@@ -350,6 +350,18 @@ This driver can also be built as a module. If so, the module will be called via686a. +config SENSORS_VT8231 + tristate "VT8231" + depends on HWMON && I2C && PCI && EXPERIMENTAL + select HWMON_VID + select I2C_ISA + help + If you say yes here then you get support for the integrated sensors + in the Via VT8231 device. + + This driver can also be built as a module. If so, the module + will be called vt8231. + config SENSORS_W83781D tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" depends on HWMON && I2C
drivers/hwmon/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o +obj-$(CONFIG_SENSORS_VT8231) += vt8231.o obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
drivers/hwmon/vt8231.c +781 -0
781 lines not on this page · raw message
Quoted 6 lines · Roger Lucas
Hi Jean,
Updated patch attached. I love it when you inherit loads of code that you end up fixing... :-)
One problem: As you know, I use a Verax fan with 9 pulses/revolution.
If i use
compute fan1 @/9 , @*9
set fan1_min 1
set fan1_div 1
in sensors.conf, the shortened sensors output is:
fan1: 1324 RPM (min = 571 RPM, div = 1)
and /sys/bus/i2c/devices/9191-6000/fan1_min contains 5140.
But if I use
compute fan1 @/9 , @*9
set fan1_min 0
set fan1_div 1
that results in a sensors output of
fan1: 1324 RPM (min = 0 RPM, div = 1) ALARM
and /sys/bus/i2c/devices/9191-6000/fan1_min contains 0.
The previous patch also behaved wrong for a "set fan1_min 0".
cu,
Knut
Hi Knut,
I'm not sure exactly how the VT8251 generates its alarms. I'll have to look into the device spec and see exactly what it does then get back to you.
- Roger
-----Original Message-----
From: Knut Petersen [mailto:[email protected]]
Sent: 02 November 2005 18:48
To: Roger Lucas
Cc: 'Jean Delvare'; 'LM Sensors'
Subject: Re: [lm-sensors] RE: vt8231.c
Quoted 6 lines · Roger Lucas
Hi Jean,
Updated patch attached. I love it when you inherit loads of code that you end up fixing... :-)
One problem: As you know, I use a Verax fan with 9 pulses/revolution.
If i use
compute fan1 @/9 , @*9
set fan1_min 1
set fan1_div 1
in sensors.conf, the shortened sensors output is:
fan1: 1324 RPM (min = 571 RPM, div = 1)
and /sys/bus/i2c/devices/9191-6000/fan1_min contains 5140.
But if I use
compute fan1 @/9 , @*9
set fan1_min 0
set fan1_div 1
that results in a sensors output of
fan1: 1324 RPM (min = 0 RPM, div = 1) ALARM
and /sys/bus/i2c/devices/9191-6000/fan1_min contains 0.
The previous patch also behaved wrong for a "set fan1_min 0".
cu,
Knut
BTW, Knut...
Quoted 11 lines
Fans:
==
I connected a fan for tests. It?s a Verax fan with 9 pulses / revolution.In sensors.conf I used the four dividers 1,2,4,9 instead of the *:
set
fan1_div*
setfan1_min1000Here are the results
Quoted 8 lines
1: fan1: 12024 RPM (min = 0 RPM, div = 1) 2: fan1: 11702 RPM (min = 0 RPM, div = 2) 4: fan1: 11702 RPM (min = 0 RPM, div = 4) 8: fan1: 12603 RPM (min = 999 RPM, div = 8) 9: fan1: 11915 RPM (min = 0 RPM, div = 2)Obviously the
fan1_minare ignored most of the time and dividers are not handled correctly.
Dividers work the way they are supposed to. You do not seem to understand what that way is. I invite you to read the following document:
http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/fan-divisors
Hopefully this will help you understand how it works.
If you use a 9 pulse/rev fan (didn't know these existed...) instead of standard 2 pulse/rev, you should add the following line to your configuration file:
conpute fan1 @*2/9, @*9/2
Signature · 1 line
Jean Delvare
Quoted 28 lines · Jean Delvare
BTW, Knut...
Quoted 11 lines
Fans:
==
I connected a fan for tests. It?s a Verax fan with 9 pulses / revolution.In sensors.conf I used the four dividers 1,2,4,9 instead of the *:
set
fan1_div*
setfan1_min1000Here are the results
Quoted 8 lines
1: fan1: 12024 RPM (min = 0 RPM, div = 1) 2: fan1: 11702 RPM (min = 0 RPM, div = 2) 4: fan1: 11702 RPM (min = 0 RPM, div = 4) 8: fan1: 12603 RPM (min = 999 RPM, div = 8) 9: fan1: 11915 RPM (min = 0 RPM, div = 2)Obviously the
fan1_minare ignored most of the time and dividers are not handled correctly.Dividers work the way they are supposed to. You do not seem to understand what that way is. I invite you to read the following document:
http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/fan-divisors
Quoted 7 lines
Hopefully this will help you understand how it works.
If you use a 9 pulse/rev fan (didn't know these existed...) instead of standard 2 pulse/rev, you should add the following line to your configuration file:
conpute fan1 @*2/9, @*9/2
Possibly:
compute fan1 @*8/9, @*9/8
since fan1_div = 8 is only one gave a result for fan1_min?
Grant.
Quoted 1 line
Hi Roger, Knut,
Quoted 6 lines
Quoted 6 lines
But if I use
compute fan1 @/9 , @*9
setfan1_min0
setfan1_div1
Quoted 6 lines
Quoted 3 lines
that results in a sensors output of
fan1: 1324 RPM (min = 0 RPM, div = 1) ALARM
I'm not sure exactly how the VT8231 generates its alarms. I'll have to look into the device spec and see exactly what it does then get back to you.
This means that my suggestion of changing FAN_FROM_REG earlier today was probably not correct, and FAN_TO_REG should be changed instead:
static inline u8 FAN_TO_REG(long rpm, int div)
{
if (rpm = 0)
return 255;
return SENSORS_LIMIT(1310720 / (rpm * div), 1, 254);
}static inline long FAN_FROM_REG(u8 reg, int div)
{
if (reg = 0 || reg = 255)
return 0;
return (1310720 / (reg * div));
}Ideally we should probably handle the fan speed measurement registers and the low limit registers differently, as 255 means no low limit (0 RPM) but is still a valid speed measurement. However, I am not certain the benefit is worth the additional code.
Roger: I am in the process of reviewing all your code. This takes some time so please be patient. I couldn't finish the review today, hopefully it will be OK tomorrow.
Thanks,
Signature · 1 line
Jean Delvare
Hi Jean,
No problem. I appreciate the effort you are spending on the code review.
- Roger
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 02 November 2005 20:56
To: Roger Lucas
Cc: [email protected]; LM Sensors
Subject: Re: [lm-sensors] RE: vt8231.c
Hi Roger, Knut,
Quoted 11 lines
Quoted 9 lines
But if I use
compute fan1 @/9 , @*9
setfan1_min0
setfan1_div1that results in a sensors output of
fan1: 1324 RPM (min = 0 RPM, div = 1) ALARM
I'm not sure exactly how the VT8231 generates its alarms. I'll have to
look
Quoted 1 line
into the device spec and see exactly what it does then get back to you.
This means that my suggestion of changing FAN_FROM_REG earlier today was probably not correct, and FAN_TO_REG should be changed instead:
static inline u8 FAN_TO_REG(long rpm, int div)
{
if (rpm = 0)
return 255;
return SENSORS_LIMIT(1310720 / (rpm * div), 1, 254);
}static inline long FAN_FROM_REG(u8 reg, int div)
{
if (reg = 0 || reg = 255)
return 0;
return (1310720 / (reg * div));
}Ideally we should probably handle the fan speed measurement registers and the low limit registers differently, as 255 means no low limit (0 RPM) but is still a valid speed measurement. However, I am not certain the benefit is worth the additional code.
Roger: I am in the process of reviewing all your code. This takes some time so please be patient. I couldn't finish the review today, hopefully it will be OK tomorrow.
Thanks,
Signature · 1 line
Jean Delvare
Hi Grant:
Quoted 12 lines
Quoted 11 lines · Jean Delvare
Dividers work the way they are supposed to. You do not seem to understand what that way is. I invite you to read the following document:
http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/fan-divisorsHopefully this will help you understand how it works.
If you use a 9 pulse/rev fan (didn't know these existed...) instead of standard 2 pulse/rev, you should add the following line to your configuration file:
conpute fan1 @*2/9, @*9/2
Quoted 5 lines · Grant Coady
Possibly:
compute fan1 @*8/9, @*9/8since
fan1_div= 8 is only one gave a result forfan1_min?
No, no, no... fan divisors are *not* related to sensors.conf compute formulas!
You must have read the document Jean mentioned... didn't you work on automagic fan divisor algorithms for a while?
Who are you? And what have you done with Grant? ;)
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Quoted 1 line · Mark M. Hoffman
Hi Grant:
...
Quoted 6 lines
No, no, no... fan divisors are *not* related to sensors.conf compute formulas!
You must have read the document Jean mentioned... didn't you work on automagic fan divisor algorithms for a while?
Who are you? And what have you done with Grant? ;)
What can I say? It was before coffee this morning :o)
Cheers,
Grant.
Hi Roger,
Quoted 2 lines
Updated patch attached. I love it when you inherit loads of code that you end up fixing... :-)
I finished reviewing your code (at last! sorry for the delay), here we go.
First of all, please delete all trailing whitespace in vt8231.c. There are a lot of these.
And a generic comment: I *know* that some of the problems here are not yours, they come from the original driver. Don't take it personally ;) but we need to fix them all before the driver can be accepted in Linux 2.6.
Quoted 5 lines
diff -Naur reference/drivers/hwmon/Kconfig linux-2.6.14/drivers/hwmon/Kconfig
drivers/hwmon/Kconfig +0
-0@@ -350,6 +350,18 @@ This driver can also be built as a module. If so, the module
drivers/hwmon/Kconfig line 360
Quoted 10 lines
drivers/hwmon/Kconfig +8
-0will be called via686a. +config SENSORS_VT8231 + tristate "VT8231" + depends on HWMON && I2C && PCI && EXPERIMENTAL + select HWMON_VID + select I2C_ISA + help + If you say yes here then you get support for the integrated sensors + in the Via VT8231 device.
VIA should never be spelled Via.
drivers/hwmon/vt8231.c line 3
Quoted 7 lines
diff -Naur
reference/drivers/hwmon/vt8231.clinux-2.6.14/drivers/hwmon/vt8231.cdrivers/hwmon/vt8231.c +3
-0@@ -0,0 +1,785 @@ +static int force_addr; +module_param (force_addr, int,0644 ); +MODULE_PARM_DESC (force_addr,"Initialize the base address of the sensors" );
The "0644" doesn't make sense. It means that a sysfs file will be created for this parameter. Given that the parameter is only needed at initialization time, the created file will be of no use. Use "0" to not create a file.
Also, missing space before comma.
drivers/hwmon/vt8231.c line 8
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+/* pwm numbered 1-2 */ +#define VT8231_REG_PWM (nr) (0x5f + (nr)) +#define VT8231_REG_PWM_CTL 0x51 + +/* The VT8231 registers */
You could move the PWM register definitions below, else that comment is somewhat confusing.
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+/* We define the sensors as follows. Somewhat convoluted to minimize +changes from via686a. +Sensor Voltage Mode Temp Mode +-------- ------------ ---------
drivers/hwmon/vt8231.c line 22
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+Reading 1 temp3 +Reading 3 temp1 not in vt8231 +UCH1/Reading2 in0 temp2 +UCH2 in1 temp4 +UCH3 in2 temp5 +UCH4 in3 temp6 +UCH5 in4 temp7 +3.3V in5 +-12V in6 not in vt8231 +*/
What is the benefit in mentioning the inputs which the VT8231 does not have?
It's a bit confusing (and non-standard) to have temperatures starting at temp2 :(
drivers/hwmon/vt8231.c line 27
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+static const u8 regtemp[] = {0x20 ,0x21 ,0x1f ,0x22 ,0x23 ,0x24 ,0x25 }; +static const u8 regover[] = {0x39 ,0x3d ,0x1d ,0x2b ,0x2d ,0x2f ,0x31 }; +static const u8 reghyst[] = {0x3a ,0x3e ,0x1e ,0x2c ,0x2e ,0x30 ,0x32 }; + +/* temps numbered 1-7 */
So that would be 2-7. This suggests that the first "column" in the above arrays is never used, so it should be deleted.
drivers/hwmon/vt8231.c line 28
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define ALARMS_FROM_REG (val) (val)
Please discard that macro and use the value directly instead.
drivers/hwmon/vt8231.c line 29
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define DIV_TO_REG (val) ((val)=8?3:(val)=4?2:(val)=1?0:1)
In Linux 2.6 we have changed to a different strategy. Instead of defaulting to an arbitrary divider value when an unsupported value is requested, we report the error to userspace. See the various other Linux 2.6 drivers for examples.
drivers/hwmon/vt8231.c line 30
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define PWM_FROM_REG (val) (val)
You can drop that one too.
drivers/hwmon/vt8231.c line 31
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define PWM_TO_REG (val) SENSORS_LIMIT((val), 0, 255)
For this one too, it is advisable to return an error on invalid values. See it87.c for an example.
drivers/hwmon/vt8231.c line 35
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+#define TEMP_FROM_REG (val) (long)((val)*10) +#define TEMP_FROM_REG10 (val) (long)(((val)*10)/4) +#define TEMP_TO_REG (val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\ + ((val)+5)/10), 0, 255))
These do not look correct to me. They suggest that you are exporting the values to userspace with LSB = 0.1 degree C. The standard is 0.001 degree C, as documented in Documentation/hwmon/sysfs-interface. I am surprised that you got correct temperature readings, unless you also hacked libsensors.
Looking further in sensors.conf.eg, it looks like the VT8231 expresses each temperature as a voltage, which libsensors then converts to a temperature. This is a rare, but not unique, case. The pc87360 driver does something similar for temp4-6. In this case, the value must be exported in sysfs with LSB = 1 mV, as voltages do.
Even then, the formulas in sensors.conf.eg look very complex to me. We will have to look into that and make some sense out of them
drivers/hwmon/vt8231.c line 37
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+#define IN_FROM_REG (val) ((long)(val)) +#define IN_TO_REG (val) (SENSORS_LIMIT((((val) * 10 + 5)/10), 0, 255))
Voltage values must be exported to userspace with LSB = 1 mV, this is a standard. This doesn't seem to be the case here. IN_TO_REG is also
nonsensical: you multiply by 10, then immediately divide the result by 10?
Seeing the conversion formulas in sensors.conf.eg, I think I understand that the VT8231 differs much from the other chips. Most of the conversion formula (the common part) should be moved inside the driver if we want to respect the sysfs standard. This will break the compatibility between the 2.4 and the 2.6 vt8231 drivers, but we don't seem to have the choice.
drivers/hwmon/vt8231.c line 41
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+static inline int vt8231_read_value (struct i2c_client *client,u8 reg) +{ +return (inb_p (client->addr + reg)); +}
Please drop the redundant parentheses.
drivers/hwmon/vt8231.c line 42
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+/* following are the sysfs callback functions */
Generic comment about sysfs callback functions:
A new possibility, known as "dynamic sysfs callbacks", was recently introduced. Not all hardware monitoring drivers use it yet, but I would like new drivers to do, so that we don't have to convert them later.
These dynamic callbacks let you get rid of a large part of the macros above, by giving you the possibility to pass an integer parameter to the callback functions, making it possible to use the same callback function for several sysfs files.
See the it87 driver for an example. If would be very great if you could convert the vt8231 driver to do the same. This greatly improves the code readability, and makes the compiled object significantly smaller as well.
drivers/hwmon/vt8231.c line 52
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+static ssize_t set_in_min (struct device *dev,const char *buf, +size_t count,int nr) { +struct i2c_client *client =to_i2c_client (dev); +struct vt8231_data *data =i2c_get_clientdata (client); +unsigned long val =simple_strtoul (buf,NULL ,10 ); + data->in_min[nr] =IN_TO_REG (val); +vt8231_write_value (client,VT8231_REG_IN_MIN (nr), + data->in_min[nr]); +return count; +}
All "set" callback functions should hold data->update_lock while they manipulate any data field. If not, you have a race condition if another sysfs file is being read (triggering an update) while you write to this one.
See any other hwmon files for an example, it's really easy.
drivers/hwmon/vt8231.c line 53
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+/* show_temp_offset(1); */
Delete that line, no point in keeping comments about something which doesn't exist.
drivers/hwmon/vt8231.c line 59
Quoted 6 lines
drivers/hwmon/vt8231.c +6
-0+/**** VRM and VID *****/ +static ssize_t show_vid (struct device *dev,struct device_attribute *attr, +char *buf) { +struct vt8231_data *data =vt8231_update_device (dev); +return sprintf (buf,"%ld\n" , (long )vid_from_reg (data->cpu0_vid, data->vrm)); +}
The (long) cast is not needed, simply use %d instead of %ld.
drivers/hwmon/vt8231.c line 66
Quoted 7 lines
drivers/hwmon/vt8231.c +7
-0+static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); + +static ssize_t show_vrm (struct device *dev,struct device_attribute *attr, +char *buf) { +struct vt8231_data *data =vt8231_update_device (dev); +return sprintf (buf,"%ld\n" , (long )data->vrm); +}
Same here.
drivers/hwmon/vt8231.c line 75
Quoted 9 lines
drivers/hwmon/vt8231.c +9
-0+static ssize_t set_vrm (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) { +struct i2c_client *client =to_i2c_client (dev); +struct vt8231_data *data =i2c_get_clientdata (client); +int val =simple_strtol (buf,NULL ,10 ); +printk ("Setting VRM to \"%s\" = %d\n" , buf, val); + data->vrm = val; +return count; +}
Drop that printk, it's pretty useless.
drivers/hwmon/vt8231.c
Quoted 9 lines
drivers/hwmon/vt8231.c +8
-0+int vt8231_detect (struct i2c_adapter *adapter) +{ +/* Reserve the ISA region */ +if (!request_region (isa_address,VT8231_EXTENT , type_name)) { +dev_err (&adapter->dev,"region 0x%x already in use!\n" , + isa_address); +return -ENODEV ; + }
Please use vt8231_pci_driver.name to reserve the region (you'll need to forward-declare it).
drivers/hwmon/vt8231.c
Quoted 7 lines
drivers/hwmon/vt8231.c +6
-0+if (!(data =kzalloc (sizeof (struct vt8231_data ),GFP_KERNEL ))) { + err = -ENOMEM ; + goto exit_release; + } + + new_client->flags =0 ;
I don't think you need to explicitely set it to 0, as kzalloc did it for you. We'd need to fix all other drivers too.
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+/* Fill in the remaining client fields and put into the global list */ +strlcpy (new_client->name, type_name,I2C_NAME_SIZE );
As this is now the only usage of type_name, you'd better put the string verbatim here.
You forgot to create sysfs files for PWM?
drivers/hwmon/vt8231.c
Quoted 8 lines
drivers/hwmon/vt8231.c +7
-0+static int vt8231_detach_client (struct i2c_client *client) +{ +if ((err =i2c_detach_client (client))) { +dev_err (&client->dev, +"Client deregistration failed, client not detached.\n" ); +return err; + }
Please drop the log message, it was refactored into i2c_detach_client some times ago.
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+release_region (client->addr,VT8231_EXTENT ); +kfree (i2c_get_clientdata (client));
You can user "data" instead.
drivers/hwmon/vt8231.c
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+static struct vt8231_data *vt8231_update_device (struct device *dev) +{ +struct i2c_client *client =to_i2c_client (dev); +struct vt8231_data *data =i2c_get_clientdata (client); +int i, j; + +down (&data->update_lock); + +if ((jiffies - data->last_updated >HZ +HZ /2 ) || + (jiffies < data->last_updated) || !data->valid) {
Use time_after() instead of direct jiffies comparisons.
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+ data->uch_config =vt8231_read_value (client, +VT8231_REG_UCH_CONFIG );
I now realize that there is no sysfs file to change this value. I'm fine with that, as I believe this is the BIOS' job to properly configure the chip. However, we should then be consistent and modify the other parts of the driver accordingly. In particular, the driver should not create the sysfs files for the channels which are not in use. That way, the code below wouldn't have to repeatedly set unused values to 0.
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+for (i =0 ; i <=5 ; i++) { +if (ISVOLT (i, data->uch_config)) { + data->in[i] =vt8231_read_value (client, +VT8231_REG_IN (i));
drivers/hwmon/vt8231.c
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+ data->in_min[i] =vt8231_read_value (client, +VT8231_REG_IN_MIN (i)); + data->in_max[i] =vt8231_read_value (client, +VT8231_REG_IN_MAX (i)); + }else { + data->in[i] =0 ; + data->in_min[i] =0 ; + data->in_max[i] =0 ; + } + }
I'd have a clear preference for "< 6" instead of <=5.
drivers/hwmon/vt8231.c
Quoted 9 lines
drivers/hwmon/vt8231.c +9
-0+for (i =2 ; i <=7 ; i++) { +if (ISTEMP (i, data->uch_config)) { + data->temp[i -1 ] =vt8231_read_value (client, +VT8231_REG_TEMP (i)) <<2 ; +switch (i) { +case 1 : +/* ? */ + j =0 ; +break ;
This case can obviously be dropped.
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+case 2 : + j = (vt8231_read_value (client, +VT8231_REG_TEMP_LOW2 ) & +0x30 ) >>4 ; +break ;
drivers/hwmon/vt8231.c
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+case 3 : + j = (vt8231_read_value (client, +VT8231_REG_TEMP_LOW3 ) & +0xc0 ) >>6 ; +break ; +case 4 : +case 5 : +case 6 : +case 7 : +default :
Either keep only default, or drop it.
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+ j = (vt8231_read_value (client, +VT8231_REG_TEMP_LOW47 ) + >> ((i-4 )*2 )) &0x03 ; +break ; +
drivers/hwmon/vt8231.c
Quoted 10 lines
drivers/hwmon/vt8231.c +9
-0+ } +for (i =1 ; i <=2 ; i++) { + data->fan[i -1 ] =vt8231_read_value (client, +VT8231_REG_FAN (i)); + data->fan_min[i -1 ] =vt8231_read_value (client, +VT8231_REG_FAN_MIN (i)); + data->pwm[i -1 ] =vt8231_read_value (client, +VT8231_REG_PWM (i)); + }
I don't get it. We already read the fan registers earlier in this function!
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+ data->cpu0_vid=vt8231_read_value (client,VT8231_REG_VID ) + &0x1f ;
Missing space before "=" sign.
drivers/hwmon/vt8231.c
Quoted 9 lines
drivers/hwmon/vt8231.c +9
-0+static struct pci_device_id vt8231_pci_ids[] = { + { + .vendor =PCI_VENDOR_ID_VIA , + .device =PCI_DEVICE_ID_VIA_8231_4 , + .subvendor =PCI_ANY_ID , + .subdevice =PCI_ANY_ID , + }, + {0 , } +};
Please use the PCI_DEVICE macro. Also add a call to MODULE_DEVICE_TABLE (see via686a).
drivers/hwmon/vt8231.c
Quoted 6 lines
drivers/hwmon/vt8231.c +5
-0+static int __devinit vt8231_pci_probe (struct pci_dev *dev, +const struct pci_device_id *id) +{ +if (force_addr) + isa_address = force_addr;/* so detect will get called */
No more needed, detect will get called anyway.
drivers/hwmon/vt8231.c
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+if (!isa_address) { +dev_err (&dev->dev,"No Via 8231 sensors found.\n" ); +return -ENODEV ; + }
Drop that test, it was previously unneeded if you read the code carefully, and now it is a bug.
drivers/hwmon/vt8231.c
Quoted 11 lines
drivers/hwmon/vt8231.c +11
-0+static void __exit sm_vt8231_exit(void) +{ +pci_unregister_driver (&vt8231_pci_driver); +if (s_bridge !=NULL ) { +i2c_isa_del_driver (&vt8231_driver); +pci_dev_put (s_bridge); + s_bridge =NULL ; + } +} + +
Drop the second blank line.
"Other than that, it's OK" as I use to say ;)
Yeah, I know there are many many fixes needed. But nothing impossible if you are motivated enough. And if you have questions we're here to answer them.
I now answer your other questions:
Quoted 3 lines
I am not so sure I am very keen on the intelligence for the auto-div calculation moving into the driver. I think this code should be in the sensors utility.
There was a debate long ago about this. Some people (at least Mark M. Hoffman) advocated a user-space solution. I tend to agree in general that putting policy into the kernel is bad, and also about the fact that drivers must be as simple as possible. However, after checking the facts, I came to the conclusion that doing this in the kernel was OK. The main reason is that a user-space helper would need to know many things which the drivers do not currently export: the list of divider for each fan input, either the clock frequency, the register width. Additionally, letting userspace change the divider means that the driver needs additional code to preserve the min limit when this happens. As I found I'd need more code to do all this than the in-driver auto-fan-div takes, I decided for that second option.
Anyway, not all drivers do that. Those which do use slightly different rules. It's not all settled yet. If anyone provides a userspace daemon and modifies some drivers so that we can see how the userspace approach would work, that's fine with me.
Quoted 4 lines
On the other hand, however, the way the
DIV_TO_REG()function was coded, it would be almost impossible for any application to determine the legal values for DIV without knowing the details of the device. Any illegal value would end up with DIV set at zero - not very helpful.
The old code defaulted to a divider of 2 actually. But see my comments in the code above, 2.6 does things differently.
Quoted 5 lines
As an alternative, this
attached patch includes a code revision that sets DIV to the smallest legal DIV value that is the same as or larger than the requested DIV value. Hence, the mapping is as below:
Quoted 10 lines
Requested DIV Set DIV 1 1 2 2 3 4 4 4 5 8 6 8 7 8 8 8 8+ 8
I prefer an explicit -EINVAL with no divider change on invalid value, as all drivers in 2.6 now tend to do.
Quoted 8 lines
From this sequence, the DIV returned is predictable and an application can very quickly determine the legal DIV values and make its calculations accordingly.
With this revised code, if you ask for a low limit 1000 RPM with a divisor of 4, you get a low limit of 1285 RPM returned. If you ask for a low limit of 1000 RPM with a divisor of 5 then you get a low limit of 999 RPM returned with a divisor of 8.
The div returned is not predictable. Some chips have dividers up to
128. Some chips (it87) have different rules for the different channels (fan3 only has possible dividers 2 and 8). Unless the chip explicitely lists the possible dividers, there is no possible auto-div implementation in user-space. We are *not* going to set random div values and see if it works. This would generate actual register writes and execute a lot of code. Let's not probe for something we already have the knowledge of and simply needs to be exported.
Also, the only thing all chips share is the fact that the dividers are powers of 2. So it's pretty pointless to try to support other inputs from user-space. Nobody sane will try them.
Quoted 19 lines
Consider the pseudo-code below:
set_div= 1;set_rpm_div(set_div);set_low_limit_rpm(requested_limit_rpm);
while( get_low_limit_rpm() > requested_limit_rpm ){ true_div = get_rpm_div(); if (set_div > true_div) { break; // we have exceeded the DIV range } // Try next div value set_div = true_div + 1; set_rpm_div(set_div); set_low_limit_rpm(requested_limit_rpm); }
Quoted 2 lines
This will iterate through the valid DIV values and stop when it reaches the best RPM match or the highest valid DIV setting.
Sorry, I can't make any sense of this pseudo code. What part is in user space? What part is in the driver? "set_low_limit_rpm" can mean about anything. It can be in userspace (sensors, libsensors), it can be a request to the driver, it can be a register write.
If you want to propose something, please explain it with words.
Quoted 2 lines
I feel that this should be up in the application, however, and not in the driver. IMHO, the drivers should be a simple as possible.
As said above, I usually tend to agree, but in the facts, in this one case, the code is much more simple and efficient when in the drivers.
It would probably make sense to have a helper module for all drivers though, so as to not duplicate the code.
Thanks,
Signature · 1 line
Jean Delvare
Hi Jean,
Thanks for taking the time to review the code. There was a lot of code in there that I did not understand and felt that I didn't need to understand as it wasn't in areas that I was directly changing. Your comments have clarified a lot, and any new knowledge is a good thing.
One question I have is regarding the "1 mV" calibration, and this returns me to a general comment/question with the LM-Sensors system:
The LM-Sensors system appears to be based on what the sensors chips are on the motherboard, rather than what the motherboard is. From the "probe and find out what I have" concept, this is reasonable, but it does cause a LOT of problems for users who are less educated. Many of the sensors devices are wired up in different ways on different motherboards, with (for example) a voltage input being used for a 12v rail monitor on one motherboard and a 5v rail monitor on another. The motherboard manufacturer is completely at liberty to wire a device in any way they choose.
This therefore makes a sensors.conf file really a motherboard-specific rather than a device specific file. If you use the configuration file according to the device that you have, rather than the motherboard that you have, then you run a very high risk of reporting nonsense to a user, or (arguably worse) reporting information that looks correct but is actually wrong.
Following this through, when you request that the driver report the voltage detected in mV, I am _hoping_ that you are asking for the voltage at the pin of the device, rather than the voltage that the device happens to be ultimately connected to on this particular motherboard? Reporting the voltage at the device pin is the only consistent behaviour that I can see for a motherboard-independent device driver.
If the above makes sense, then would there be any interest in building some kind of database of known good sensors.conf files for specific motherboards? I would suggest that the output of "LSHW" or a similar utility is used to obtain unique identifying details for the motherboard, and then this used to determine the appropriate motherboard conf file. A simple web page with known motherboards on it and their associated .conf would be a very good start. New motherboards could then be added by people with their matching .conf file.
Thanks,
Roger
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 06 November 2005 16:00
To: Roger Lucas
Cc: LM Sensors; Knut Petersen
Subject: Re: [lm-sensors] RE: vt8231.c
Hi Roger,
Quoted 2 lines
Updated patch attached. I love it when you inherit loads of code that you end up fixing... :-)
I finished reviewing your code (at last! sorry for the delay), here we go.
First of all, please delete all trailing whitespace in vt8231.c. There are a lot of these.
And a generic comment: I *know* that some of the problems here are not yours, they come from the original driver. Don't take it personally ;) but we need to fix them all before the driver can be accepted in Linux 2.6.
Quoted 1 line
diff -Naur reference/drivers/hwmon/Kconfig
linux-2.6.14/drivers/hwmon/Kconfig
drivers/hwmon/Kconfig
Quoted 2 lines
drivers/hwmon/Kconfig +0
-0
17:35:18.000000000 +0000
drivers/hwmon/Kconfig line 359
Quoted 11 lines
drivers/hwmon/Kconfig +7
-0@@ -350,6 +350,18 @@ This driver can also be built as a module. If so, the module will be called via686a. +config SENSORS_VT8231 + tristate "VT8231" + depends on HWMON && I2C && PCI && EXPERIMENTAL + select HWMON_VID + select I2C_ISA + help + If you say yes here then you get support for the integrated
sensors
drivers/hwmon/Kconfig line 360
Quoted 1 line
drivers/hwmon/Kconfig +1
-0+ in the Via VT8231 device.
VIA should never be spelled Via.
Quoted 1 line
diff -Naur
reference/drivers/hwmon/vt8231.c
linux-2.6.14/drivers/hwmon/vt8231.c
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +0
-0
18:06:17.000000000 +0000
drivers/hwmon/vt8231.c line 3
Quoted 4 lines
drivers/hwmon/vt8231.c +3
-0@@ -0,0 +1,785 @@ +static int force_addr; +module_param (force_addr, int,0644 ); +MODULE_PARM_DESC(force_addr, "Initialize the base address of the
sensors");
The "0644" doesn't make sense. It means that a sysfs file will be created for this parameter. Given that the parameter is only needed at initialization time, the created file will be of no use. Use "0" to not create a file.
Also, missing space before comma.
drivers/hwmon/vt8231.c line 8
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+/* pwm numbered 1-2 */ +#define VT8231_REG_PWM (nr) (0x5f + (nr)) +#define VT8231_REG_PWM_CTL 0x51 + +/* The VT8231 registers */
You could move the PWM register definitions below, else that comment is somewhat confusing.
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+/* We define the sensors as follows. Somewhat convoluted to minimize +changes from via686a. +Sensor Voltage Mode Temp Mode +-------- ------------ ---------
drivers/hwmon/vt8231.c line 22
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+Reading 1 temp3 +Reading 3 temp1 not in vt8231 +UCH1/Reading2 in0 temp2 +UCH2 in1 temp4 +UCH3 in2 temp5 +UCH4 in3 temp6 +UCH5 in4 temp7 +3.3V in5 +-12V in6 not in vt8231 +*/
What is the benefit in mentioning the inputs which the VT8231 does not have?
It's a bit confusing (and non-standard) to have temperatures starting at temp2 :(
drivers/hwmon/vt8231.c line 27
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+static const u8 regtemp[] = {0x20 ,0x21 ,0x1f ,0x22 ,0x23 ,0x24 ,0x25 }; +static const u8 regover[] = {0x39 ,0x3d ,0x1d ,0x2b ,0x2d ,0x2f ,0x31 }; +static const u8 reghyst[] = {0x3a ,0x3e ,0x1e ,0x2c ,0x2e ,0x30 ,0x32 }; + +/* temps numbered 1-7 */
So that would be 2-7. This suggests that the first "column" in the above arrays is never used, so it should be deleted.
drivers/hwmon/vt8231.c line 28
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define ALARMS_FROM_REG (val) (val)
Please discard that macro and use the value directly instead.
drivers/hwmon/vt8231.c line 29
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define DIV_TO_REG (val) ((val)=8?3:(val)=4?2:(val)=1?0:1)
In Linux 2.6 we have changed to a different strategy. Instead of defaulting to an arbitrary divider value when an unsupported value is requested, we report the error to userspace. See the various other Linux 2.6 drivers for examples.
drivers/hwmon/vt8231.c line 30
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define PWM_FROM_REG (val) (val)
You can drop that one too.
drivers/hwmon/vt8231.c line 31
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+#define PWM_TO_REG (val) SENSORS_LIMIT((val), 0, 255)
For this one too, it is advisable to return an error on invalid values. See it87.c for an example.
drivers/hwmon/vt8231.c line 35
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+#define TEMP_FROM_REG (val) (long)((val)*10) +#define TEMP_FROM_REG10 (val) (long)(((val)*10)/4) +#define TEMP_TO_REG (val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\ + ((val)+5)/10), 0, 255))
These do not look correct to me. They suggest that you are exporting the values to userspace with LSB = 0.1 degree C. The standard is 0.001 degree C, as documented in Documentation/hwmon/sysfs-interface. I am surprised that you got correct temperature readings, unless you also hacked libsensors.
Looking further in sensors.conf.eg, it looks like the VT8231 expresses each temperature as a voltage, which libsensors then converts to a temperature. This is a rare, but not unique, case. The pc87360 driver does something similar for temp4-6. In this case, the value must be exported in sysfs with LSB = 1 mV, as voltages do.
Even then, the formulas in sensors.conf.eg look very complex to me. We will have to look into that and make some sense out of them
drivers/hwmon/vt8231.c line 37
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+#define IN_FROM_REG (val) ((long)(val)) +#define IN_TO_REG (val) (SENSORS_LIMIT((((val) * 10 + 5)/10), 0, 255))
Voltage values must be exported to userspace with LSB = 1 mV, this is a standard. This doesn't seem to be the case here. IN_TO_REG is also
nonsensical: you multiply by 10, then immediately divide the result by 10?
Seeing the conversion formulas in sensors.conf.eg, I think I understand that the VT8231 differs much from the other chips. Most of the conversion formula (the common part) should be moved inside the driver if we want to respect the sysfs standard. This will break the compatibility between the 2.4 and the 2.6 vt8231 drivers, but we don't seem to have the choice.
drivers/hwmon/vt8231.c line 41
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+static inline int vt8231_read_value (struct i2c_client *client,u8 reg) +{ +return (inb_p (client->addr + reg)); +}
Please drop the redundant parentheses.
drivers/hwmon/vt8231.c line 42
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+/* following are the sysfs callback functions */
Generic comment about sysfs callback functions:
A new possibility, known as "dynamic sysfs callbacks", was recently introduced. Not all hardware monitoring drivers use it yet, but I would like new drivers to do, so that we don't have to convert them later.
These dynamic callbacks let you get rid of a large part of the macros above, by giving you the possibility to pass an integer parameter to the callback functions, making it possible to use the same callback function for several sysfs files.
See the it87 driver for an example. If would be very great if you could convert the vt8231 driver to do the same. This greatly improves the code readability, and makes the compiled object significantly smaller as well.
drivers/hwmon/vt8231.c line 52
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+static ssize_t set_in_min (struct device *dev,const char *buf, +size_t count,int nr) { +struct i2c_client *client =to_i2c_client (dev); +struct vt8231_data *data =i2c_get_clientdata (client); +unsigned long val =simple_strtoul (buf,NULL ,10 ); + data->in_min[nr] =IN_TO_REG (val); +vt8231_write_value (client,VT8231_REG_IN_MIN (nr), + data->in_min[nr]); +return count; +}
All "set" callback functions should hold data->update_lock while they manipulate any data field. If not, you have a race condition if another sysfs file is being read (triggering an update) while you write to this one.
See any other hwmon files for an example, it's really easy.
drivers/hwmon/vt8231.c line 53
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+/* show_temp_offset(1); */
Delete that line, no point in keeping comments about something which doesn't exist.
drivers/hwmon/vt8231.c line 55
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+/**** VRM and VID *****/ +static ssize_t show_vid(struct device *dev, struct device_attribute
*attr,
drivers/hwmon/vt8231.c line 58
Quoted 3 lines
drivers/hwmon/vt8231.c +3
-0+ char *buf) { + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%ld\n", (long)vid_from_reg(data->cpu0_vid,
data->vrm));
drivers/hwmon/vt8231.c line 59
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+}
The (long) cast is not needed, simply use %d instead of %ld.
drivers/hwmon/vt8231.c line 62
Quoted 3 lines
drivers/hwmon/vt8231.c +3
-0+static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); + +static ssize_t show_vrm(struct device *dev, struct device_attribute
*attr,
drivers/hwmon/vt8231.c line 66
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+ char *buf) { +struct vt8231_data *data =vt8231_update_device (dev); +return sprintf (buf,"%ld\n" , (long )data->vrm); +}
Same here.
drivers/hwmon/vt8231.c
Quoted 10 lines
drivers/hwmon/vt8231.c +9
-0+static ssize_t set_vrm (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) { +struct i2c_client *client =to_i2c_client (dev); +struct vt8231_data *data =i2c_get_clientdata (client); +int val =simple_strtol (buf,NULL ,10 ); +printk ("Setting VRM to \"%s\" = %d\n" , buf, val); + data->vrm = val; +return count; +}
Drop that printk, it's pretty useless.
drivers/hwmon/vt8231.c
Quoted 9 lines
drivers/hwmon/vt8231.c +8
-0+int vt8231_detect (struct i2c_adapter *adapter) +{ +/* Reserve the ISA region */ +if (!request_region (isa_address,VT8231_EXTENT , type_name)) { +dev_err (&adapter->dev,"region 0x%x already in use!\n" , + isa_address); +return -ENODEV ; + }
Please use vt8231_pci_driver.name to reserve the region (you'll need to forward-declare it).
drivers/hwmon/vt8231.c
Quoted 7 lines
drivers/hwmon/vt8231.c +6
-0+if (!(data =kzalloc (sizeof (struct vt8231_data ),GFP_KERNEL ))) { + err = -ENOMEM ; + goto exit_release; + } + + new_client->flags =0 ;
I don't think you need to explicitely set it to 0, as kzalloc did it for you. We'd need to fix all other drivers too.
drivers/hwmon/vt8231.c
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+/* Fill in the remaining client fields and put into the global list
*/
drivers/hwmon/vt8231.c
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+strlcpy (new_client->name, type_name,I2C_NAME_SIZE );
As this is now the only usage of type_name, you'd better put the string verbatim here.
You forgot to create sysfs files for PWM?
drivers/hwmon/vt8231.c
Quoted 8 lines
drivers/hwmon/vt8231.c +7
-0+static int vt8231_detach_client (struct i2c_client *client) +{ +if ((err =i2c_detach_client (client))) { +dev_err (&client->dev, +"Client deregistration failed, client not detached.\n" ); +return err; + }
Please drop the log message, it was refactored into i2c_detach_client some times ago.
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+release_region (client->addr,VT8231_EXTENT ); +kfree (i2c_get_clientdata (client));
You can user "data" instead.
drivers/hwmon/vt8231.c
Quoted 10 lines
drivers/hwmon/vt8231.c +10
-0+static struct vt8231_data *vt8231_update_device (struct device *dev) +{ +struct i2c_client *client =to_i2c_client (dev); +struct vt8231_data *data =i2c_get_clientdata (client); +int i, j; + +down (&data->update_lock); + +if ((jiffies - data->last_updated >HZ +HZ /2 ) || + (jiffies < data->last_updated) || !data->valid) {
Use time_after() instead of direct jiffies comparisons.
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+ data->uch_config =vt8231_read_value (client, +VT8231_REG_UCH_CONFIG );
I now realize that there is no sysfs file to change this value. I'm fine with that, as I believe this is the BIOS' job to properly configure the chip. However, we should then be consistent and modify the other parts of the driver accordingly. In particular, the driver should not create the sysfs files for the channels which are not in use. That way, the code below wouldn't have to repeatedly set unused values to 0.
drivers/hwmon/vt8231.c
Quoted 6 lines
drivers/hwmon/vt8231.c +6
-0+for (i =0 ; i <=5 ; i++) { +if (ISVOLT (i, data->uch_config)) { + data->in[i] =vt8231_read_value (client, +VT8231_REG_IN (i)); + data->in_min[i] = vt8231_read_value(client, +
VT8231_REG_IN_MIN(i));
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+ data->in_max[i] = vt8231_read_value(client, +
VT8231_REG_IN_MAX(i));
drivers/hwmon/vt8231.c
Quoted 6 lines
drivers/hwmon/vt8231.c +6
-0+ }else { + data->in[i] =0 ; + data->in_min[i] =0 ; + data->in_max[i] =0 ; + } + }
I'd have a clear preference for "< 6" instead of <=5.
drivers/hwmon/vt8231.c
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+for (i =2 ; i <=7 ; i++) { +if (ISTEMP (i, data->uch_config)) { + data->temp[i - 1] vt8231_read_value(client, +VT8231_REG_TEMP (i))
<< 2;
drivers/hwmon/vt8231.c
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+switch (i) { +case 1 : +/* ? */ + j =0 ; +break ;
This case can obviously be dropped.
drivers/hwmon/vt8231.c
Quoted 3 lines
drivers/hwmon/vt8231.c +3
-0+case 2 : + j (vt8231_read_value(client, +
VT8231_REG_TEMP_LOW2) &
drivers/hwmon/vt8231.c
Quoted 5 lines
drivers/hwmon/vt8231.c +5
-0+ 0x30) >> 4; +break ; +case 3 : + j (vt8231_read_value(client, +
VT8231_REG_TEMP_LOW3) &
drivers/hwmon/vt8231.c
Quoted 7 lines
drivers/hwmon/vt8231.c +7
-0+ 0xc0) >> 6; +break ; +case 4 : +case 5 : +case 6 : +case 7 : +default :
Either keep only default, or drop it.
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+ j (vt8231_read_value(client, +
VT8231_REG_TEMP_LOW47)
drivers/hwmon/vt8231.c
Quoted 1 line
drivers/hwmon/vt8231.c +1
-0+ >> ((i-4)*2)) &
0x03;
drivers/hwmon/vt8231.c
Quoted 12 lines
drivers/hwmon/vt8231.c +11
-0+break ; + + } +for (i =1 ; i <=2 ; i++) { + data->fan[i -1 ] =vt8231_read_value (client, +VT8231_REG_FAN (i)); + data->fan_min[i -1 ] =vt8231_read_value (client, +VT8231_REG_FAN_MIN (i)); + data->pwm[i -1 ] =vt8231_read_value (client, +VT8231_REG_PWM (i)); + }
I don't get it. We already read the fan registers earlier in this function!
drivers/hwmon/vt8231.c
Quoted 2 lines
drivers/hwmon/vt8231.c +2
-0+ data->cpu0_vid=vt8231_read_value (client,VT8231_REG_VID ) + &0x1f ;
Missing space before "=" sign.
drivers/hwmon/vt8231.c
Quoted 9 lines
drivers/hwmon/vt8231.c +9
-0+static struct pci_device_id vt8231_pci_ids[] = { + { + .vendor =PCI_VENDOR_ID_VIA , + .device =PCI_DEVICE_ID_VIA_8231_4 , + .subvendor =PCI_ANY_ID , + .subdevice =PCI_ANY_ID , + }, + {0 , } +};
Please use the PCI_DEVICE macro. Also add a call to MODULE_DEVICE_TABLE (see via686a).
drivers/hwmon/vt8231.c
Quoted 6 lines
drivers/hwmon/vt8231.c +5
-0+static int __devinit vt8231_pci_probe (struct pci_dev *dev, +const struct pci_device_id *id) +{ +if (force_addr) + isa_address = force_addr;/* so detect will get called */
No more needed, detect will get called anyway.
drivers/hwmon/vt8231.c
Quoted 4 lines
drivers/hwmon/vt8231.c +4
-0+if (!isa_address) { +dev_err (&dev->dev,"No Via 8231 sensors found.\n" ); +return -ENODEV ; + }
Drop that test, it was previously unneeded if you read the code carefully, and now it is a bug.
drivers/hwmon/vt8231.c
Quoted 11 lines
drivers/hwmon/vt8231.c +11
-0+static void __exit sm_vt8231_exit(void) +{ +pci_unregister_driver (&vt8231_pci_driver); +if (s_bridge !=NULL ) { +i2c_isa_del_driver (&vt8231_driver); +pci_dev_put (s_bridge); + s_bridge =NULL ; + } +} + +
Drop the second blank line.
"Other than that, it's OK" as I use to say ;)
Yeah, I know there are many many fixes needed. But nothing impossible if you are motivated enough. And if you have questions we're here to answer them.
I now answer your other questions:
Quoted 3 lines
I am not so sure I am very keen on the intelligence for the auto-div calculation moving into the driver. I think this code should be in the sensors utility.
There was a debate long ago about this. Some people (at least Mark M. Hoffman) advocated a user-space solution. I tend to agree in general that putting policy into the kernel is bad, and also about the fact that drivers must be as simple as possible. However, after checking the facts, I came to the conclusion that doing this in the kernel was OK. The main reason is that a user-space helper would need to know many things which the drivers do not currently export: the list of divider for each fan input, either the clock frequency, the register width. Additionally, letting userspace change the divider means that the driver needs additional code to preserve the min limit when this happens. As I found I'd need more code to do all this than the in-driver auto-fan-div takes, I decided for that second option.
Anyway, not all drivers do that. Those which do use slightly different rules. It's not all settled yet. If anyone provides a userspace daemon and modifies some drivers so that we can see how the userspace approach would work, that's fine with me.
Quoted 1 line
On the other hand, however, the way the
DIV_TO_REG()function was coded,
it
Quoted 1 line
would be almost impossible for any application to determine the legal
values
Quoted 1 line
for DIV without knowing the details of the device. Any illegal value
would
Quoted 1 line
end up with DIV set at zero - not very helpful.
The old code defaulted to a divider of 2 actually. But see my comments in the code above, 2.6 does things differently.
Quoted 2 lines
As an alternative, this
attached patch includes a code revision that sets DIV to the smallest
legal
Quoted 13 lines
DIV value that is the same as or larger than the requested DIV value. Hence, the mapping is as below:
Requested DIV Set DIV 1 1 2 2 3 4 4 4 5 8 6 8 7 8 8 8 8+ 8
I prefer an explicit -EINVAL with no divider change on invalid value, as all drivers in 2.6 now tend to do.
Quoted 6 lines
From this sequence, the DIV returned is predictable and an application can very quickly determine the legal DIV values and make its calculations accordingly.
With this revised code, if you ask for a low limit 1000 RPM with a divisor of 4, you get a low limit of 1285 RPM returned. If you ask for a low
limit
Quoted 1 line
of 1000 RPM with a divisor of 5 then you get a low limit of 999 RPM
returned
Quoted 1 line
with a divisor of 8.
The div returned is not predictable. Some chips have dividers up to
128. Some chips (it87) have different rules for the different channels (fan3 only has possible dividers 2 and 8). Unless the chip explicitely lists the possible dividers, there is no possible auto-div implementation in user-space. We are *not* going to set random div values and see if it works. This would generate actual register writes and execute a lot of code. Let's not probe for something we already have the knowledge of and simply needs to be exported.
Also, the only thing all chips share is the fact that the dividers are powers of 2. So it's pretty pointless to try to support other inputs from user-space. Nobody sane will try them.
Quoted 19 lines
Consider the pseudo-code below:
set_div= 1;set_rpm_div(set_div);set_low_limit_rpm(requested_limit_rpm);
while( get_low_limit_rpm() > requested_limit_rpm ){ true_div = get_rpm_div(); if (set_div > true_div) { break; // we have exceeded the DIV range } // Try next div value set_div = true_div + 1; set_rpm_div(set_div); set_low_limit_rpm(requested_limit_rpm); }
Quoted 1 line
This will iterate through the valid DIV values and stop when it reaches
the
Quoted 1 line
best RPM match or the highest valid DIV setting.
Sorry, I can't make any sense of this pseudo code. What part is in user space? What part is in the driver? "set_low_limit_rpm" can mean about anything. It can be in userspace (sensors, libsensors), it can be a request to the driver, it can be a register write.
If you want to propose something, please explain it with words.
Quoted 2 lines
I feel that this should be up in the application, however, and not in the driver. IMHO, the drivers should be a simple as possible.
As said above, I usually tend to agree, but in the facts, in this one case, the code is much more simple and efficient when in the drivers.
It would probably make sense to have a helper module for all drivers though, so as to not duplicate the code.
Thanks,
Signature · 1 line
Jean Delvare
Hi Roger,
Quoted 12 lines · Roger Lucas
One question I have is regarding the "1 mV" calibration, and this returns me to a general comment/question with the LM-Sensors system:
The LM-Sensors system appears to be based on what the sensors chips are on the motherboard, rather than what the motherboard is. From the "probe and find out what I have" concept, this is reasonable, but it does cause a LOT of problems for users who are less educated. Many of the sensors devices are wired up in different ways on different motherboards, with (for example) a voltage input being used for a 12v rail monitor on one motherboard and a 5v rail monitor on another. The motherboard manufacturer is completely at liberty to wire a device in any way they choose.
Completely true.
Quoted 6 lines
This therefore makes a sensors.conf file really a motherboard-specific rather than a device specific file. If you use the configuration file according to the device that you have, rather than the motherboard that you have, then you run a very high risk of reporting nonsense to a user, or (arguably worse) reporting information that looks correct but is actually wrong.
True again.
Keep in mind that the folks originally running the project were passionates with good electronics knowledge. Back then, most users also had the same profile. This explains a number of technical choices which turned out not to be suitable for average users. In a way, the project is the victim of its own success. It is also victim of the increase of the number of hardware monitoring chips and the exponential growth of the number of motherboard, each with its own specifics.
We're trying to fix these issues as time permits (e.g. the drivers do no more set arbitrary limits, and they tend not to reset chips anymore) but there's still a lot left to do.
Quoted 7 lines
Following this through, when you request that the driver report the voltage detected in mV, I am _hoping_ that you are asking for the voltage at the pin of the device, rather than the voltage that the device happens to be ultimately connected to on this particular motherboard? Reporting the voltage at the device pin is the only consistent behaviour that I can see for a motherboard-independent device driver.
Yes, of course. Drivers are written for chips. All the rest belongs to userspace (libsensors or whatever).
Quoted 3 lines
If the above makes sense, then would there be any interest in building some kind of database of known good sensors.conf files for specific motherboards?
There have been 472 people complaining of the lack of such a database already. A dozen of these said they would build one. Two of these actually did. One is already dead, one is available at
http://lm-sensors-db.berlios.de/ but doesn't actually work.
We rejected the idea that we would include the configuration files one by one in the lm_sensors project as people send them, because it would be too much work. An external, web-based system where people could post and retrieve their configuration files would be prefered. But we are still in need of one which would work.
It might be discussed what to do with the sensors.conf.eg file. It started as a small file when there were only a couple supported chips, and motherboard manufacturers were following the chip maker's recommendations on wiring. Now the file is quite large, and has lots of conditionals (expressed as comments) to try and help users to get a working configuration file. according to their hardware. I agree that it isn't suitable for the average user.
Maybe we should stop installing this file to /etc/sensors.conf automatically. As you say, It's probably better not to have a configuration file than to have a bad one. However, this still a good base for people to start tinkering, so we probably can't get rid of it unless we actually have a database with configuration files for the most popular boards.
Quoted 6 lines
I would suggest that the output of "LSHW" or a similar utility is used to obtain unique identifying details for the motherboard, and then this used to determine the appropriate motherboard conf file. A simple web page with known motherboards on it and their associated .conf would be a very good start. New motherboards could then be added by people with their matching .conf file.
We would probably use the DMI fields for board identification (using dmidecode, which is more standard than lshw I think). However, the difficult part is to gather the data. What you call "a simple web page" won't work. We want something the average user can freely contribute to, with a minimum maintenance workload from us. Briefly:
* Any user can add a configuration file. He/she must pick from a list of motherboard makers, or add one if his/her aint in the list. Then he/she types the name of his/her motherboard and uploads his file. Ideally we would do a brief content check to make sure nobody uploads crap.
* Any user can update (overwrite) a configuration file. We probably need to backup older files just in case though.
* We need an administration interface to fix about anything (manufacturer or board name, broken configuration statements) and even delete files if needed.
* Users should have the possibility to alert us if they think something is wrong.
* Not sure how to deal with duplicates. We probably want one single configuration file per board, but it might be hard to enforce.
Note that there still is a problem with the fact that not all users of the same board will use the same fans, so fan limits (and, to some extent, temperature limits) depend on the user. The configuration files are still templates. If we want to ultimately install them automatically, we will probably need to enforce the fact that configuration files should not set limits for fans and temperatures, nor ignore statements for fans. These configuration files should essentially contain label and compute statements.
This ain't simple, else this would have been done already. But if you want to work on this (preferably *after* we are done with the vt8231 port ;)) you're very welcome.
--
Jean Delvare
Hi Jean,
Attached is revision 3 of the VT8231 driver. There are a LOT of changes to implement your suggestions. Some of these break compatibility with older vt8231 driver releases as follows:
tempX sequence
Temperatures are now measured temp0,temp1,temp2,etc. This causes the "sensors" user-space program to fail with errors as it expects the older temperature numbering sequence.
tempX scaling
Given that we have no idea what the temperature curves for a device are, the driver now returns the 10-bit value directly from the register. Older versions of the driver multiplied the register value by 2.5 (reason unknown as it DEFINITELY didn't scale it to degrees Centigrade, Fahrenheit or Kelvin). Older temperature scaling calculations are now completely wrong.
inX scaling
The driver now scales the measurement to mV. Inputs such as the 3.3v internal reference are now completely correct. Inputs such as IN0-IN5 which report an external pin now return the value at the pin. SENSORS.CONF still has to scale these to compensate for external divider chains (if, for example, the 12v rail is being measured).
tempX/inX presence
The driver only generates measurements for inputs that are genuinely measured (according to the CONFIG register). This causes the "sensors" program to fail as it expects to see all the tempX and inX sources available, even if you add "ignore xxx" to the sensors.conf file. IMHO this is a bug in the "sensors" program, as "ignore xxx" should cause it to fully ignore that parameter, not still generate warnings if the parameter doesn't exist.
PWM controls
The VT8231 doesn't have any PWM controls. All the code that was in the driver was erroneous and has been removed (I suspect it was legacy from some other driver used as the base for an earlier port).
If the newer vt8231 driver is accepted into the kernel tree, would you like me to go through v2.9.2 of lm_sensors and try to see what can be done to resolve the compatibilities issues with this newer vt8231 driver?
As far as the web site for the sensors.conf file is concerned, I have no time to do this in the near-term. If I get some spare time in the future, and no-one has done it by then, I will look into it further.
Best regards,
Roger
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 07 November 2005 09:24
To: [email protected]
Cc: Knut Petersen; LM Sensors
Subject: RE: [lm-sensors] RE: vt8231.c
Hi Roger,
Quoted 12 lines · Roger Lucas
One question I have is regarding the "1 mV" calibration, and this returns me to a general comment/question with the LM-Sensors system:
The LM-Sensors system appears to be based on what the sensors chips are on the motherboard, rather than what the motherboard is. From the "probe and find out what I have" concept, this is reasonable, but it does cause a LOT of problems for users who are less educated. Many of the sensors devices are wired up in different ways on different motherboards, with (for example) a voltage input being used for a 12v rail monitor on one motherboard and a 5v rail monitor on another. The motherboard manufacturer is completely at liberty to wire a device in any way they choose.
Completely true.
Quoted 6 lines
This therefore makes a sensors.conf file really a motherboard-specific rather than a device specific file. If you use the configuration file according to the device that you have, rather than the motherboard that you have, then you run a very high risk of reporting nonsense to a user, or (arguably worse) reporting information that looks correct but is actually wrong.
True again.
Keep in mind that the folks originally running the project were passionates with good electronics knowledge. Back then, most users also had the same profile. This explains a number of technical choices which turned out not to be suitable for average users. In a way, the project is the victim of its own success. It is also victim of the increase of the number of hardware monitoring chips and the exponential growth of the number of motherboard, each with its own specifics.
We're trying to fix these issues as time permits (e.g. the drivers do no more set arbitrary limits, and they tend not to reset chips anymore) but there's still a lot left to do.
Quoted 7 lines
Following this through, when you request that the driver report the voltage detected in mV, I am _hoping_ that you are asking for the voltage at the pin of the device, rather than the voltage that the device happens to be ultimately connected to on this particular motherboard? Reporting the voltage at the device pin is the only consistent behaviour that I can see for a motherboard-independent device driver.
Yes, of course. Drivers are written for chips. All the rest belongs to userspace (libsensors or whatever).
Quoted 3 lines
If the above makes sense, then would there be any interest in building some kind of database of known good sensors.conf files for specific motherboards?
There have been 472 people complaining of the lack of such a database already. A dozen of these said they would build one. Two of these actually did. One is already dead, one is available at
http://lm-sensors-db.berlios.de/ but doesn't actually work.
We rejected the idea that we would include the configuration files one by one in the lm_sensors project as people send them, because it would be too much work. An external, web-based system where people could post and retrieve their configuration files would be prefered. But we are still in need of one which would work.
It might be discussed what to do with the sensors.conf.eg file. It started as a small file when there were only a couple supported chips, and motherboard manufacturers were following the chip maker's recommendations on wiring. Now the file is quite large, and has lots of conditionals (expressed as comments) to try and help users to get a working configuration file. according to their hardware. I agree that it isn't suitable for the average user.
Maybe we should stop installing this file to /etc/sensors.conf automatically. As you say, It's probably better not to have a configuration file than to have a bad one. However, this still a good base for people to start tinkering, so we probably can't get rid of it unless we actually have a database with configuration files for the most popular boards.
Quoted 6 lines
I would suggest that the output of "LSHW" or a similar utility is used to obtain unique identifying details for the motherboard, and then this used to determine the appropriate motherboard conf file. A simple web page with known motherboards on it and their associated .conf would be a very good start. New motherboards could then be added by people with their matching .conf file.
We would probably use the DMI fields for board identification (using dmidecode, which is more standard than lshw I think). However, the difficult part is to gather the data. What you call "a simple web page" won't work. We want something the average user can freely contribute to, with a minimum maintenance workload from us. Briefly:
* Any user can add a configuration file. He/she must pick from a list of motherboard makers, or add one if his/her aint in the list. Then he/she types the name of his/her motherboard and uploads his file. Ideally we would do a brief content check to make sure nobody uploads crap.
* Any user can update (overwrite) a configuration file. We probably need to backup older files just in case though.
* We need an administration interface to fix about anything (manufacturer or board name, broken configuration statements) and even delete files if needed.
* Users should have the possibility to alert us if they think something is wrong.
* Not sure how to deal with duplicates. We probably want one single configuration file per board, but it might be hard to enforce.
Note that there still is a problem with the fact that not all users of the same board will use the same fans, so fan limits (and, to some extent, temperature limits) depend on the user. The configuration files are still templates. If we want to ultimately install them automatically, we will probably need to enforce the fact that configuration files should not set limits for fans and temperatures, nor ignore statements for fans. These configuration files should essentially contain label and compute statements.
This ain't simple, else this would have been done already. But if you want to work on this (preferably *after* we are done with the vt8231 port ;)) you're very welcome.
--
Jean Delvare
-------------- next part --------------
drivers/hwmon/Kconfig +12 -0
@@ -350,6 +350,18 @@ This driver can also be built as a module. If so, the module will be called via686a. +config SENSORS_VT8231 + tristate "VT8231" + depends on HWMON && I2C && PCI && EXPERIMENTAL + select HWMON_VID + select I2C_ISA + help + If you say yes here then you get support for the integrated sensors + in the VIA VT8231 device. + + This driver can also be built as a module. If so, the module + will be called vt8231. + config SENSORS_W83781D tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" depends on HWMON && I2C
drivers/hwmon/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o +obj-$(CONFIG_SENSORS_VT8231) += vt8231.o obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
drivers/hwmon/vt8231.c +829 -0
829 lines not on this page · raw message
Hi Roger,
Quoted 3 lines · Roger Lucas
Attached is revision 3 of the VT8231 driver. There are a LOT of changes to implement your suggestions. Some of these break compatibility with older vt8231 driver releases as follows:
I'll not review that code as you have posted r4 since, but I still would like to answer the various points you make.
Quoted 4 lines
tempX sequence
Temperatures are now measured temp0,temp1,temp2,etc. This causes the "sensors" user-space program to fail with errors as it expects the older temperature numbering sequence.
No. As per Documentation/hwmon/sysfs-interface, temperature numbering starts at 1. You can't use temp0.
I would usually object to renumbering because it breaks comptibility with the 2.4 driver and libsensors, but it starts being obvious that we will have to break compatibility anyway, and the 2.4 driver (and libsensors/sensors) will need a significant rework, so it's probably no more a problem.
Quoted 7 lines
tempX scaling
Given that we have no idea what the temperature curves for a device are, the driver now returns the 10-bit value directly from the register. Older versions of the driver multiplied the register value by 2.5 (reason unknown as it DEFINITELY didn't scale it to degrees Centigrade, Fahrenheit or Kelvin). Older temperature scaling calculations are now completely wrong.
We know how temperature scaling works, see the BIOS porting guide document and sensors.conf.eg. This chip is quite different from other ones and needs additional conputations.
temp3 is a bit special, it is diode-based. The conversion which is currently done in userspace should be moved into the driver, so that the exported value is a temperature rather than a random register value. Other temps are thermistor based, a part of the conversion has to be moved into the driver so that we export the voltage value at the chip pin. The thermistor bridge computation (voltag -> temperature) belongs to userspace because different thermistors can be used on different motherboards. The same is done for the PC87366 temp4-6 already.
Quoted 6 lines
inX scaling
The driver now scales the measurement to mV. Inputs such as the 3.3v internal reference are now completely correct. Inputs such as IN0-IN5 which report an external pin now return the value at the pin. SENSORS.CONF still has to scale these to compensate for external divider chains (if, for example, the 12v rail is being measured).
Correct, that's exactly what we want.
Quoted 3 lines
tempX/inX presence
The driver only generates measurements for inputs that are genuinely measured (according to the CONFIG register).
This sounds good to me. If anyone later complains that he/she needs to be able to change the configuration, we'll see at that time. The BIOS should configure it properly for us, so I would consider it a BIOS bug, but...
Quoted 5 lines
This causes the "sensors" program to fail as it expects to see all the tempX and inX sources available, even if you add "ignore xxx" to the sensors.conf file. IMHO this is a bug in the "sensors" program, as "ignore xxx" should cause it to fully ignore that parameter, not still generate warnings if the parameter doesn't exist.
Not sure if it is a bug or a design issue. I never took the time to investigate this. If you have some time, please do. In the meantime, we usually drop the printed complaint in sensors for all inputs which may not exist in 2.6 drivers. It's kind of a hack (we could miss real errors), but works.
Quoted 4 lines
PWM controls
The VT8231 doesn't have any PWM controls. All the code that was in the driver was erroneous and has been removed (I suspect it was legacy from some other driver used as the base for an earlier port).
Ugh. True, I don't see anything related to PWM in the VT8231 datasheet. Mark, can you please comment on this? Undocumented registers which worked for you? Or dead code inherited from the vt1211 or via686a drivers? Let's clean up whatever can be.
Quoted 4 lines
If the newer vt8231 driver is accepted into the kernel tree, would you like me to go through v2.9.2 of
lm_sensorsand try to see what can be done to resolve the compatibilities issues with this newer vt8231 driver?
Yes, this would be very very welcome. I never feel confident when I have to do that myself for drivers I can't test. If you can test the changes, that's different, we can (and will have to) cleanup the 2.4 vt8231 driver.
Thanks,
--
Jean Delvare
Hi Jean,
Please see my comments below.
- Roger
Quoted 18 lines
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 09 November 2005 11:50
To: [email protected]
Cc: Knut Petersen; LM Sensors; Mark Studebaker
Subject: RE: [lm-sensors] RE:vt8231.cHi Roger,
Quoted 3 lines · Roger Lucas
Attached is revision 3 of the VT8231 driver. There are a LOT of changes to implement your suggestions. Some of these break compatibility with older vt8231 driver releases as follows:
I'll not review that code as you have posted r4 since, but I still would like to answer the various points you make.
Quoted 7 lines
Quoted 4 lines
tempX sequence
Temperatures are now measured temp0,temp1,temp2,etc. This causes the "sensors" user-space program to fail with errors as it expects the older temperature numbering sequence.No. As per
Documentation/hwmon/sysfs-interface, temperature numbering starts at 1. You can't use temp0.
No problem. Renumbering them is easy.
Quoted 21 lines
I would usually object to renumbering because it breaks comptibility with the 2.4 driver and libsensors, but it starts being obvious that we will have to break compatibility anyway, and the 2.4 driver (and libsensors/sensors) will need a significant rework, so it's probably no more a problem.
Quoted 4 lines
tempX scaling
Given that we have no idea what the temperature curves for a device are, the driver now returns the 10-bit value directly from the register. Older versions of the driver multiplied the register value by 2.5(reason
Quoted 1 line
unknown as it DEFINITELY didn't scale it to degrees Centigrade,
Fahrenheit
Quoted 2 lines
or Kelvin). Older temperature scaling calculations are now completely wrong.
We know how temperature scaling works, see the BIOS porting guide document and sensors.conf.eg. This chip is quite different from other ones and needs additional conputations.
Quoted 8 lines
temp3 is a bit special, it is diode-based. The conversion which is currently done in userspace should be moved into the driver, so that the exported value is a temperature rather than a random register value. Other temps are thermistor based, a part of the conversion has to be moved into the driver so that we export the voltage value at the chip pin. The thermistor bridge computation (voltag -> temperature) belongs to userspace because different thermistors can be used on different motherboards. The same is done for the PC87366 temp4-6 already.
We know what the datasheet and porting guide say about the temperatures, but I am not sure that this matches reality. On my VIA EPIA 500 motherboard, the CPU is a VIA EPIA 5000 and not an Intel CPU. I don't doubt that the sensor scale is correct for an Intel CPU, but the VIA EPIA CPU is different. If I use the scaling values in the porting guide then my temperatures are over 30C off.
For reference,
VIA's equation: REG = TEMP * 0.9686 + 65 My EPIA Mobo: REG = TEMP * 0.7809 + 45
We can put the VIA official Intel scaling into the driver, but this would be very misleading as the VT8231 is used on the VIA EPIA platform which is in widespread use, and all users of that board would therefore need to know that additional scaling was required. If they didn't then they would be panicking when they see the CPU temperature (since the motherboard is only passively cooled).
I'm happy putting in the appropriate voltage scaling for the other temps into the driver, but I have no way to test it. We need to find someone else who has a VT8231 on a motherboard that uses external temperature sensors who can test it.
Quoted 46 lines
Quoted 7 lines
inX scaling
The driver now scales the measurement to mV. Inputs such as the 3.3v internal reference are now completely correct. Inputs such as IN0-IN5 which report an external pin now return the value at the pin. SENSORS.CONF still has to scale these to compensate for external divider chains (if, for example, the 12v rail is being measured).Correct, that's exactly what we want.
Quoted 3 lines
tempX/inX presence
The driver only generates measurements for inputs that are genuinely measured (according to the CONFIG register).This sounds good to me. If anyone later complains that he/she needs to be able to change the configuration, we'll see at that time. The BIOS should configure it properly for us, so I would consider it a BIOS bug, but...
Quoted 5 lines
This causes the "sensors" program to fail as it expects to see all the tempX and inX sources available, even if you add "ignore xxx" to the sensors.conf file. IMHO this is a bug in the "sensors" program, as "ignore xxx" should cause it to fully ignore that parameter, not still generate warnings if the parameter doesn't exist.
Not sure if it is a bug or a design issue. I never took the time to investigate this. If you have some time, please do. In the meantime, we usually drop the printed complaint in sensors for all inputs which may not exist in 2.6 drivers. It's kind of a hack (we could miss real errors), but works.
Quoted 4 lines
PWM controls
The VT8231 doesn't have any PWM controls. All the code that was in the driver was erroneous and has been removed (I suspect it was legacy from some other driver used as the base for an earlier port).Ugh. True, I don't see anything related to PWM in the VT8231 datasheet. Mark, can you please comment on this? Undocumented registers which worked for you? Or dead code inherited from the vt1211 or via686a drivers? Let's clean up whatever can be.
Quoted 4 lines
If the newer vt8231 driver is accepted into the kernel tree, would you like me to go through v2.9.2 of
lm_sensorsand try to see what can be done to resolve the compatibilities issues with this newer vt8231 driver?
Quoted 4 lines
Yes, this would be very very welcome. I never feel confident when I have to do that myself for drivers I can't test. If you can test the changes, that's different, we can (and will have to) cleanup the 2.4 vt8231 driver.
I'll see what time I get for this, but I suspect I won't get much in the immediate future.
Quoted 4 lines
Thanks,
--
Jean Delvare
Hi Roger,
Once again, sorry for the delay... :(
Quoted 16 lines
Quoted 8 lines
temp3 is a bit special, it is diode-based. The conversion which is currently done in userspace should be moved into the driver, so that the exported value is a temperature rather than a random register value. Other temps are thermistor based, a part of the conversion has to be moved into the driver so that we export the voltage value at the chip pin. The thermistor bridge computation (voltag -> temperature) belongs to userspace because different thermistors can be used on different motherboards. The same is done for the PC87366 temp4-6 already.
We know what the datasheet and porting guide say about the temperatures, but I am not sure that this matches reality. On my VIA EPIA 500 motherboard, the CPU is a VIA EPIA 5000 and not an Intel CPU. I don't doubt that the sensor scale is correct for an Intel CPU, but the VIA EPIA CPU is different. If I use the scaling values in the porting guide then my temperatures are over 30C off.
Quoted 3 lines
For reference,
VIA's equation: REG = TEMP * 0.9686 + 65 My EPIA Mobo: REG = TEMP * 0.7809 + 45
Good point. Do these constant have any kind of physical meaning? Is the information publicly available? How did you come up with the correct one for your VIA CPU?
What would the formula required for VIA CPUs look like if the Intel one was integrated into the driver as I first proposed?
Quoted 6 lines
We can put the VIA official Intel scaling into the driver, but this would be very misleading as the VT8231 is used on the VIA EPIA platform which is in widespread use, and all users of that board would therefore need to know that additional scaling was required. If they didn't then they would be panicking when they see the CPU temperature (since the motherboard is only passively cooled).
Well, whatever we do, the VIA CPU users will have an incorrect reading at first and will have to edit some lines in their configuration file to get the proper reading. So this point doesn't really weight in either direction. All it really means is that we will have to improve the vt8231's sensors.conf.eg section to make the point clear.
Thanks,
Signature · 1 line
Jean Delvare
Hi Jean,
Quoted 32 lines
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 15 November 2005 07:13
To: Roger Lucas
Cc: Knut Petersen; LM Sensors; Mark Studebaker
Subject: Re: [lm-sensors] RE:vt8231.cHi Roger,
Once again, sorry for the delay... :(
Quoted 2 lines
Quoted 2 lines
temp3 is a bit special, it is diode-based. The conversion which is currently done in userspace should be moved into the driver, so that
the
Quoted 8 lines
Quoted 6 lines
exported value is a temperature rather than a random register value. Other temps are thermistor based, a part of the conversion has to be moved into the driver so that we export the voltage value at the chip pin. The thermistor bridge computation (voltag -> temperature) belongs to userspace because different thermistors can be used on different motherboards. The same is done for the PC87366 temp4-6 already.
We know what the datasheet and porting guide say about the temperatures,
but
Quoted 1 line
I am not sure that this matches reality. On my VIA EPIA 500
motherboard,
Quoted 2 lines
the CPU is a VIA EPIA 5000 and not an Intel CPU. I don't doubt that the sensor scale is correct for an Intel CPU, but the VIA EPIA CPU is
different.
Quoted 1 line
If I use the scaling values in the porting guide then my temperatures
are
Quoted 2 lines
over 30C off.
Quoted 7 lines
Quoted 3 lines
For reference,
VIA's equation: REG = TEMP * 0.9686 + 65 My EPIA Mobo: REG = TEMP * 0.7809 + 45Good point. Do these constant have any kind of physical meaning? Is the information publicly available? How did you come up with the correct one for your VIA CPU?
We have been running some thermal tests on the VIA board and the values from LM-Sensors were significantly off. We therefore ran our own thermal cycling tests with a probe attached to the center of the heatsink directly above the CPU. We were then able to obtain a set of measurements for the probe temperature versus the register value. This gave us a very linear response with the above equation. We did not get the curve information from VIA.
We have another sample of the board here now, so we will be repeating the measurements to ensure that the VIA results are predictable from board to board.
Quoted 4 lines
What would the formula required for VIA CPUs look like if the Intel one was integrated into the driver as I first proposed?
It would still be a simple y=mx+c style graph but just with different constants.
Quoted 7 lines
Quoted 1 line
We can put the VIA official Intel scaling into the driver, but this
would be
Quoted 1 line
very misleading as the VT8231 is used on the VIA EPIA platform which is
in
Quoted 3 lines
widespread use, and all users of that board would therefore need to know that additional scaling was required. If they didn't then they would be panicking when they see the CPU temperature (since the motherboard is
Quoted 8 lines
only
Quoted 1 line
passively cooled).
Well, whatever we do, the VIA CPU users will have an incorrect reading at first and will have to edit some lines in their configuration file to get the proper reading. So this point doesn't really weight in either direction. All it really means is that we will have to improve the vt8231's sensors.conf.eg section to make the point clear.
I agree that whatever we do, the VIA users must apply some kind of equation to get their correct temperature, but I feel that the safest approach is "first do no wrong".
I am extremely uncomfortable with the situation where we release a driver that we know will give incorrect information under some conditions. I feel that it is much better to return the result from the driver as a register value and put the text below:
# If you have an Intel CPU, then uncomment the line below
# temp0_input = (@-65)/0.9686, (@*0.9686)+65
# If you have an VIA EPIA CPU, then uncomment the line below
# temp0_input = (@-45)/0.7809, (@*0.7809)+45
This way, an incorrect value is never returned and the user must correctly set the board configuration before a temperature is returned.
Quoted 4 lines
Thanks,
--
Jean Delvare
Thanks for the work you are doing on reviewing this driver.
Best regards,
Roger
Hi Roger,
Quoted 3 lines · Roger Lucas
We have another sample of the board here now, so we will be repeating the measurements to ensure that the VIA results are predictable from board to board.
OK, great. I've tried some mathematics on the formulae to find out if anything obvious with regards to the physical meaning of the constants would spring out, but did not find anything.
Quoted 3 lines
I agree that whatever we do, the VIA users must apply some kind of equation to get their correct temperature, but I feel that the safest approach is "first do no wrong".
Fair enough.
Quoted 4 lines
I am extremely uncomfortable with the situation where we release a driver that we know will give incorrect information under some conditions. I feel that it is much better to return the result from the driver as a register value and put the text below:
The problem is that the standard sysfs interface sets some contraints on what we can or cannot do. In particular, it dictates that the magnitude for temperature values is 3. This suggests that the value we would be returning would be REG * 1000. As it seems that there are an additional 2 bits of resolution, that would be (REG << 2 + ADDREG) * 250.
Quoted 5 lines
# If you have an Intel CPU, then uncomment the line below
# temp0_input = (@-65)/0.9686, (@*0.9686)+65# If you have an VIA EPIA CPU, then uncomment the line below
# temp0_input = (@-45)/0.7809, (@*0.7809)+45
s/temp0_input =/compute temp1/, but yes.
BTW, does this suggest that you decided that the diode temperature would be temp1, and thermistor-based ones are temp2+? I have no objection a priori, just curious.
Quoted 3 lines
This way, an incorrect value is never returned and the user must correctly set the board configuration before a temperature is returned.
By commenting out both compute lines, I'd rather say that an incorrect value will *always* be returned. I'd prefer to keep the Intel line by default so as to preserve backward compatibility as much as we can.
I think you will end up with a dedicated configuration file for your board anyway. The best we can do to help out VIA EPIA users is to make this file publicly available.
Thanks,
--
Jean Delvare
Hi Jean,
Comments below:
Quoted 32 lines
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 15 November 2005 12:02
To: [email protected]
Cc: 'Mark Studebaker'; LM Sensors
Subject: RE: [lm-sensors] RE:vt8231.cHi Roger,
Quoted 1 line · Roger Lucas
We have another sample of the board here now, so we will be repeating
the
Quoted 1 line
measurements to ensure that the VIA results are predictable from board
to
Quoted 1 line
board.
OK, great. I've tried some mathematics on the formulae to find out if anything obvious with regards to the physical meaning of the constants would spring out, but did not find anything.
Quoted 3 lines
I agree that whatever we do, the VIA users must apply some kind of equation to get their correct temperature, but I feel that the safest approach is "first do no wrong".
Fair enough.
Quoted 4 lines
I am extremely uncomfortable with the situation where we release a driver that we know will give incorrect information under some conditions. I feel that it is much better to return the result from the driver as a register value and put the text below:
Quoted 6 lines
The problem is that the standard sysfs interface sets some contraints on what we can or cannot do. In particular, it dictates that the magnitude for temperature values is 3. This suggests that the value we would be returning would be REG * 1000. As it seems that there are an additional 2 bits of resolution, that would be (REG << 2 + ADDREG) * 250.
From the above, if the driver returns the result ((REG << 2 + ADDREG) * 250) to the sensors user-space application, then you are OK with this? The SENSORS.CONF file would then apply one of the two lines below to give user the temperature in degrees Centigrade.
Quoted 11 lines
Quoted 5 lines
# If you have an Intel CPU, then uncomment the line below
# temp0_input = (@-65)/0.9686, (@*0.9686)+65# If you have an VIA EPIA CPU, then uncomment the line below
# temp0_input = (@-45)/0.7809, (@*0.7809)+45s/temp0_input =/compute temp1/, but yes.
BTW, does this suggest that you decided that the diode temperature would be temp1, and thermistor-based ones are temp2+? I have no objection a priori, just curious.
Nope. I don't care which is which. Really. If there is a general trend for the CPU-0 temperature to be on a specific sensor then let me know and I'll make the driver match.
Quoted 5 lines
Quoted 4 lines
This way, an incorrect value is never returned and the user must correctly set the board configuration before a temperature is returned.
Quoted 7 lines
By commenting out both compute lines, I'd rather say that an incorrect value will *always* be returned. I'd prefer to keep the Intel line by default so as to preserve backward compatibility as much as we can.
I think you will end up with a dedicated configuration file for your board anyway. The best we can do to help out VIA EPIA users is to make this file publicly available.
Fair enough.
Quoted 4 lines
Thanks,
--
Jean Delvare
If you can send me the results for the code review of the driver then I'll wrap these changes up into it and re-submit it. Hopefully then it is complete.
Best regards,
Roger
Hi Roger,
Quoted 4 lines
From the above, if the driver returns the result ((REG << 2 + ADDREG) * 250) to the sensors user-space application, then you are OK with this? The SENSORS.CONF file would then apply one of the two lines below to give user the temperature in degrees Centigrade.
Yes, I'm fine with that. I don't think we can do anything better.
Quoted 7 lines
Quoted 3 lines
BTW, does this suggest that you decided that the diode temperature would be temp1, and thermistor-based ones are temp2+? I have no objection a priori, just curious.
Nope. I don't care which is which. Really. If there is a general trend for the CPU-0 temperature to be on a specific sensor then let me know and I'll make the driver match.
No, the general trend is to use the same order the device itself does because it usually allows for some code optimizations, and makes it easier when comparing the code and the datasheet. In the case of the VT8231, none of this really applies anyway.
Quoted 3 lines
If you can send me the results for the code review of the driver then I'll wrap these changes up into it and re-submit it. Hopefully then it is complete.
Just done that :)
Signature · 1 line
Jean Delvare