Skip to content

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

Open
RyanTheTide wants to merge 5 commits into
mainfrom
sweep/cpufreq-lazy
Open

RyanTheTide wants to merge 5 commits into
mainfrom
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.

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

Copy link
Copy Markdown
Contributor Author

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:

stock this PR
driver / governor, both policies apple-cpufreq / schedutil apple-cpufreq / schedutil
sugov kthreads (0 = fast switch) 0 0
cpu_frequency events in a 6 s single-thread run / from sugov threads 324 / 0 364 / 0
one busy P core, add chain, median GHz 2.523 2.525
all 8 cores, total GHz 18.11 18.08
cpufreq errors, "stopping requests" 0 0

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.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf: a T6050 row for this PR, and a stacked follow-up.

  • What it replaces: our cpufreq: apple: switch T6050 frequencies from the scheduler #2484, which added .lazy_verify = true to T6050 alone. That is now closed in favour of this PR, which gives T6050 the same path through verify_transition.
  • T6050 input (J775c, Mac Studio M5 Max, earlier lobata kernel, 2026-11-05): a transition between 300 MHz or 1.3 GHz and the fastest state takes 12–75 µs at p50 and at most about 100 µs (userspace governor). The sugov kthread ran for 30–58 µs per update in a sched_switch trace. That is the kthread hop this PR removes.
  • Not yet run on this head. lobata's next candidate carries this PR. I'll post the J775c result here.
  • Stacked follow-up: arm64: dts: apple: t6050: describe CPU OPP transition latency (stacked on #2302) #2516 reports that measured 100 µs as T6050's transition latency, so schedutil's rate limit becomes 150 µs instead of 6 ms.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Looks good; approve once T6050 (J775c) has a row on 544c498.

  1. drivers/cpufreq/apple-soc-cpufreq.c:84 and 678: the pending-request retry is scheduled at write_time + APPLE_DVFS_TRANSITION_NS (50 us). After that the verify timer re-arms every APPLE_DVFS_RETRY_NS (4 us, hard-irq, line 635) for as long as BUSY reads set. The 50 us figure is the T8140 transition time (the comment at line 531 says so), and this commit now applies it to T8142, T8152 and T6050. T8152 and T6050 are given a 2 ms transition bound, and on T6050 transitions were reported at up to about 100 us. On those SoCs a request that lands behind a busy transition turns into a 4 us hard-irq poll from about 50 us to the end of the transition, on every burst. Take the retry point from the SoC: from policy->cpuinfo.transition_latency when the OPP table gives one, or from a per-SoC field next to transition_timeout_us. At minimum, fix the line 531 comment, which now states a T8140 number for every verify_transition SoC.

The rest holds up. lock, verify_timer, pending_pstate and cap_pstate are set up for every policy (lines 1505-1510). The lazy deadline uses apple_soc_cpufreq_timeout(), so T8152 and T6050 keep 2 ms. An unexpected PS1 still latches transition_failed (lines 588-590 and 648). Suspend drains and settles a pending request before cpufreq_generic_suspend(). Resume re-reads the state on the same verify_transition condition as before. T8103, T8112, T8132 and the default info have verify_transition false, so nothing changes for them. The posted M2 module-swap row confirms that. CI host-tests pass and the branch merges cleanly.

HW row: J775c (T6050) on 544c498 + integration, the run already offered on this PR. It should show schedutil on every policy with no sugov: kthreads, cpu_frequency events from task context under load, no "stopping requests" or "DVFS busy timeout" through a 10 min mixed load and 3 s2idle cycles, and 0 new kernel errors, 0 AVC and 0 failed units. Neither T8142 nor T8152 has a row. Say so in the PR and ask for one from anyone who has those machines. Also needed: a J700 (T8140) no-regression boot on this head.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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 @544c4981

VERDICT: BLOCKERS

The mechanics are sound. The timer and lock are initialised for every policy (drivers/cpufreq/apple-soc-cpufreq.c:1505-1508). ->exit drains unconditionally (:1572). The lazy deadline uses apple_soc_cpufreq_timeout() (:404-407, :596-597), so T8152/T6050 keep 2 ms and T8142 keeps 400 us. An unexpected PS1 still latches transition_failed (:588-590, :648). No lazy_verify user remains after a merge with b241e35. Non-verify SoCs keep fast_switch_possible = true (:1542), as before.

Blockers:

  1. apple-soc-cpufreq.c:84, :678 and :633-636: a request that finds the cluster busy is retried at write_time + 50 us (the T8140 transition time), then every 4 us from a hard-irq hrtimer until BUSY clears. T8152 and T6050 are described with a 2 ms transition bound, and T6050 was measured at up to ~100 us. On T8152, a transition that really takes ~1-2 ms produces ~250-500 hard-irq timer fires per pending burst per cluster. Each fire takes a raw spinlock with IRQs off and does an MMIO read. That can easily cost more than the sugov kthread hop this PR removes. The retry point should come from the SoC (policy->cpuinfo.transition_latency or a field next to transition_timeout_us). The reviewer raised this on this exact head (RyanTheTide 11-21) and it is unaddressed, including the :531 comment that now states the T8140 50 us figure for every verify_transition SoC.
  2. No row on any SoC whose behaviour changes (T8142, T8152, T6050). The rows posted (J413, J316s, J616s) are on SoCs without verify_transition, where the diff does nothing. The reviewer's own approval condition, a T6050/J775c row on 544c498, has not been met. T8152 also gains the immediate fast-die cap path (:1025), which is a thermal-safety path, without a row.

Nits:

  • The body and the existing comment at :309 say "CLPC/PMP". CLPC is the macOS internal name for the performance controller. The comment predates this PR, but don't repeat it in new text.
  • Neo T8140: the code path is identical (it only swaps the flag for its alias), so the missing Neo row is low risk. It is still listed as "Still to run".

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.

@satchlj

satchlj commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf. J775c (Mac Studio M5 Max, T6050) row for this PR's drivers/cpufreq/ at 544c4981. This is the run offered on 11-20.

What was booted: this is not an exact-head tree.

  • The kernel is lobata's cand-15 (2ed7977aa07c = integration/aurora plus our open PRs, which carried this PR plus our stacked T6050 latency commit afba7661), with afba7661 reverted (eb4a446cfbe2).
  • git diff --stat eb4a446cfbe2 544c49819597 -- drivers/cpufreq/ is empty, so the cpufreq directory is identical to this head. The rest of the tree differs from the PR branch.
  • Default cmdline, one one-shot boot (004beb8c), nothing installed.

Results

Check Result
Driver / governor apple-cpufreq / schedutil on all three policies (0-5, 6-11, 12-17)
sugov: kthreads 0 (fast switch)
cpuinfo_transition_latency / schedutil rate_limit_us 4,000,000 ns / 6000. There's no OPP clock-latency-ns in this DT, so it is derived from the 2 ms timeout
6 s bursty single-thread window, cpu_frequency events 1,218. Emitting context: 180 task (d..3.), the rest from scheduler hooks in hard or soft IRQ (d.h*, d.s*). By comm: <idle> 1,026, dd 96, bash 18, others ≤12. None from a sugov thread
Mixed load, 600 s 7-Zip at 1, 4 and 18 threads in turns, plus a bursty dd thread with idle gaps
"stopping requests", "DVFS busy timeout", "DVFS completion timeout", "unexpected DVFS state" 0 through the load and after each s2idle
s2idle 3/3 rtcwake -m freeze -s 12, rc 0. After each, a 5 s burst moves all three policies, with 0 lines
7-Zip 1T after the cycles 13,546
AVC / failed units / new kernel errors 0 / 0 / 0. The 9 error lines are the known DCP lane-count/clock and speakers-off lines

Blocker 1 cost on T6050. I counted fires of apple_soc_cpufreq_verify (the hard-IRQ hrtimer callback) with a kprobe (p:apsverify apple_soc_cpufreq_verify, kprobe_profile hit counts). The candidate has CONFIG_KPROBE_EVENTS; lobata's default kernel does not.

  • 6 s window: 202 fires for 1,218 frequency events, so 0.16 fires per event. 160 of them in hard IRQ.
  • Re-arms: only 3 fires came within 10 µs of a previous fire on the same CPU, which is the 4 µs APPLE_DVFS_RETRY_NS chain.
  • 600 s mixed load: 23,822 fires, about 39 per second across 18 CPUs.
  • Reading: on T6050 most requests find the cluster idle, so the 50 µs retry point rarely turns into a poll chain. T6050 transitions measured 12–75 µs at p50 and at most about 100 µs.
  • Not covered: this says nothing about T8152. If its transitions take the 1–2 ms its bound allows, the per-SoC retry point you asked for still matters there.

Evidence is in lobata's session notes (claude-cand15-2302-*).

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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.

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formal pre-PR review (§1–§6) at 544c49819597c0f456f947a1f7058a35e2b30da5: REQUEST_CHANGES.

Verified Clean

  • Core lazy-verify mechanics: Dropping lazy_verify and keying on verify_transition keeps lock, verify_timer, pending_pstate, cap_pstate initialized for every policy (drivers/cpufreq/apple-soc-cpufreq.c:1505-1510), preserves per-SoC deadlines via apple_soc_cpufreq_timeout(), latches transition_failed on unexpected PS1 (:588-590, :648), and drains/settles in ->set_target, ->suspend, and ->exit.
  • Integration check (70a00e583b03): Checked against newly landed 8b5a4e4c836e (drivers/cpufreq/apple-soc-cpufreq-test.c) — no direct info->lazy_verify references break compilation.
  • §4 Attribution / CI: Commit 544c49819597 carries human author/committer and Signed-off-by: only (zero AI commit trailers); live CI (Host tests) is green.

Blockers

  1. §1/§2 (Hardcoded T8140 retry timing on 2 ms-bound SoCs): drivers/cpufreq/apple-soc-cpufreq.c:84, 531, 633-636, 677-680 still schedule a pending-request retry at write_time + APPLE_DVFS_TRANSITION_NS (50 µs, the T8140 transition time) and then re-arm the hard-IRQ hrtimer every APPLE_DVFS_RETRY_NS (4 µs) while BUSY stays set. While @satchlj's J775c (T6050) kprobe measurement showed few 4 µs retry chains on T6050 (12–75 µs typical transitions), T8152 has a 2 ms bound and unmeasured transition times; a 1–2 ms transition behind a pending request would fire ~250–500 hard-IRQ timers per burst (each taking raw_spin_lock_irqsave + MMIO read). Derive the initial retry point from the SoC's transition latency (policy->cpuinfo.transition_latency when supplied, or a per-SoC field next to transition_timeout_us), and update the line 531 comment that states T8140's 50 µs for every verify_transition SoC.
  2. §3/§5 (Missing hardware rows for affected SoCs, including thermal-safety path on T8152):
    • @satchlj's J775c (T6050) row (eb4a446cfbe2, matching drivers/cpufreq/ on a combined tree) is clean, and J413/J316s/J616s are unaffected (verify_transition = false).
    • T8152 (M6, J873g) has zero hardware evidence, even though it gains both lazy fast-switch AND immediate apple_fast_die_cap() (:1025, a §3 thermal-safety path).
    • T8142 (M5) has zero hardware evidence despite switching from waited kthread to lazy fast-switch.
    • T8140 (Neo, J700) no-regression row is still listed as pending.
    • After fixing blocker #1, re-prove on the updated exact head (default cmdline): J775c (T6050), Neo (T8140) no-regression, and T8142/T8152 rows (schedutil fast-switch with 0 sugov: kthreads, verify-timer fire counts under load, thermal cap check on T8152, s2idle, and 0 AVC / 0 failed units / 0 new kernel errors), or explicitly note and request tester runs for unavailable machines per §1/§5.

Non-blocking Nit

  • Avoid repeating the macOS internal name CLPC in new PR text (§4/§6).

@github-actions github-actions Bot added area:power Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

ghost commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 17e6b446: not ready yet

Check Detail
CI at head running running: host-tests
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 17e6b446, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:power

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 544c49819597

Blockers:

  1. drivers/cpufreq/apple-soc-cpufreq.c:84, 531, 633-636, 677-680: now that every verify_transition SoC takes the lazy path, the pending-request retry is still scheduled at write_time + APPLE_DVFS_TRANSITION_NS, which is T8140's 50 µs, and re-armed every 4 µs while BUSY stays set. On a SoC whose transitions take longer (T8152's bound is 2 ms), that is hundreds of hard-IRQ timer runs per transition. Fix: take the first retry point from the SoC's own transition latency (policy->cpuinfo.transition_latency, which comes from the OPP table's clock-latency-ns, as #2516 adds for T6050), or a per-SoC field next to transition_timeout_us. Update the comment at :531 too.

