Repository navigation
Conversation
Find the hwmon named macsmc_hwmon when applesmc is absent, drive fans through fanN_target (value in [min,max] = manual, 0 = SMC auto), parse sensor keys from 'Description (KEY)' labels, exclude unreadable or out-of-range sensors from averages, clamp to hardware min/max, and hand fans back to the SMC on exit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- calc_fan: ramp linearly from min_speed at floor to max_speed at ceiling. The old |normalized| * window ran fans faster as temps fell below the floor and never reached max_speed. - read_cfg: allocate per-fan fan_sensors lists (were NULL -> segfault) and let /etc/macfand.conf use_avg override the machine profile. - Per-fan control follows the hottest listed sensor, not the average. - fan_sensors may name any hwmon sensor as "<hwmon name>:<label>", e.g. "coretemp:Package id 0" or "amdgpu:junction". T2 SMCs have no usable CPU die / GPU junction sensor. - No readable sensor for a fan -> run it at max (fail hot). - main: allocate struct applesmc, not a pointer-sized buffer. - SENSKEY_MAXLEN 16 -> 48; CFG_FILE overridable at build time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Speed-ups still apply immediately. Slow-downs smaller than rampdown_deadband (default 100 RPM) are ignored, and larger ones are limited to rampdown_step RPM per poll (default 250). Jittery sensors such as the CPU package temperature otherwise move fans +-80 RPM every poll under steady load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ig on upgrade
PKGBUILD: add backup=('etc/macfand.conf') so pacman does not overwrite
a customized config on upgrade.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After easing down in rampdown_step increments a fan could stop within rampdown_deadband of min_speed (e.g. 570 RPM with min 500) and stay there indefinitely. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Linux 7.3 drops
applesmcon T2 Macs in favour of the newmacsmcfamily (macsmc_acpi+macsmc_hwmon), so macfand currently exits with "Cannot find applesmc device" and the fans are left at SMC defaults. This PR addsmacsmc_hwmonsupport and fixes several control/stability bugs I hit while getting a MacPro7,1 (2019, Radeon Pro Vega II) working on 7.3.3.applesmcbehaviour is unchanged apart from the bug fixes below.macsmc_hwmon support
macsmc_hwmonwhenapplesmcis absent.fanN_target(a value in[fanN_min, fanN_max]switches the fan to manual,0hands it back to the SMC); there is nofanN_manual. The driver needsoptions macsmc_hwmon fan_control=1.GPU 0 Die Cooked Temperature (TG0D), so existing profiles/blacklists keep matching.TC1F= -127 °C) are excluded from averages instead of being sign-flipped into them.EINVALotherwise).SIGTERM/SIGINT), for both drivers.External sensors
On T2 Macs the SMC has no usable CPU die or GPU junction sensor (
TCXcis stuck,TC0Pis a slow proximity sensor), so averaging SMC sensors can't protect the machine.fan_sensorsentries may now name any hwmon sensor as"<hwmon name>:<temp label>", e.g."coretemp:Package id 0"or"amdgpu:junction". Per-fan control follows the hottest listed sensor rather than the average, and a fan with no readable sensor runs at max (fail hot).Bug fixes
|normalized| * (max - min), so below the floor fans sped up as temperature fell and never reachedmax_speed. Now a linear ramp frommin_speedatfloortomax_speedatceiling.fan_sensorsin/etc/macfand.confcrashed with SIGSEGV (per-fan sensor arrays were never allocated inread_cfg).use_avg = falsein/etc/macfand.confcould not override a profile'suse_avg = true.mainallocatedsizeof(struct applesmc *)(8 bytes) forstruct applesmc(heap overflow).SENSKEY_MAXLEN16 → 48 so external sensor names fit..PHONY; previously a re-runmakepkgcould silently package a stale binary.backup=('etc/macfand.conf')so upgrades don't overwrite a customized config.Smoothing
Speed-ups apply immediately; slow-downs under
rampdown_deadband(default 100 RPM) are ignored and larger ones are limited torampdown_stepper poll (default 250). This stops the fans hunting when a jittery sensor like CPU package temperature moves ±1–2 °C each poll. Both are optional config keys, documented inmacfand.conf.Testing
MacPro7,1, Xeon W, Radeon Pro Vega II, CachyOS
linux-cachyos 7.3.3, config: all 4 fansfan_sensors = ("coretemp:Package id 0", "amdgpu:junction", "TG0D"), floor 60 / ceiling 88.With smoothing, a 60 s all-core load held fans 2–4 at a constant 1954 RPM for 40+ s; without it the same load moved them ±80 RPM nearly every poll. Speed-ups are unaffected (903 → 1388 RPM in the first poll of GPU load), and after load stops the fans ease down 250 RPM per poll (~30 s from 1954 to 500) instead of dropping instantly.
I don't have a pre-T2 Mac to test the
applesmcpath; it compiles and the changes there are limited to the bug fixes above.🤖 Generated with Claude Code