Repository navigation
cpufreq: apple-soc: verify every SoC's transitions lazily on fast switch - #2302
RyanTheTide wants to merge 1 commit into
Conversation
Lazy verification was enabled by a separate lazy_verify flag set only on T8140. The other SoCs whose command register reads back the accepted state (T8142, T8152, T6050) still waited about a transition per request on every frequency change, and so kept schedutil off the fast-switch path: every change woke the governor kthread, which then busy-waited on the register. Nothing in the lazy scheme is specific to T8140. It needs what verify_transition already describes: a command register whose PS1 field reads back the accepted state and a BUSY bit. It uses the per-SoC transition timeout for its deadline, so T8152 and T6050 keep their 2 ms bound, and it still stops all requests when the accepted state is not the one last written, so an unexpected owner is caught as before, one request later. Waited-for requests (initial check, static governors) are unchanged; suspend first settles a pending request, as on T8140. Drop lazy_verify and key the lazy path on verify_transition. Every policy can now switch from the scheduler, and a lowered fast die-temperature limit is applied to the cluster at once on all of them, as on T8140. The lazy scheme itself is Diljit Singh's. Fixes: b11a5e9 ("cpufreq: apple: verify T8140 transitions on the next request") Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
M2 (J413, T8112) no-regression row: pass. This PR's patch on the production fleet74 driver source (1f710d2), built as a module and swapped in at runtime, compared with the stock module on the same boot:
s2idle x2 on rtc1 with this PR's module: 2/2 clean, no cpufreq messages after, one busy P core at 2.529 GHz after resume. Stock module restored. |
|
Claude Opus 5.5 on @satchlj's behalf: a T6050 row for this PR, and a stacked follow-up.
🤖 Generated with Claude Code |
|
Looks good; approve once T6050 (J775c) has a row on 544c498.
The rest holds up. HW row: J775c (T6050) on 544c498 + integration, the run already offered on this PR. It should show schedutil on every policy with no Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge-train adversarial review (MERGETRAIN-LINUX2) at 544c498: BLOCKERS. Not merging until the blockers below are fixed or answered; the details give file:line and a failure case. Full review#2302 cpufreq: apple-soc: verify every SoC's transitions lazily on fast switch @544c4981VERDICT: BLOCKERS The mechanics are sound. The timer and lock are initialised for every policy (drivers/cpufreq/apple-soc-cpufreq.c:1505-1508). Blockers:
Nits:
Missing rows: T6050 (J775c, from satchlj, pending), T8152 (J873, an M6 owner) with a transition-latency and hard-irq count under schedutil load, T8142 (J704/J813, an M5 owner), and the Neo T8140 no-regression row. |
|
Claude Opus 5.5 on @satchlj's behalf. J775c (Mac Studio M5 Max, T6050) row for this PR's What was booted: this is not an exact-head tree.
Results
Blocker 1 cost on T6050. I counted fires of
Evidence is in lobata's session notes ( Assisted-by: LLM (Anthropic:Claude Opus 5.5) |
|
The J775c (T6050) row is in and clean. Still needed: take the pending-request retry point from each SoC's transition latency instead of the T8140 50 us (and fix the comment that states it for every SoC), then T8152 and T8142 rows under schedutil load with the verify-timer fire count, plus the Neo no-regression row. |
Problem
Lazy transition verification on the fast-switch path is enabled by a
lazy_verifyflag that onlysoc_t8140_infosets (drivers/cpufreq/apple-soc-cpufreq.c:300, from b11a5e9 "cpufreq: apple: verify T8140 transitions on the next request"). The other SoCs withverify_transition(T8142, T8152, T6050) getfast_switch_possible = false(line 1540). On them every schedutil frequency change wakes the governor kthread, which then busy-waits for the transition.Change
Drop
lazy_verifyand key the lazy path onverify_transition, the match-data property that says the command register's PS1 field reads back the accepted state. Every policy now setsfast_switch_possible = true.The lazy path needs nothing beyond what
verify_transitionalready requires: the BUSY bit and the PS1 readback. Its deadline is the per-SoC transition timeout, so T8152 and T6050 keep their 2 ms bound. It still stops all requests when the accepted state is not the one last written, so an unexpected owner is caught as before, one request later. Waited-for requests (initial check, static governors, suspend) are unchanged.The lazy verification scheme is by Diljit Singh (b11a5e9 and follow-ups); this only extends it to the SoCs that already verify transitions.
Testing
Build:
drivers/cpufreq/apple-soc-cpufreq.owith W=1 (arm64, LLVM=1, release config): builds, no warnings.SoCs that gain fast switch (T8142, T8152, T6050) are not bootable in our lab; the safety argument is from code and DT review below.
Hardware (one-shot test kernel 7.3.0-aurora-swl1 = integration 0abc2f3 + this and the other open sweep PRs, 2026-11-20):
Still to run
cat /sys/devices/system/cpu/cpufreq/policy*/scaling_driver=apple-cpufreq; schedutil active;cpu_frequencytrace events under load from task context (nosugov:kthread wakeups); no "stopping requests" in dmesg.verify_transitionand already used fast switch.Per-SoC impact and safety
m6_pm_cpufreqin t8152-j873g.dts), so one policy owns each command register. It has a fast die-temperature limit; a lowered limit is now also applied to the cluster at once, as on T8140.apple,firmware-managed-thermal); the resume path that re-reads the state after a firmware sleep already ran for everyverify_transitionSoC.Not changed here
of_machine_is_compatible("apple,t8112")in module init): measured, turbo states do not raise the delivered P-core clock there. Its reason is in the comment.needs_thermal_owner, which only T8132 sets. It could be derived from match data, but those lines are the context of the open boost-control change (cpufreq: apple-soc: offer no boost control without turbo-mode OPPs #2199), so it is left for after that lands.Assisted-by: LLM (Claude:Opus 5.5)