Checked: no Apple material. Dropping lazy_verify and keying on verify_transition keeps the lock, timer and pending state set up for every policy and keeps the per-SoC deadlines. An unexpected PS1 still latches transition_failed. Rows: M2 (J413) no regression, and J775c (T6050) clean at this head's driver. CI green. This replaces my earlier review; this is the only blocker. #2516 is stacked on this PR.

Evidence

Read 544c4981 and Ryan's 11-21/22 notes and satchlj's J775c row.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:38

Superseded by the review at 544c498

Ryan Murray added 2 commits November 27, 2026 16:31
…wn latency

Review follow-up. With every verify_transition SoC on the lazy path, a
request that finds the cluster busy was retried at write_time + 50 us,
T8140's transition time, and then every 4 us while BUSY stayed set. On
a SoC whose transitions take longer (T8152 and T6050 allow 2 ms), that
is hundreds of hard-IRQ timer runs per transition.

Take the first retry point from the SoC: the OPP table's
clock-latency-ns when the tree has one, otherwise an eighth of the
SoC's transaction timeout, which is 50 us for the default 400 us and
keeps T8140 where it was. While the transition stays busy, the re-check
interval starts at 4 us and doubles up to that point, so a 2 ms
transition costs about eight timer runs.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 27, 2026 06:54
@RyanTheTide

