Skip to content

hwmon: macsmc: SMC key inventory and sensor key checks on every SoC - #2304

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
sweep/macsmc-hwmon
Nov 22, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
sweep/macsmc-hwmon

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

Two macsmc-hwmon features were enabled by SoC list rather than by what the SMC reports:

  • The read-only debugfs SMC key inventory (keys) was created only on the M3 SoCs and T6050 (drivers/hwmon/macsmc-hwmon.c:1683, from 2604bb0). It enumerates keys, prints their type, size and flags, and reads readable float T*/P* keys. Nothing in it depends on the SoC, and it is how a machine's sensor keys are found for its device tree.
  • The check that a device tree sensor key is readable and of a type the driver can decode (flt 4 bytes or ioft 8 bytes) ran only on the M3 SoCs (line 866, from c91c5f4). Elsewhere such a key still got a channel that could only ever return -EOPNOTSUPP, because macsmc_hwmon_read_key() decodes only those two types.

Change

  • Create the debugfs inventory on every SoC. It still only queries metadata and reads readable float keys. It writes nothing, does no work until root reads the file, and is debugfs-only (mode 0400).
  • Apply the readable/type check on every SoC and drop macsmc_hwmon_is_m3(), which has no other user. A temperature node on a thermal sensor provider (#thermal-sensor-cells, T8140) keeps its channel slot when it fails, as before, so thermal zones are not renumbered.

Credit: Satya Benson wrote the inventory (2604bb0). Chris Kearney wrote the key checks (c91c5f4).

Testing

  • Compiles clean with the W=1 warning set (drivers/hwmon/macsmc-hwmon.o). See the build log below.
  • Not run on hardware yet.

Still to run

On Neo (J700), J616s, M1 Pro (J316s) and M2 (J413):

  1. ls /sys/kernel/debug/ | grep macsmc and head -3 /sys/kernel/debug/macsmc-hwmon*/keys; wc -l /sys/kernel/debug/macsmc-hwmon*/keys. Expected: the directory exists, and the file lists # N keys followed by N lines.
  2. sensors (or ls /sys/class/hwmon/hwmon*/) compared against the base kernel. Expected: the same channels and labels. A channel that disappears was a key that always failed with -EOPNOTSUPP/-EACCES, and the kernel log names it. If one does, the second commit can be dropped on its own.
  • Neo: pending
  • J616s: pending
  • M1 Pro: pending
  • M2: pending
Reach and safety

Both changes reach every SoC with an SMC hwmon node: T8103, T8112, T6000-T6002, T6020-T6022, T6030-T6034, T8122, T6040/T6041, T6050, T8132, T8140 and T8152. The inventory is passive until read. The key check only removes channels whose reads cannot succeed on any SoC, because the read path rejects every other type.

Build log

Compiled with the release config's kbuild flags plus the W=1 warning set (clang, -fsyntax-only):

== drivers/hwmon/macsmc-hwmon.c  base: 0 warnings, 0 errors | patched: 0 warnings, 0 errors

The full kbuild object build in a clean O= tree is pending and will be added here.

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 <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>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Boot rows on hardware, M1 Pro and M2. These ran on combined test kernels that carry these two commits (7.3.0-aurora-hk2 on the M1 Pro, 7.3.0-aurora-pwr1 = the same plus #2448 on both Macs).

  • M1 Pro (J316s): 142 hwmon channels, same indices and labels as production, thermal zones unchanged, 0 probe errors, s2idle 2/2 on both kernels. The debugfs keys listing works (2038 keys).
  • M2 (J413): 3 channels are gone: SoC die Tg0f, SoC die Tg0n, SoC die Tg0r (production temp43 to temp45). On the production kernel all three read a constant 4607 m°C (4.6 °C on a running SoC, so the value is wrong). With the checks now running on T8112, they get no channel, and the five later SoC die channels move down from temp46..50 to temp43..47 with the same labels. The macsmc_soc_die thermal zone still lists all 8 keys ("8 of 8 listed keys present"), and the zone set is unchanged. 0 probe errors, s2idle 2/2.

The M2 result fits the change, but not the commit message: it says such a channel "could only ever return an error", and on the M2 these three returned a fixed wrong value. It may be worth rewording that before merge, e.g. "returns an error or a meaningless value". Which check drops them (readable flag or size) is not confirmed yet.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Neo (J700) and 14" MacBook Pro M4 Pro (J616s), on combined test kernels carrying these commits: hwmon channel lists are identical to production (Neo 213, J616s 480 channels, same indices and labels), thermal zones are unchanged, 0 probe errors, s2idle 2/2 on each. The debugfs keys listing works on both (Neo 2334 keys, J616s 3462 keys). Neither Mac drops a channel, so the M2 (3 SoC die channels reading a constant 4607 m°C) is the only Mac where this change is visible.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide merged commit 8ff23e2 into integration/aurora Nov 22, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the sweep/macsmc-hwmon 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.

1 participant