Repository navigation
hwmon: macsmc: Select sensor keys by key metadata, not by SoC - #2353
Closed
RyanTheTide wants to merge 1 commit into
Closed
RyanTheTide wants to merge 1 commit into
RyanTheTide wants to merge 1 commit into
Conversation
macsmc_hwmon_is_m3() matched apple,t6030/t6031/t6032/t6034/t8122 and gated two things that do not depend on the SoC: 1. The key check in macsmc_hwmon_create_sensor(). A sensor node was admitted only if the SMC reports its key readable and as a 4-byte "flt " or 8-byte "ioft" value, but only on those five SoCs. The gate was added to keep the earlier admission policy on other machines, not because of a firmware difference. Every SMC reports a key's type, size and flags (apple_smc_get_key_info()), and macsmc_hwmon_read_key() decodes only those two formats on every SoC, so a key that fails the check can only fail every read. The die sensor, thermal pressure and temperature discovery paths already apply the same check without a SoC gate. Apply it to every sensor node. On a node that is a thermal sensor provider (#thermal-sensor-cells, used today by the T600x MacBook Pro, T604x, T8112, T8122 and T8140 trees) a rejected temperature node keeps its hidden channel, so zone indices do not move; elsewhere the unusable channel is no longer registered. 2. The debugfs "keys" inventory, enabled on the same SoCs and T6050. It only walks the SMC key index and key info and reads readable 4-byte float T* and P* keys on demand, which every SMC supports. It is debugfs, root only, and reads nothing at probe. Create it on every machine. No SMC write and no probe-time key read is added on any SoC. The key check and the inventory were written by Chris Kearney for T6030. Fixes: c91c5f4 ("hwmon: macsmc: preserve the legacy sensor export policy") Fixes: 2604bb0 ("hwmon: macsmc: expose read-only SMC key inventory on T6050") Signed-off-by: Ryan Murray <[email protected]>
This was referenced Nov 19, 2026
Contributor
Author
|
Superseded by #2304, which makes the same change (key metadata checks and the key inventory on every SoC) and came first. |
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
drivers/hwmon/macsmc-hwmon.chad a chip list,macsmc_hwmon_is_m3()(t6030, t6031, t6032, t6034, t8122), that switched two things which do not depend on the SoC:macsmc_hwmon_create_sensor()(line 866): a sensor node was admitted only if the SMC reports its key as readable and as a 4-bytefltor 8-byteioftvalue. This check ran on those five SoCs only. It was gated in c91c5f4 ("hwmon: macsmc: preserve the legacy sensor export policy") to keep the earlier behaviour on other machines. No firmware difference was given.macsmc_hwmon_debugfs_init()(line 1683): the read-only debugfskeysinventory was created on those SoCs, and on T6050 after 2604bb0 ("hwmon: macsmc: expose read-only SMC key inventory on T6050").Change
apple_smc_get_key_info(), which every SMC reports.macsmc_hwmon_read_key()decodes only these two formats on every SoC, so a key that fails the check could only fail every read. The die sensor, thermal pressure and temperature discovery paths already run the same check with no chip gate.T*/P*keys only when root reads the file. It reads nothing at probe and writes nothing.macsmc_hwmon_is_m3()is removed. The driver has noof_machine_is_compatible()call left.Why every SoC is safe:
#thermal-sensor-cells, a rejected temperature node keeps a hidden channel, so thermal zone indices do not move. Today those nodes are the T600x MacBook Pro, T604x, T8112, T8122 and T8140 trees.The key check and the inventory were written by Chris Kearney for T6030.
Testing
drivers/hwmon/macsmc-hwmon.owith W=1 (clang, LLVM=1, release config) on base 0abc2f3 and on this branch: 0 warnings on both. The same build with the KUnit code compiled in also has 0 warnings.macsmc-hwmon4/4 andmacsmc-hwmon-fan14/14 passed on the head of this stack (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.Still to run
The test kernel goes on J316s (T6000), J413 (T8112), J616s (T6040) and J700 (T8140). On each machine, compare against the current kernel:
macsmc_hwmonchannel list (index, label, value). Expected: every channel that gave a value before is still there, with the same index and label. A channel can only disappear, or show up as hidden in admesg"unavailable ... hidden" line, if every read of it failed before.sudo head -2 /sys/kernel/debug/<smc hwmon device>/keys. Expected: a# N keysheader, with N equal to the number of lines that follow it, and no new SMC errors indmesg.cat /sys/class/thermal/thermal_zone*/typeand the temperatures. Expected: the same set as before.Exact commands
Assisted-by: LLM (Claude:Opus 5.5)