Details
- Reviewers
olce rz_fabmicro.ru seuros ziaee - Group Reviewers
docs - Commits
- rG116216477e8a: acpi: Add acpi_fan
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 71094 Build 67977: arc lint + arc unit
Event Timeline
With this patch, on a framework 16 (AI 300) I see
# sysctl dev.fan.0 dev.fan.0.fine_grind: 0 dev.fan.0.status: Control Level: 100, Speed: 1674 RPM dev.fan.0.levels: dev.fan.0.%domain: -1 dev.fan.0.%iommu: dev.fan.0.%parent: acpi0 dev.fan.0.%pnpinfo: _HID=PNP0C0B _UID=0 _CID=none dev.fan.0.%location: handle=\_SB_.FAN_ dev.fan.0.%driver: fan dev.fan.0.%desc:
Just received panic: mtx_lock() of spin mutex Fan mutex @ ... upon sysctl -a.
I may not have all updates from this review in place.
Some fixes for the man page. You may also try out mandoc -Tlint and see if it gives you additional things to fix.
Other than that, I'm a ... well... fan. ;-)
| share/man/man4/acpi_fan.4 | ||
|---|---|---|
| 60 ↗ | (On Diff #184867) | s/fine grain/fine grained/ |
| 63 ↗ | (On Diff #184867) | s/fine grain/fine grained/ |
| 76 ↗ | (On Diff #184867) | s/fine grain/fine grained/ |
| 84 ↗ | (On Diff #184867) | s/fine grain/fine grained/ |
| 159 ↗ | (On Diff #184867) | s/fine grain/fine grained/ |
| share/man/man4/acpi_fan.4 | ||
|---|---|---|
| 1–24 ↗ | (On Diff #184867) | Please see updated preferred license guidelines: |
| 32 ↗ | (On Diff #184867) | This is the new driver synopsis standard, I am in the middle of updating all manuals to this. |
| 72 ↗ | (On Diff #184867) | Please add a HARDWARE section for the hardware compatibility list. Note that to be useful for that application this needs to be user focused like I have written it (what hardware is the reader staring at) and not developer focused (how does the fan attach in software), but I am not an expert on this topic and this suggestion might have details wrong. also I wonder if we should use some of this in the document description |
| 143 ↗ | (On Diff #184867) | It's worthwhile to list this here too, but for maintenance I wouldn't duplicate the description. |
| 180–185 ↗ | (On Diff #184867) | Since you wrote everything, if you want you can do it like this. This is the more traditional way, I think it's much more handsome. |
| 187 ↗ | (On Diff #184867) | what does this mean? |
| sys/dev/acpica/acpi_fan.c | ||
| 28 | ditto about the new preferred license template. | |
I tested this patch on three machines:
- Lenovo Ideapad Gaming laptop based on AMD Ryzen 5 5600H, acpi0: <LENOVO CB-01 >
- Some chinese mini-PC based on AMD Ryzen 5 7535HS, acpi0: <ALASKA A M I >
- Panasonic CF-31 laptop (AKA Toughbook) based on Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz, acpi0: <MATBIO CF31-5>
The first two seem do not have fan control in their ACPI firmware. I searched through decompiled firmware code (ASL) and could not find any reference neither to "PNP0C0B" device, nor to _FIF control method. Expectedly acpi_fan driver did not attach.
But the last one (CF-31) was much more interesting. I decompiled its ACPI firmware and could find "PNP0C0B" and well as a number of fan control methods, including _FIF. But, the driver did not attach to it too. I read through the ASL code a bit more thoroughly and could observe the following:
- The \_TZ.FAN0 device marked with "PNP0C0B" id does not export any _F* methods, in fact it has only one _STA.
- There's another device \_SB.PCI0.LPCB.EC0.TFN1 which is marked with "INT3404" id, it exports the following control methods: _FIF, _FPS, _FSL and _FST
I installed acpi_call tool from ports and was able to call some of these methods:
acpi_call -p \\_SB.PCI0.LPCB.EC0.TFN1._FIF -o b 0400000004000000182C800100F8FFFF0000000000000000010000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000010000000000000002000000000000000000000000000000010000000000000000000000000000000000000000000000 acpi_call -p \\_SB.PCI0.LPCB.EC0.TFN1._STA -o b 01000000000000000F000000000000000000000000000000 acpi_call -p \\_SB.PCI0.LPCB.EC0.TFN1._FST -o b 040000000300000018D8700100F8FFFF00000000000000000100000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000FFFFFFFF000000000000000000000000
I even was able to turn on and off the fan with:
acpi_call -p \\_SB.PCI0.LPCB.EC0.TFN1._FSL -i 100 acpi_call -p \\_SB.PCI0.LPCB.EC0.TFN1._FSL -i 0
I did some googling on "INT3404" and decided it was legitimate to add this id to the list of supported (i.e. to fan_ids array). After recompile and reboot I got the following:
root@panasonic:/home/rz # sysctl hw.model hw.model: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz root@panasonic:/home/rz # dmesg | grep 'acpi0:\|fan' FreeBSD 16.0-CURRENT #2 acpi_fan-c96ef70c1ea6-dirty: Wed Nov 18 17:46:16 +05 2026 acpi0: <MATBIO CF31-5> acpi0: Power Button (fixed) fan0: <ACPI Fan> on acpi0 root@panasonic:/home/rz # sysctl dev.fan dev.fan.0.fine_grind: 1 dev.fan.0.set_level: 0 dev.fan.0.status: Control Level: 0, Speed: 4294967295 RPM dev.fan.0.steps: 2 dev.fan.0.%iommu: dev.fan.0.%parent: acpi0 dev.fan.0.%pnpinfo: _HID=INT3404 _UID=0 _CID=none dev.fan.0.%location: handle=\_SB_.PCI0.LPCB.EC0_.TFN1 dev.fan.0.%driver: fan dev.fan.0.%desc: ACPI Fan dev.fan.%parent:
Now I'm able to control fan speed by sysctl dev.fan.0.set_level=XXX command. I'm well fan, as well as bcr@. ;)
Hope this helps.
Just tested this patch on my Panasonic CF-31. Everything looks good.
rz@panasonic:~ % uname -a FreeBSD panasonic 16.0-CURRENT FreeBSD 16.0-CURRENT #1 acpi_fan-e3ce29fb50f1: Thu Nov 26 16:39:51 +05 2026 rz@butterfly:/usr/home/rz/FreeBSD-src/src-current/obj/amd64.amd64/sys/GENERIC amd64 rz@panasonic:~ % dmesg | grep fan0 fan0: <ACPI Fan> on acpi0 rz@panasonic:~ % sysctl dev.fan dev.fan.0.fine_grained: 1 dev.fan.0.set_level: 0 dev.fan.0.status: Control Level: 0, Speed: 4294967295 RPM dev.fan.0.steps: 2 dev.fan.0.%iommu: dev.fan.0.%parent: acpi0 dev.fan.0.%pnpinfo: _HID=INT3404 _UID=0 _CID=none dev.fan.0.%location: handle=\_SB_.PCI0.LPCB.EC0_.TFN1 dev.fan.0.%driver: fan dev.fan.0.%desc: ACPI Fan dev.fan.%parent: rz@panasonic:~ % sudo sysctl dev.fan.0.set_level=100 dev.fan.0.set_level: 0 -> 100 rz@panasonic:~ % sudo sysctl dev.fan.0.set_level=0 dev.fan.0.set_level: 100 -> 0