Skip to content

hwmon: macsmc: Drop the fan_control module parameter - #2448

Merged
RyanTheTide merged 3 commits into
integration/aurorafrom
powerctl/hwmon-fan-control-v2
Nov 22, 2026
Merged

RyanTheTide merged 3 commits into
integration/aurorafrom
powerctl/hwmon-fan-control-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

macsmc_hwmon.fan_control (module_param_unsafe, off by default) makes fanX_target writable on every fan that has mode, target, minimum and maximum keys, whatever the device tree says. It came with the original driver by James Calligeros (785205f). Since 65f0c0f ("hwmon: macsmc: let the device tree allow manual fan speeds"), the hardware-described path is the apple,fan-manual-control property on a fan node. A machine's device tree sets it where the SMC firmware is known to accept a manual speed and to take the fan back. The parameter is now only a way to force manual speeds on fans whose firmware behaviour is not described. Nothing in our kits, scripts or device trees sets it.

Change

  • Remove the parameter. fanX_target is writable exactly on fans whose node has apple,fan-manual-control. It is read-only on all other fans.
  • A leftover macsmc_hwmon.fan_control=1 on the command line or in modprobe options is reported as an unknown parameter and ignored. The driver still loads.
  • Kernel thermal requests through macsmc_hwmon_fans_request() never used the parameter and are unchanged. So are the unlock, restore, suspend and shutdown paths.
  • The fan KUnit suite now sets the per-fan device tree flag instead of the parameter. A new case checks that a fan without the flag refuses a target and writes nothing to the SMC.
  • Documentation/hwmon/macsmc-hwmon.rst is updated.

This diverges from mainline, which still has the parameter.

This PR sits on top of #2304 (SMC key inventory and sensor key checks on every SoC) because both change the same lines at the top of the file. Review only the last commit, adcfa5c.

Which machines this reaches: every machine with a fan node. On fans that have apple,fan-manual-control (T6040/T6041 MacBook Pro, T6050 J714s, T8142 J704), nothing changes. On every other fanned machine, manual speed is no longer possible through the parameter. Those fans stay under SMC control, which is the default today.

