FreeBSD kernel module to control fan speed

ACPI

Yes. If your hardware supports Advanced Configuration and Power Interface (ACPI) then there are loadable modules for ACPI support.

Unfortunately most (if not all) modules are targetting laptops.

You can see if you have any settings related to fans using sysctl:

# sysctl hw.acpi

But rather than manually tweaking the fan speed it should autoadjust according to temperature and load. In FreeBSD this is handled by powerd which is disabled by default.

So even if the fans are not directly exposed then you might be able to adjust them but adjusting the CPU frequency. Some BIOSes then adjust the fan speed accordingly (if within reasonable temperature range as well).

Example setting in /etc/rc.conf

powerd_enable="YES"
powerd_flags="-a adaptive"
performance_cx_lowest="C2"      # Online CPU idle state
performance_cpu_freq="1399"     # Online CPU frequency
economy_cx_lowest="C3"          # Offline CPU idle state
economy_cpu_freq="NONE"         # Offline CPU frequency

The sysctl hw.acpi will also show if any of the above settings can take effect.

IPMI

If you have no luck going the ACPI route then maybe the Intelligent Platform Management Interface (IPMI) can be helpful to you. This is however normally only available on serverclass motherboards with a BMC.

When the server boots up the fans runs at BIOS default speeds until the OS takes over. If the OS does not take over (ie. using ACPI) then the CPU and fans often runs at full throttle. Even though the thresholds are not directly available in the BIOS configuration screen in several cases this can then be set using IPMI.

FreeBSD does have an IPMI driver and you can install sysutils/ipmitool to play with the settings.

The following snippet from servethehome.com should work for some SuperMicro boards (X9/X10/X11):

#set fan mode to "full"
ipmitool raw 0x30 0x45 0x01 0x01
#set fans in "system" zone to 37.5%
ipmitool raw 0x30 0x70 0x66 0x01 0x00 0x24
#set fans in "peripheral" zone to 25%
ipmitool raw 0x30 0x70 0x66 0x01 0x01 0x16

NOTE: The fan mode is set to full at first as the BMC does not seem to change the fan speed if not.

Hardware

If everything else fails then get a cheap hardware fan controller :-).