ghost commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Fixed at 1b4b8f8 (fix commit c1b6d1c plus a merge of main, normal push).

Blocker 1 (retry timed from T8140's 50 µs, re-armed every 4 µs): the first retry point is now priv->transition_ns. That is the OPP table's clock-latency-ns when the tree has one (#2516 adds it for T6050), otherwise an eighth of the SoC's own transaction timeout. For the default 400 µs that is 50 µs, so T8140 behaves as before; T8152/T6050 (2 ms) get 250 µs. Today none of the four verify_transition SoCs has clock-latency-ns, so taking cpuinfo.transition_latency directly would have moved the Neo's first retry from 50 µs to 800 µs. While BUSY stays set, the re-check interval starts at 4 µs and doubles up to transition_ns (reset on each write), so a 2 ms transition costs about 8 timer runs, not about 500. The "Lazy verification" comment says all this.
Testing: builds in the fleet-config kernel 7.3.0-aurora-fixa2 (this PR's file byte-identical to its head). checkpatch is clean.
Still to run: Neo (T8140) row at this head: the lazy path under schedutil load plus 3 s2idle, no transition_failed. #2516 stays stacked.

@RyanTheTide

ghost commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Row at 1b4b8f8e5bd2 (this PR's files byte-identical in the combined test kernel 7.3.0-aurora-fixa2): M1 Pro (J316s, T6000/G13S): PASS, M2 Air (J413, T8112/G14G): PASS.

These SoCs don't take the lazy-verify path, so this is the no-regression row only. The T8140 (Neo) row is still owed.

Detail

Both rows ran on the default cmdline with the kernel booted once as a non-default entry, then back to fleet89, which was verified afterwards (saved entry, empty next_entry, kernel removed, 0 failed, Enforcing). Per Mac: SELinux Enforcing, 0 failed units, 0 AVC, 0 err-level kernel lines, 0 oops; Wi-Fi ping OK; s2idle (rtc1, 15 s) rc=0 with ping and a 64 MiB direct NVMe read after the wake; Apple SoC watchdog armed with time left counting (44 s and 58 s of systemd's 60 s); dEQP-VK api.smoke 8/8 pass. J413 also: glmark2 off-screen (FBO) score 7672, 2 audio sinks. On the M1 Pro, glmark2-wayland never starts rendering: its internal panel is dead and there is no Wayland output, the same on fleet89 (traced), so no GL FBO number there. Silent, no playback. Logs: traces/kernel/20261127-fixa2-rows/ (store).
Kernel kit: kits/test/20261127-fixa2 = main 0a4f97d + forward-merged heads of #2919 #2886 #2302 #2475 #2393 #2384 #2895.

@RyanTheTide

ghost commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Row at 1b4b8f8e5bd2 (byte-identical in 7.3.0-aurora-fixa2): Neo (J700, T8140/G17P): PASS.

This is the T8140 lazy-verify row: under schedutil with 30 rounds of 300 ms two-thread bursts, the two policies made 4064 and 2022 transitions with no transition_failed and no cpufreq/DVFS failure line; the frequency follows the load (policy0 744 MHz idle, 4044 MHz under load). cpuinfo_transition_latency reads 800 µs, the fallback bound, since the Neo has no clock-latency-ns; the retry point is 50 µs (400 µs / 8), as before.

Detail

Neo (J700, T8140/G17P), fixa2 booted once as a non-default BLS entry, then back to fleet89, verified afterwards (saved entry, empty next_entry, kernel removed, 0 failed, Enforcing). SELinux Enforcing, 0 failed units, 0 AVC, 0 oops, 0 err-level kernel lines; Wi-Fi up; G17P Vulkan device; dEQP-VK api.smoke 8/8 and draw.renderpass.simple_draw 4/4; watchdog armed (57 s left of 60); s2idle on rtc0 rc=0 with a 64 MiB direct NVMe read after the wake. Two lines are the same on fleet89 (baseline traced): the boot-time "G17: crash logs from the firmware data segment" note, and Wi-Fi needing ~9 s after the wake before ping answers. Logs: traces/kernel/20261127-fixa2-rows/neo/ (store).

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 1b4b8f8e

Blockers:

  1. Requires independent maintainer approval before merge (and optional confirmation row on a newly enabled verify_transition SoC such as T6050 or T8142 if desired).

Checked:

  • drivers/cpufreq/apple-soc-cpufreq.c: commit c1b6d1c0 cleanly resolves the earlier hardcoded 50 us retry blocker by setting priv->transition_ns from dev_pm_opp_get_max_transition_latency(cpu_dev) (which returns 0 when absent) falling back to apple_soc_cpufreq_timeout(info) / 8, and exponentially doubling priv->retry_ns from APPLE_DVFS_RETRY_NS (4 us) up to priv->transition_ns while busy.
  • Drops the T8140-only lazy_verify flag in favor of keying on verify_transition uniformly across set_target, suspend, fast_switch, apple_fast_die_cap, and init.
  • Hardware rows & CI: 3/3 CI green (SUCCESS), MERGEABLE on main; exact-head rows posted on J700 (T8140 lazy-verify 4064/2022 transitions, 0 failures), J316s (M1 Pro), and J413 (M2 Air).
  • Checked for Apple material, tool attribution, private serials, and SoC gating: clean; human Signed-off-by present.
Evidence
  • Head: 1b4b8f8e5bd2 (base: main, mergeable: MERGEABLE, +62/-33, 3/3 CI green).
  • Non-blocking nit: if a future OPP table specifies clock-latency-ns smaller than APPLE_DVFS_RETRY_NS (4 us), min(priv->retry_ns * 2, priv->transition_ns) would step below 4 us; clamping transition_ns with max(..., (u64)APPLE_DVFS_RETRY_NS) would prevent that.

satchlj
satchlj previously approved these changes Nov 28, 2026

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified at exact head 1b4b8f8e5bd21ee5658ccae79d8c61676b3a61cf on Apple M5 Max (J775c, T6050) (newly enabled verify_transition SoC):

  • Code audit: Removing the separate lazy_verify flag and gating lazy fast-switch verification, ->target_index drain, suspend settle, and fast die-temperature capping on verify_transition is consistent across all paths. Computing priv->transition_ns from dev_pm_opp_get_max_transition_latency() (falling back to timeout / APPLE_DVFS_TRANSITION_DIV) and exponentially backing off priv->retry_ns from APPLE_DVFS_RETRY_NS up to priv->transition_ns (reset on every apple_soc_cpufreq_lazy_write()) cleanly resolves the earlier T8140-specific retry-timing review finding.
  • Live T6050 verification (1b4b8f8e5bd2, one-shot Aura trial with carried J775c DTB, 0 failed systemd units):
    • All 3 T6050 policies (policy0 CPUs 0–5, policy6 CPUs 6–11, policy12 CPUs 12–17) bound to apple-cpufreq under schedutil with 0 sugov kthreads (fast_switch_possible = true active).
    • 30 rounds x 300 ms 18-thread bursts (150 ms idle gaps): policy0 432 -> 688 (+256), policy6 425 -> 688 (+263), policy12 649 -> 1005 (+356) transitions.
    • ->target_index drain path (schedutil -> performance -> powersave -> schedutil on all 3 policies): clean (690 / 693 / 1013 total transitions).
    • dmesg: 0 transition_failed, 0 cpufreq/DVFS warnings or kernel faults.

Verdict: MERGE at 1b4b8f8e5bd2 (once the older 544c4981 CR is cleared).

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 28, 2026
@DjDeveloperr

ghost commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

One blocker remains at 1b4b8f8e. The first retry now uses the SoC’s transition time, and the driver comment explains it. In drivers/cpufreq/apple-soc-cpufreq.c:709-718, a request that replaces an already pending P-state can still pull the queued timer forward to 4 µs from now. That undoes the backoff at lines 660-664.

For example, on T8152 the timer can fire 262 µs after the write and schedule its next check for 278 µs. A replacement request at 263 µs moves that check to 267 µs even though the hardware is still processing the same write. In a timing model with BUSY held for 2 ms, replacing the pending target every 8 µs from that point gives 220 timer callbacks before BUSY clears. A single pending target gives 12.

Please keep the queued retry’s expiry when replacing an already pending target. The first pending request should still be able to bring the ordinary verification timer forward.

Main gave T6050 lazy_verify and added two lazy_verify checks (the non-fast-switch target path and policy-bounds verification) plus a KUnit fixture that reads it. This branch keys lazy verification on verify_transition for every SoC, so T6050 drops lazy_verify and those checks and the fixture use verify_transition. Without this the merged tree does not build, although GitHub reports no text conflict.

Signed-off-by: DjDeveloperr <[email protected]>

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 075213d8ec92

Blockers:

  • Unaddressed review finding from 2026-11-30: A replacement request while a P-state is already pending in drivers/cpufreq/apple-soc-cpufreq.c still pulls the queued verify timer forward to 4 us from now, undoing the exponential backoff when the hardware remains BUSY.
  • Hosted CI at 075213d8ec92 is still queued/pending (3 queued, 1 pending): wait for build, host-tests, pr-text, readiness, and apple-soc-cpufreq KUnit to pass green.

Checked:

  • Audited merge commit 075213d8ec92 (MERGEABLE against main, 2 files +66/-38): cleanly converts main's new lazy_verify references (including apple-soc-cpufreq-test.c) to verify_transition so the merged tree builds cleanly without dropping any of main's new checks.
Evidence
  • Head: 075213d8ec923b5fd29d589f042c271e1ffa0c10 (base main, MERGEABLE).
  • Prior J700 (T8140) and J775c (T6050) hardware rows remain on file for 1b4b8f8e.

@RyanTheTide

ghost commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Merge-up review (our own PR, so no approval from this account): conflict-pass merge commit 075213d: compile fix checked: the lazy_verify field is fully renamed to main's verify_transition (only a test-case name keeps the old word); retry_ns backoff is initialised on both init paths. Nothing outside the conflict. Needs a non-author approval plus CI and rows at this head before merge.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Dec 1, 2026

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My one blocker is fixed: busy-transition retries now start at the SoC's own transition latency (the OPP clock-latency, or an eighth of its timeout) and back off from there.

Main had since given T6050 lazy_verify and added two checks on it, so the merge at 075213d8 moves those checks onto verify_transition, as this branch does for every SoC. Without that, the merged tree didn't build. The driver builds with and without its KUnit suite. Left before merge: J413 and J775c rows at this head.

@github-actions github-actions Bot removed the changes-requested A reviewer requested changes (bot) label Dec 1, 2026
Main's 848ee92 gave T8142 .lazy_verify = true. This branch folds that
flag into .verify_transition (every verifying SoC checks lazily on fast
switch), so the T8142 entry drops the field and its KUnit case drops the
matching assertion. T8142 behaviour is unchanged.
@RyanTheTide

ghost commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Merge-up pushed at 17e6b44623b6. It merges main (d148fbda) into this branch. main's 848ee92 gave T8142 .lazy_verify = true, and this branch folds that flag into .verify_transition, so the merge drops the T8142 .lazy_verify line and its one KUnit assertion. T8142 behaviour is unchanged. Without this the merge with main fails to compile at apple-soc-cpufreq.c:336.

Checked: the cpufreq KUnit suite on arm64 QEMU passes (74 tests: 70 passed, 4 skipped), and drivers/cpufreq compiles.

Correction: the B2-MERGE lane (Ryan's merge train) made this merge commit, not @DjDeveloperr. My script copied the committer identity from the previous commit on the branch, so the commit is mislabelled as Dj's. It can't be rewritten without a force push. Dj's approval at 075213d8 covers the code up to the merge-up; this head needs one re-check of the 2-line resolution.

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 17e6b44

Checked (merge resolution against main d148fbd, which already has lazy_verify on T8140/T8142/T6050):

  • lazy_verify is folded into verify_transition at every use: get_rate, verify_policy, set_target drain, suspend, fast_switch, fast-die cap, plus fast_switch_possible = true. On main the only verify_transition SoC without lazy_verify is T8152, so T8152 is the one SoC whose behaviour changes: it gets the fast-switch path with its own 2000 us timeout as the deadline. T8140/T8142/T6050 keep their current lazy path.
  • The new busy-retry backoff (retry_ns from 4 us, doubling up to transition_ns, reset on each write) starts its first re-check at transition_ns after the write. transition_ns is the OPP table's max clock-latency-ns, or timeout/8 (50 us for 400 us). Tried to make min(retry_ns * 2, transition_ns) shrink the interval below 4 us: that needs a table max under 4 us. The only sub-4 us latencies in Apple DTs are on s8003/t7000/t7001, which aren't verify_transition SoCs, and t8140.dtsi has no clock-latency-ns, so it uses the 50 us fallback.
  • The deadline, failure stop and pending-replacement logic are unchanged. B2 reports cpufreq KUnit 70 pass / 0 fail / 4 skip at this head.

Follow-ups (not blocking):

  • Clamp transition_ns to at least APPLE_DVFS_RETRY_NS in init, so a future OPP table with a tiny max latency can't turn the backoff into a sub-4 us re-arm loop.
  • T8152 (and T8142/T6050) fast-switch still has no hardware row in our lab, as the PR says.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:power Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants