Time to get rid of these userspace pwm fan controll shit

Here is a devicetree overlay to make pwm fan controlled by the kernel driver: https://github.com/amazingfate/radxa-rock5b-overlays/blob/main/pwm-fan.dts
No need to use some userspace script to control the fan, just a kernel has CONFIG_SENSORS_PWM_FAN enabled, adn run
echo step_wise > /sys/class/thermal/thermal_zone0/policy at boot, then your fan is controlled by kernel driver based on the soc temp.
The armbian kernel doesn’t have CONFIG_SENSORS_PWM_FAN enabled at this moment, but that is on the way: https://github.com/armbian/build/pull/4888

5 Likes

Yes please. :slight_smile:
I’ve been using this method for a couple months now (with a slightly different curve). Is there a plan to merge the overlay into Armbian dt by default?

I will, after we’ve done the kernel toggle.

1 Like

Thanks! And a follow-up question: does it make sense then to make step-wise governor the default one?

@@ -3792,10 +3792,10 @@ CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
 CONFIG_THERMAL_HWMON=y
 CONFIG_THERMAL_OF=y
 CONFIG_THERMAL_WRITABLE_TRIPS=y
-# CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE is not set
+CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
 # CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
 # CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
-CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR=y
+# CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set
 CONFIG_THERMAL_GOV_FAIR_SHARE=y
 CONFIG_THERMAL_GOV_STEP_WISE=y
 # CONFIG_THERMAL_GOV_BANG_BANG is not set

It may not be optimal for fanless systems though, but for everyone else it would save some hassle.
Then again, it can probably be done with e.g. an option in armbian-config, to create a file /etc/sysfs.d/something.conf with contents of
class/thermal/thermal_zone0/policy = step_wise

I think it’s better that this pwm device tree modification stays in the overlay because not all users have a fan insatlled, and so does the thermal governor. We can provide tools for users to toggle settings easly.

Is this what armbian is using at the moment ?

Hi, currently i try to get this running with boogiepops / googlenators midstream kernel 6.2 and archlinux.

After compiling the dts with
dtc -@ -I dts -O dtb -o pwm-fan.dtbo pwm-fan.dts

following Warnings show up
pwm-fan.dts:21.25-25.7: Warning (unit_address_vs_reg): /fragment@1/__overlay__/trips/trip-point@0: node has a unit name, but no reg or ranges property pwm-fan.dts:26.25-30.7: Warning (unit_address_vs_reg): /fragment@1/__overlay__/trips/trip-point@1: node has a unit name, but no reg or ranges property pwm-fan.dts:31.25-35.7: Warning (unit_address_vs_reg): /fragment@1/__overlay__/trips/trip-point@2: node has a unit name, but no reg or ranges property pwm-fan.dts:36.29-40.7: Warning (unit_address_vs_reg): /fragment@1/__overlay__/trips/trip-point@3: node has a unit name, but no reg or ranges property

I got tips from boogiebpop in Archlinux on Rock5b thread
but sadly im not experienced enough to write a new fragment to get this working.
Can someone help me with this?

1 Like

The device tree has get merged to armbian’s kernel repo. Images built after 5th May should have this feature.

2 Likes