michalpolkowski / alt-f

Automatically exported from code.google.com/p/alt-f
0 stars 0 forks source link

Fan speed on HW rev-C1 #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. the fan speed on HW rev-C1 changes between only two states: 'low speed' and 
'off'
2. the fan never switches to 'high speed' regardless of any combination of 
temperature thresholds we might have set on /etc/sysctrl.conf and/or even with 
the hard-coded/builtin/defaults on sysctrl.c
3. this seems to affect both flashed and reloaded versions of Alt-F v0.1B6 on 
HW rev-C1

What is the expected output? What do you see instead?
Fan speed is checked/set on lines 592~597 of sysctrl.c but the code currently 
checks different things along the way and since C1 units seem to respond 
slightly differently to the same queries, sysctrl.c never gets to line 597 (pwm 
= FAN_FAST).

What version of the product are you using? On what operating system?
DNS-323 HW rev-C1 running Alt-F v0.1B6 (both flashed and reloaded versions) 

Please provide any additional information below.

Here's a fragment of the syslog when sysctrl starts with default/built-in 
settings. Notice 3 things:
a) lo_fan=2000 (default value)
b) hi_fan=5000 (default value)
c) sysctrl reports fan=400 (read from /sys/class/hwmon/hwmon1/device/fan1_input)

Dec 22 12:31:12 fido.baia sysctrl: Starting
Dec 22 12:31:12 fido.baia sysctrl: reading /etc/sysctrl.conf
Dec 22 12:31:12 fido.baia sysctrl: cant open /etc/sysctrl.conf: No such file or 
directory#012Using defaults
Dec 22 12:31:12 fido.baia sysctrl: args.lo_fan=2000
Dec 22 12:31:12 fido.baia sysctrl: args.hi_fan=5000
Dec 22 12:31:12 fido.baia sysctrl: args.lo_temp=45
Dec 22 12:31:12 fido.baia sysctrl: args.hi_temp=50
Dec 22 12:31:12 fido.baia sysctrl: args.mail=1
Dec 22 12:31:12 fido.baia sysctrl: args.recovery=1
Dec 22 12:31:12 fido.baia sysctrl: args.fan_off_temp=38
Dec 22 12:31:12 fido.baia sysctrl: args.max_fan_speed=5500
Dec 22 12:31:12 fido.baia sysctrl: args.crit_temp=54
Dec 22 12:31:12 fido.baia sysctrl: args.warn_temp=52
Dec 22 12:31:12 fido.baia sysctrl: args.crit_temp_command="/sbin/poweroff"
Dec 22 12:31:12 fido.baia sysctrl: args.warn_temp_command="(null)"
Dec 22 12:31:12 fido.baia sysctrl: args.front_button_command1="(null)"
Dec 22 12:31:12 fido.baia sysctrl: args.front_button_command2="(null)"
Dec 22 12:31:12 fido.baia sysctrl: args.back_button_command="(null)"
Dec 22 12:31:12 fido.baia sysctrl: temp=46.0#011 fan=400
Dec 22 12:31:12 fido.baia sysctrl: md1: state=clean level=raid5 degraded=1 
action=idle
Dec 22 12:31:12 fido.baia sysctrl: right_dev disk (sda) wakeup
Dec 22 12:31:12 fido.baia sysctrl: left_dev disk (sdb) wakeup

On line 83 of sysctrl.c, we have:
enum FanSpeed { FAN_OFF = 0, FAN_LOW =  127, FAN_FAST = 255 };

When we check values on /sys, we find:
root@FIDO:~# cat /sys/class/hwmon/hwmon1/device/pwm1
63
root@FIDO:~# cat /sys/class/hwmon/hwmon1/device/fan1_input
400
root@FIDO:~# 

A few tests on rev-C1 reveal the following:
root@FIDO:~# echo 0 > /sys/class/hwmon/hwmon1/device/pwm1
root@FIDO:~# cat /sys/class/hwmon/hwmon1/device/fan1_input
0
root@FIDO:~# echo 127 > /sys/class/hwmon/hwmon1/device/pwm1
root@FIDO:~# cat /sys/class/hwmon/hwmon1/device/fan1_input
400
root@FIDO:~# echo 255 > /sys/class/hwmon/hwmon1/device/pwm1
root@FIDO:~# cat /sys/class/hwmon/hwmon1/device/fan1_input
2000
root@FIDO:~# 

Since 'args.lo_fan' is set to 2000 by default and 'fan' will never be larger 
than 2000 on rev-C1, line 597 of sysctrl.c will never be executed (thus, the 
fan speed is never set to 'fast').

I came up with a couple of solutions:

Alternative #1 (workaround) - add the following lines to /etc/sysctrl.conf

lo_fan="400"         # default = 2000
hi_fan="2000"        # default = 5000
max_fan_speed="2000" # not quite sure if this one is really necessary 

Alternative #1b - set/update the built-in/default values for rev-C1 boards on 
check_board() to include:
------- sysctrl_c1_fan_defaults.diff -------
535a536,538
>       args.lo_fan = 400;
>       args.hi_fan = 2000;
>       args.max_fan_speed = 2000;
------- sysctrl_c1_fan_defaults.diff -------

Alternative #2 - 
The current code tests temperature (line 592), then fan speed (line 594). 
Instead, I'd suggest changing line 594 of sysctrl.c so the same kind of thing 
is tested as in line 592 (i.e. stick with temperature checks):
------- sysctrl_c1_fan_control.diff -------
594c594
<       else if (fan < args.lo_fan)

---
>       else if (temp < args.lo_temp)
------- sysctrl_c1_fan_control.diff -------

Original issue reported on code.google.com by augu...@bott.com.br on 22 Dec 2010 at 6:30

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed using Alternative #2, which was obviously the desired.
Can you please check it now, together with the web status page modification?
Thanks 

Original comment by whoami.j...@gmail.com on 7 Jan 2011 at 6:45

GoogleCodeExporter commented 9 years ago
Somehow after following the Alternative #1 the fan still often goes to 2000, 
even though the temp never goes above 40 on my Rev-C1 board (and the lo_temp is 
set to default '45'). I'm using Alt-F-0.1B6.

Original comment by dinv...@gmail.com on 9 Jan 2011 at 7:09

GoogleCodeExporter commented 9 years ago
Can you please try 

http://dl.dropbox.com/u/1555717/DNS-323/Alt-F/experimental/index.html

Original comment by whoami.j...@gmail.com on 14 Jan 2011 at 1:30

GoogleCodeExporter commented 9 years ago
Just tried this experimental build on my Rev-C1 box (copied zImage and 
rootfs.arm.cpio-sq.lzma to /root and rebooted): fan speed/control is working as 
documented/expected.

Original comment by augu...@bott.com.br on 19 Jan 2011 at 5:15

GoogleCodeExporter commented 9 years ago
Thanks.

So closing the issue.

Original comment by whoami.j...@gmail.com on 19 Jan 2011 at 7:26