Repository navigation
hwmon: macsmc: Drop the fan_control module parameter - #2448
Draft
RyanTheTide wants to merge 3 commits into
Draft
RyanTheTide wants to merge 3 commits into
RyanTheTide wants to merge 3 commits into
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 <satya@benson.earth> Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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 <ryan@aurorasilicon.org>
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 <ryan@aurorasilicon.org>
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.
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.Still to run
apple,fan-manual-control):stat -c %a fan1_targetshould give444, and a write should be refused. Boot once withmacsmc_hwmon.fan_control=1:dmesgshould show the unknown parameter, the files should still be444, and the fans should run under the SMC.ls /sys/module/macsmc_hwmon/parameters/should list nofan_control.Fanned boards and apple,fan-manual-control (from the compiled DTBs)
Assisted-by: LLM (Claude:Opus 5.5)