Skip to content

cpufreq: apple-soc: verify every SoC's transitions lazily on fast switch - #2302

Open
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
sweep/cpufreq-lazy
Open

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
sweep/cpufreq-lazy

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Lazy transition verification on the fast-switch path is enabled by a lazy_verify flag that only soc_t8140_info sets (drivers/cpufreq/apple-soc-cpufreq.c:300, from b11a5e9 "cpufreq: apple: verify T8140 transitions on the next request"). The other SoCs with verify_transition (T8142, T8152, T6050) get fast_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_verify and key the lazy path on verify_transition, the match-data property that says the command register's PS1 field reads back the accepted state. Every policy now sets fast_switch_possible = true.

The lazy path needs nothing beyond what verify_transition already 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.o with 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):

    • T8112 J413 and T6000 J316s (no verify_transition, no change expected): boot + 20 s idle + 3 s2idle cycles (rtcwake, ~20 s each, rc=0): 0 kernel errors, 0 SError, 0 failed units, 0 AVC; apple-cpufreq on every policy, no 'stopping requests'.
    • T6040 J616s: same, 3 s2idle clean.

Still to run

  • Neo (T8140, J700): no-regression row. cat /sys/devices/system/cpu/cpufreq/policy*/scaling_driver = apple-cpufreq; schedutil active; cpu_frequency trace events under load from task context (no sugov: kthread wakeups); no "stopping requests" in dmesg.
  • J616s (T6040), M1 Pro (T6000), M2 (T8112): no-regression only. These SoCs have no verify_transition and already used fast switch.
Per-SoC impact and safety
SoC Boards (DT) verify_transition Before After
T8140 t8140.dtsi (Neo) yes lazy, fast switch same
T8142 t8142-j704, t8142-j813-j815 yes waited, governor thread lazy, fast switch
T8152 t8152-j873g yes waited, governor thread lazy, fast switch
T6050 t6050-j716s, t6050-dieX yes waited, governor thread lazy, fast switch
T8103/T600x, T8112/T6041, T8132, S5L8960X, generic many no fast switch same
  • T8142: firmware keeps CLPC/PMP ownership. A firmware change to the request is still detected as an unexpected state and latches the failure, as before.
  • T8152: P and M CPUs share one performance domain (m6_pm_cpufreq in 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.
  • T6050: firmware owns thermal limits (apple,firmware-managed-thermal); the resume path that re-reads the state after a firmware sleep already ran for every verify_transition SoC.
  • Suspend on these SoCs now settles a pending request before the generic suspend, as on T8140.
Not changed here
  • Boost off by default on T8112 (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.
  • T8132 online/offline lifecycle in module init: tied to 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)

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>
@RyanTheTide
RyanTheTide marked this pull request as ready for review November 19, 2026 21:28
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