Testing

  • macsmc-hwmon.ko with W=1 against the fleet75 configuration on this stack: 0 warnings. Earlier, drivers/hwmon/macsmc-hwmon.o with W=1 (clang, LLVM=1, release config): 0 warnings, both with and without the KUnit code compiled in. The new test case is present in the object.
  • KUnit on arm64 (kunit.py, qemu virt, LLVM): macsmc-hwmon 4/4 and macsmc-hwmon-fan 14/14 passed on the head of this stack (hwmon: macsmc: SMC key inventory and sensor key checks on every SoC #2304 with the fan_control removal on top); 52 tests run in total, 51 passed, 1 skipped (a GPU test that needs CONFIG_UCLAMP_TASK). The kunitconfig enables MFD_MACSMC, MACSMC_POWER and SENSORS_MACSMC_HWMON with their KUnit options under COMPILE_TEST.
  • J616s (T6040, apple,fan-manual-control on both fans), on the production kernel, whose DT-flag path this PR leaves as it is: fan1_target is 644; writing 2000 moved fan1 to 1977-2020 rpm within 10 s (the SMC brought fan2 to its own 1458 rpm), and writing 0 returned both fans to the SMC, which stopped them at idle.
  • Production baselines for the rows below: the J316s has fan_control in /sys/module/macsmc_hwmon/parameters/ and fan1_target/fan2_target at 444.
  • Boot rows on all four lab Macs, one-shot boots of a combined test kernel carrying this commit (on the J616s, the same kernel plus two unrelated fixes): /sys/module/macsmc_hwmon/parameters is gone and modinfo -p is empty; hwmon channels have the same indices and labels as production (M1 Pro 142, Neo 213, J616s 480; on the M2 the only change, 3 channels gone, comes from hwmon: macsmc: SMC key inventory and sensor key checks on every SoC #2304); the J316s keeps fan1_target/fan2_target at 444 and a root write fails with Permission denied; the J616s fans stay 644 and accept 0; s2idle 2/2 on each Mac; 0 failed units, 0 AVCs. Details in the PR comments.
  • macsmc_hwmon.fan_control=1 on the kernel command line (this kernel under qemu virt, module loaded by insmod ... fan_control=1 and by modprobe with the option taken from /proc/cmdline): macsmc_hwmon: unknown parameter 'fan_control' ignored, and the module loads.

Still to run

Nothing.

Fanned boards and apple,fan-manual-control (from the compiled DTBs)
SoC boards fans manual control
T8103 J274 mini, J293 MBP13, J456 iMac (2), J457 iMac (1) 1-2 no
T600x J314s/J316s, J314c/J316c MBP, J375c/J375d Studio 2 no
T8112 J473 mini, J493 MBP13 1 no
T602x J414s/J416s, J414c/J416c MBP, J474s mini (1), J475c/J475d Studio 1-2 no
T603x J514s/J516s, J514c/J516c, J514m/J516m MBP, J575d Studio 2 no
T8122 J433/J434 iMac, J504 MBP14 2 no
T604x J614s/J616s, J614c/J616c MBP 2 yes
T604x J773s mini (1), J575c Studio 1-2 no
T8132 J604 MBP14, J623/J624 iMac, J773g mini (1) 1-2 no
T6050 J714s MBP14 2 yes
T6050 J716s, K116s MBP16, J775d Studio 2 no
T8142 J704 MBP14 1 yes
T8152 J873g mini 1 (monitor only, no mode/target keys) no

Assisted-by: LLM (Claude:Opus 5.5)

Commit 2604bb0 ("hwmon: macsmc: expose read-only SMC key inventory
on T6050") enabled the debugfs "keys" listing on T6050 next to the M3
SoCs. The listing only queries key metadata through the SMC's own key
enumeration and reads readable 32-bit float T*/P* keys; it writes
nothing, and it does its work only when root reads the file. None of
that depends on the SoC, and the listing is how the keys a machine has
are found for its device tree, on every SMC.

Create it on every SoC.

Fixes: 2604bb0 ("hwmon: macsmc: expose read-only SMC key inventory on T6050")
Suggested-by: Satya Benson <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Commit c91c5f4 ("hwmon: macsmc: preserve the legacy sensor export
policy") limited the key checks in macsmc_hwmon_create_sensor() to the
M3 SoCs: a device tree sensor is set up only if the SMC reports its key
as readable and as a 4-byte "flt " or an 8-byte "ioft". Elsewhere a
sensor whose key fails those checks still got a channel.

macsmc_hwmon_read_key() decodes only those two types and returns
-EOPNOTSUPP for any other, so such a channel can only ever return an
error, whatever the SoC. Apply the checks on every SoC and drop
macsmc_hwmon_is_m3(), which has no other user.

A temperature node of a thermal sensor provider (#thermal-sensor-cells)
keeps its channel slot when it fails, as before, so thermal zones that
refer to channels by index are not renumbered.

Fixes: c91c5f4 ("hwmon: macsmc: preserve the legacy sensor export policy")
Signed-off-by: Ryan Murray <[email protected]>
fan_control (module_param_unsafe, default off) made fanX_target writable
on every fan with mode, target, minimum and maximum keys, whatever the
device tree says. Since commit 65f0c0f ("hwmon: macsmc: let the
device tree allow manual fan speeds") the hardware-described path is the
apple,fan-manual-control property on a fan node, set in a machine's
device tree where its SMC firmware is known to accept a manual speed and
to take the fan back. The parameter was kept then as the mainline
interface. It is now the only way left to force manual speeds on a fan
whose firmware behaviour is not described, and nothing in this tree's
kits, scripts or device trees sets it.

Remove it. fanX_target is writable exactly on the fans whose node has
apple,fan-manual-control. A leftover macsmc_hwmon.fan_control=1 on the
command line or in modprobe options is reported as an unknown parameter
and ignored; the driver still loads. Kernel thermal requests through
macsmc_hwmon_fans_request() never depended on the parameter and are
unchanged, as is the unlock and restore sequence.

The fan KUnit suite now sets the per-fan device tree flag instead of the
parameter, and a new case checks that a fan without it refuses a target
without writing to the SMC.

The parameter came with the original driver by James Calligeros.

Fixes: 65f0c0f ("hwmon: macsmc: let the device tree allow manual fan speeds")
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Boot rows on hardware, part 1 (M1 Pro, M2). Neo (J700) and 14" M4 Pro (J616s) follow.

Test kernel 7.3.0-aurora-pwr1: a combined test kernel (current integration plus other open drafts, including #2304 and #2372) with this PR's commit cherry-picked on top (clean). One-shot boot on each Mac, then back to the production kernel.

MacBook Pro M1 Pro (J316s) MacBook Air M2 (J413)
/sys/module/macsmc_hwmon/parameters absent (production: fan_control) absent (production: fan_control)
modinfo -p macsmc_hwmon empty empty
probe errors, unknown-parameter lines 0 0
hwmon channels vs production 142, same indices and labels 106; see #2304 for the 3 removed channels
fan1_target/fan2_target 0444, root write refused (Permission denied) no fans
s2idle (apple-pmu-rtc wake) 2/2, same channels after each wake 2/2
kernel errors / failed units / AVC 0 / 0 / 0 0 / 0 / 0

The M1 Pro has no apple,fan-manual-control on its fan nodes, so it never offered manual fan speeds. It keeps both targets read-only, and with the parameter gone nothing can override that.

How it was run

hw-rows.sh <mac>-pwr1 2 as root in the one-shot boot: lists every macsmc_hwmon *_input with its label and value, module parameters, thermal zone types and fan*_target modes; writes 0 (SMC automatic, harmless) to each fan*_target to check that read-only fans refuse; reads macsmc-ac/power_now; then 2 s2idle cycles with an RTC wake 20 s out, listing the channels again after each wake. The channel list is compared against the same listing taken on the production kernel earlier the same night. 4 GPU channels on the M1 Pro and 6 on the M2 return ENODATA on both the production and test kernels, so that predates this change.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Boot rows on hardware, part 2 (MacBook Air M4 Neo J700, 14" MacBook Pro M4 Pro J616s). This completes the four lab Macs.

Neo (J700), 7.3.0-aurora-pwr1 J616s, 7.3.0-aurora-hk3 (= pwr1 + #2460 + a display fix)
/sys/module/macsmc_hwmon/parameters absent (production: fan_control) absent (production: fan_control)
modinfo -p macsmc_hwmon empty empty
probe errors, unknown-parameter lines 0 0
hwmon channels vs production 213, same indices and labels 480, same indices and labels
fan*_target no fans 0644 on both fans (their nodes carry apple,fan-manual-control); writing 0 (SMC automatic) succeeds
s2idle (apple-pmu-rtc wake) 2/2, same channels after each wake 2/2, same channels after each wake
failed units / AVC 0 / 0 0 / 0

On the J616s, manual fan control still comes from the device tree, so removing the parameter changes nothing there. Kernel error lines in these boots come from other drafts in the combined kernels (USB dock enumeration and a display-surface error on the Neo; dwc3 genpd_prepare -11 during s2idle on the J616s). None of them are from hwmon.

Summary across the four Macs (part 1 above has the M1 Pro and M2): the parameter is gone, no channel moved or changed its label except the M2 change that belongs to #2304, read-only fans stay read-only, fans the device tree allows stay writable, and s2idle passes 8/8.

Notes
  • 22 GPU Tg.. channels on the J616s and 8 on the Neo read ENODATA in these boots. On the J616s the SMC returns its powered-down placeholder (0 or -4000 m°C) for those keys while the GPU is idle, which 97bc174 already reports as no data; the production listing was taken with the GPU awake. On the Neo the same 8 channels read ENODATA on production too.
  • Every row comes from hw-rows.sh <mac>-<kernel> 2 (described in part 1) in a one-shot boot, followed by a reboot back to the production kernel.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 19, 2026 23:32

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed adcfa5c only, as asked. Approving.

  • macsmc_hwmon_fan_user_control() now keys only on the per-fan apple,fan-manual-control flag, so manual speed exists exactly where a device tree says the SMC takes the fan back. Kernel thermal requests and the unlock/restore/suspend/shutdown paths don't go through this check, so they're unaffected.
  • The KUnit change is right: the suite sets the per-fan flag instead of the global, the .exit that reset the global goes with it, and the new not_manual case checks -EOPNOTSUPP with no SMC write and the fan left in system mode.
  • A leftover fan_control=1 is ignored with a warning and the module still loads, so no boot breaks.

Two notes, neither blocking:

  1. This is a user-visible change on every fanned board without the flag (all of T8103, T600x, T8112, T602x and T603x today): anyone using fan_control=1 with a fan daemon loses manual control. Please put one line in the next release notes pointing at apple,fan-manual-control, so people know how a board can opt in once its firmware behaviour is confirmed.
  2. It diverges from mainline, which keeps the parameter, so expect a conflict here when mainline touches these lines.

Merge order: this branch carries #2304's commit, so it lands after #2304 (still draft), or together with it once #2304 is ready.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers.

I read adcfa5c at the head. No fan_control reference is left in drivers/hwmon/macsmc-hwmon.c. macsmc_hwmon_fan_user_control() (:536-539) controls both the write path (:547) and the 0644 mode (:755). manual_control is set only when the DT flag is present and the mode and target keys exist (:1131-1136). The kernel thermal path does not go through this check. The rows on the four lab Macs cover read-only fans, fans the DT allows, and s2idle.

  1. Nit, commit message: Fixes: 65f0c0fddad9 points at a commit that exists only in this tree, not in mainline, and it marks a user-visible parameter removal as a bug fix, which invites a stable backport. Drop the tag and keep the reference in the text.

CI: host-tests green. Merge after #2304, which is still a draft.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide merged commit a279690 into integration/aurora Nov 22, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the powerctl/hwmon-fan-control-v2 branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants