Repository navigation
power: supply: macsmc: report the adapter's input power as power_now - #2372
Conversation
The AC supply tells how much the adapter may deliver (input_power_limit, from ACPW) but not how much the system takes from it now. The SMC has that too: PDTR is the DC-in power in watts, the "In" value of the driver's own log_power debug output. On a 16-inch MacBook Pro (M4 Pro, J616s) on a 15 W USB-C source, PDTR read 12.92 W while the SMC's system power read 6.2 W and the battery took 6.7 W, so PDTR is the input that feeds both. Report it as power_now on the AC supply when the key exists. With the battery's own power_now this gives the adapter's headroom and the charge rate without the debug log. Read it through a helper and test the float conversion with KUnit. Signed-off-by: Ryan Murray <[email protected]>
|
No blockers.
HW row: the existing rows swapped the module in at runtime. Add one boot of the fleet kernel with this commit built in on any of the three Macs, default command line: Assisted-by: LLM (Claude:Opus 5.5) |
|
No blockers in review; the one thing still needed is a boot of the fleet kernel with this commit built in (not a module swapped in at runtime) on a T6000, T8112 or T6040 Mac, with the default command line, showing macsmc-ac/power_now present and tracking the adapter. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at 969abb4. The AC power supply advertises POWER_NOW only when the SMC reports the PDTR key. The existing adapter-capacity property stays separate from the live reading. The host suite covers scale, zero and read errors. Please include an unplug/replug row on J413 that maps unsupported and unplugged behavior, and a positive live adapter reading alongside battery power. These are different physical quantities.
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at 969abb49d0662bd805b7152b99080c7b8287d38c:
Code and tests look clean and still apply cleanly to integration/aurora (not superseded):
- §1 No model gating: Pass.
POWER_SUPPLY_PROP_POWER_NOWis registered onmacsmc-acstrictly viaapple_smc_key_exists(power->smc, SMC_KEY(PDTR))(5 of 10MACSMC_MAX_AC_PROPSslots used). - §2 Production-ready, no hacks: Pass. Verified
apple_smc_read_f32_scaled(..., 1000000): max 24-bit mantissa × 10⁶ is 44 bits (nou64intermediate overflow),0.0f/subnormals yield0, 140 W+ fits comfortably withinINT_MAX(~2147 W in µW), and read errors propagate cleanly.host-testsCI passes and the newmacsmc-power-acKUnit suite checks scaling, zero, and-EIO. - §3 Safety: Pass (read-only SMC telemetry).
- §4 Clean-room and attribution: Pass. Commit
969abb49d066has human author/committer (Ryan Murray <[email protected]>) and humanSigned-off-by:only, zero AI trailers in commit; PR body includesAssisted-by:. - §6 Naming: Pass.
Blocker:
- §5 Evidence (Blocker): All three reported Mac runs (J413, J616s, J316s) used a runtime-swapped
macsmc-power.komodule onfleet74/fleet75rather than booting a kernel built with this commit on the default command line, did not include the §5 regression check (0 SELinux denials / 0 AVC, 0 failed units, 0 new kernel errors), and did not record unplug/replug behavior (macsmc-ac/power_nowunplugged vs plugged alongsidemacsmc-battery/power_now).
Please add one full-boot row on a T6000, T8112 (e.g., J413), or T6040 Mac with this commit built into the kernel on the default command line, covering plugged and unplugged macsmc-ac/power_now readings alongside macsmc-battery/power_now plus the regression check (0 AVC, 0 failed units, 0 new kernel errors).
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 969abb49d066
Blockers: none.
Checked: no Apple material, no gates. PDTR is the sum of the system and battery legs, so it's the adapter's input, and the property only appears when it's read. Rows at this head's code: J616s (In 12.92 W against Sys 6.2 + Batt 6.7 W), J413 (power_now 2.32–2.35 W matching log_power) and J316s, each with the module built from this commit. A module built from the head counts as the row; a full kernel boot isn't needed for a driver module. KUnit test added, CI green. This replaces my earlier review.
Evidence
Read 969abb49 (macsmc-power.c, macsmc-power-test.c) and the three rows. A plugged/unplugged comparison of macsmc-ac/power_now is a check after the merge.
Superseded by the review at 969abb4
Problem
The macsmc AC supply reports how much the adapter may deliver (
input_power_limit) but not how much the Mac takes from it. You can't see the charge rate against the adapter's headroom without turning on the driver's debug log.Change
The SMC already has the input power: PDTR, the DC-in power in watts. It is the "In" value that the driver's
log_powerdebug output prints. When the key exists, it is now reported aspower_nowonmacsmc-ac. The read goes through a small helper, and a new KUnit suite,macsmc-power-ac, checks the float conversion and error handling.Every machine gets this through key presence at probe. There is no board or SoC check.
Testing
log_poweron for 40 s: In 12.92 W, Sys 6.2 W, Batt 6.7 W. PDTR is the sum of the system and battery legs, so it is the adapter's input.macsmc-ac/power_nowread 2.32-2.35 W whilelog_powerprinted In 2.32-2.35 W (battery full, 0 W), and the property appears only with the test module. The stock module was put back afterwards.power_now12.94 W against In 12.94-12.95 W while the battery took 6.7 W.power_now3.39-3.47 W against In 3.42-3.47 W (battery full).macsmc-power1/1,macsmc-power-charge14/14 and the newmacsmc-power-ac1/1 passed; 35 tests run in total, 34 passed, 1 skipped (a GPU test that needs CONFIG_UCLAMP_TASK).Still to run
Nothing on our machines: rows done on T6000, T8112 and T6040. Other SoCs get the property only where the SMC has PDTR.
Reviewer detail
apple_smc_read_f32_scaled()at a scale of 1e6, so the value is in µW as power_supply expects. 140 W fits in an int with room to spare.apple_smc_key_exists(PDTR), the same way the driver already handles ACPW and the legacy AC-n/AC-i keys.macsmc_do_dbg()already prints as "In" (Hector Martin's debug mode, dbg print added in dbfcab8).