Repository navigation
hwmon: macsmc: Drop the fan_control module parameter - #2448
Conversation
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]>
|
Boot rows on hardware, part 1 (M1 Pro, M2). Neo (J700) and 14" M4 Pro (J616s) follow. Test kernel
The M1 Pro has no How it was run
Assisted-by: LLM (Claude:Opus 5.5) |
|
Boot rows on hardware, part 2 (MacBook Air M4 Neo J700, 14" MacBook Pro M4 Pro J616s). This completes the four lab Macs.
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 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
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed adcfa5c only, as asked. Approving.
macsmc_hwmon_fan_user_control()now keys only on the per-fanapple,fan-manual-controlflag, 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
.exitthat reset the global goes with it, and the newnot_manualcase checks -EOPNOTSUPP with no SMC write and the fan left in system mode. - A leftover
fan_control=1is ignored with a warning and the module still loads, so no boot breaks.
Two notes, neither blocking:
- 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=1with a fan daemon loses manual control. Please put one line in the next release notes pointing atapple,fan-manual-control, so people know how a board can opt in once its firmware behaviour is confirmed. - 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.
|
No blockers. I read adcfa5c at the head. No
CI: host-tests green. Merge after #2304, which is still a draft. Assisted-by: LLM (Claude:Opus 5.5) |
Problem
macsmc_hwmon.fan_control(module_param_unsafe, off by default) makesfanX_targetwritable 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 theapple,fan-manual-controlproperty 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
fanX_targetis writable exactly on fans whose node hasapple,fan-manual-control. It is read-only on all other fans.macsmc_hwmon.fan_control=1on the command line or in modprobe options is reported as an unknown parameter and ignored. The driver still loads.macsmc_hwmon_fans_request()never used the parameter and are unchanged. So are the unlock, restore, suspend and shutdown paths.Documentation/hwmon/macsmc-hwmon.rstis 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.kowith W=1 against the fleet75 configuration on this stack: 0 warnings. Earlier,drivers/hwmon/macsmc-hwmon.owith 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.macsmc-hwmon4/4 andmacsmc-hwmon-fan14/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.apple,fan-manual-controlon both fans), on the production kernel, whose DT-flag path this PR leaves as it is:fan1_targetis644; 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.fan_controlin/sys/module/macsmc_hwmon/parameters/andfan1_target/fan2_targetat444./sys/module/macsmc_hwmon/parametersis gone andmodinfo -pis 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 keepsfan1_target/fan2_targetat444and a root write fails withPermission denied; the J616s fans stay644and accept0; s2idle 2/2 on each Mac; 0 failed units, 0 AVCs. Details in the PR comments.macsmc_hwmon.fan_control=1on the kernel command line (this kernel under qemuvirt, module loaded byinsmod ... fan_control=1and bymodprobewith 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)
Assisted-by: LLM (Claude:Opus 5.5)