Skip to content

soc: apple: clpc: enable on-time idle sampling on T8132 - #3882

Merged
DjDeveloperr merged 2 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-clpc-t8132-idle-on-time
Dec 3, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-clpc-t8132-idle-on-time

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: Enable idle_on_time on apple_clpc_hw_t8132 in drivers/soc/apple/clpc.c (matching apple_clpc_hw_t6041, apple_clpc_hw_t6050, and apple_clpc_hw_t8142) so single-threaded memory-bound workloads waking from a short sleep do not sit at DCS 0 / fabric 0 waiting on deferrable idle_work, while per-CPU deferrable idle timers keep idle NO_HZ CPUs at zero CLPC wakeups. Update the T8132 KUnit table check and tools/asahi/clpc-gpu-demand-tests.py assertions to match.

Tested:

  • Offline on aurora-silicon/linux main (2225082e1, branch j604-clpc-t8132-idle-on-time, head e9c20ef1b0b3, merged cleanly with main b902937859ec at 491e031bb680):
    • tools/asahi/clpc-gpu-demand-tests.py: PASS (2 positive suites + 47 negative controls, 0 failures).
    • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks (41 lines checked).
    • ARM64 LLVM=1 W=1 (clang 23.1.5): drivers/soc/apple/clpc.o 0 warnings (368464 bytes).
    • ARM64 QEMU KUnit (KASAN+UBSAN, drivers/soc/apple/clpc.kunitconfig): apple-clpc-gpu 15/15 passed (0 failed, 0 skipped), including apple_clpc_t8132_gpu_input_test.
  • Prior J604 (M4 MacBook Pro 14", T8132) hardware run with .idle_on_time = true enabled (linux-aurora 7.3.0.aurora1-1.1683, boot 5440e161): PMP events 0, idle die 34.0 C, deep sleep suspend/wake PASS (rc=0), 0 kernel faults, 0 failed systemd units.
  • Exact-head J773g (T8132) hardware row posted at 491e031bb680 (comment #7366257374): PASS.

Risk: two-way · M4 (T8132) — on standard !tick_nohz_full kernels idle_on_time uses per-CPU TIMER_DEFERRABLE | TIMER_PINNED idle timers (clpc->idle_timers) for zero idle wakeups; a plain revert restores deferrable idle_work on T8132.

Not yet:

  • Live J604 (T8132) hardware boot row at 491e031bb680 and verification on non-J604/J773g T8132 boards (J713/J715).
Details and verification

Scope (j604-clpc-t8132-idle-on-time, head 491e031bb680)

  • drivers/soc/apple/clpc.c (+7 / -0)
  • tools/asahi/clpc-gpu-demand-tests.py (+2 / -2)
  • Sign-off: Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
  • tools/asahi/clpc-gpu-demand-tests.py: 2/2 positive suites + 47/47 negative controls PASS.
  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks (41 lines checked).
  • ARM64 LLVM=1 W=1 (clang 23.1.5): drivers/soc/apple/clpc.o 0 warnings (368464 bytes).
  • ARM64 QEMU KUnit (KASAN+UBSAN): apple-clpc-gpu 15/15 passed (0 failed, 0 skipped).

Mechanism summary

  • On main, apple_clpc_hw_t8132 left .idle_on_time unset (false), while t6041, t6050, and t8142 enable .idle_on_time = true.
  • On a quiet NO_HZ system, leaving idle_on_time disabled lets a single-threaded memory-bound workload waking from a short sleep sit at DCS 0 / fabric 0 (~345 ns DRAM latency instead of ~97 ns) for 0.2–1.5 s until an unrelated timer wakes deferrable idle_work.
  • Enabling .idle_on_time = true on apple_clpc_hw_t8132 aligns T8132 with the other M4/M5 SoC tables and allocates per-CPU deferrable idle timers at probe.

@IronsideXXVI
IronsideXXVI requested review from a team as code owners December 2, 2026 05:39

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

Reviewed 1541a10. Turning idle_on_time on for T8132 is reasonable (T6041, T6050 and T8142 already use it). Two blockers:

  1. Host tests will fail. tools/asahi/clpc-gpu-demand-tests.py:940 asserts !apple_clpc_hw_t8132.idle_on_time. Update that assertion with the table change.
  2. Runtime switch. The idle_on_time module parameter is an A/B knob; merged code has to pick its behaviour itself. Drop the parameter, apple_clpc_idle_on_time() and the test that writes the global, and keep .idle_on_time = true in apple_clpc_hw_t8132 with a KUnit/host check of the table. Note the per-CPU idle timers are only allocated at probe when the table says idle_on_time, so the override never had the same effect as the table on other SoCs anyway.

After that the remaining gate is a row at the new head on a T8132 Mac.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at 491e031b: ready to merge

Check Detail
CI at head ok 4 checks passed
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok in the PR body at 491e031b
Conflicts ok none
PR text ok Risk: two-way · M4 (T8132) — on standard !ticknohzfull kernels idleontime uses per-CPU `TIMERDEFERRABLE

Areas: area:gpu, area:platform
Merge: gh pr merge 3882 --merge (Owners and Core through the bypass: add --admin).

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

On T8132 (M4), apple_clpc_hw_t8132 leaves idle_on_time disabled, so
after 32 ms without a held vote CLPC switches to deferrable idle_work.
On a quiet NO_HZ system, a single-threaded memory-bound workload waking
from a short sleep can sit at DCS 0 / fabric 0 (~345 ns DRAM latency
instead of ~97 ns) for 0.2 to 1.5 seconds until an unrelated timer
wakes the deferrable worker.

Enable idle_on_time on apple_clpc_hw_t8132, matching
apple_clpc_hw_t6041, apple_clpc_hw_t6050, apple_clpc_hw_t8142, and
apple_clpc_hw_t8152, so per-CPU deferrable idle timers keep idle NO_HZ
CPUs at zero CLPC wakeups while active cores still sample on time.

Update the T8132 KUnit table check and tools/asahi/clpc-gpu-demand-tests.py
assertions to match.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI
IronsideXXVI force-pushed the j604-clpc-t8132-idle-on-time branch from 1541a10 to e9c20ef Compare December 2, 2026 08:26
@IronsideXXVI IronsideXXVI changed the title soc: apple: clpc: enable on-time idle sampling on T8132 with runtime override soc: apple: clpc: enable on-time idle sampling on T8132 Dec 2, 2026
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks for the review — addressed both blockers and rebased onto main (2225082e1, new head e9c20ef1b0b3):

  1. Updated tools/asahi/clpc-gpu-demand-tests.py (check_t8132 and line 940 in check_t6041) to assert apple_clpc_hw_t8132.idle_on_time.
  2. Dropped the idle_on_time module parameter, apple_clpc_idle_on_time(), and the global-mutating KUnit test; kept .idle_on_time = true in apple_clpc_hw_t8132 with a table assertion in apple_clpc_t8132_gpu_input_test.

Verified offline at e9c20ef1b0b3:

  • tools/asahi/clpc-gpu-demand-tests.py: PASS (2 positive suites + 47 negative controls).
  • ARM64 LLVM=1 W=1: drivers/soc/apple/clpc.o 0 warnings.
  • ARM64 QEMU KUnit (KASAN+UBSAN): apple-clpc-gpu 15/15 passed.
  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.

Will follow up with a live J604 hardware boot row at e9c20ef1b0b3.

@github-actions github-actions Bot added the area:gpu Area from CODEOWNERS (bot) label Dec 2, 2026

@satchlj satchlj 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.

Code audit clean at e9c20ef1b0b3 — awaiting exact-head hardware row & prior review clearance

Reviewed drivers/soc/apple/clpc.c and tools/asahi/clpc-gpu-demand-tests.py:

  • Setting .idle_on_time = true on apple_clpc_hw_t8132 matches t6041/t6050/t8142/t8152, drops the earlier module parameter cleanly, and updates both the KUnit assertion (apple_clpc_t8132_gpu_input_test) and clpc-gpu-demand-tests.py.
  • All CI checks pass at e9c20ef1b0b3.

Remaining before approval:

  • Exact-head T8132 hardware boot/idle row at e9c20ef1b0b3 (as listed in Not yet).
  • Re-review from @DjDeveloperr to clear the earlier CHANGES_REQUESTED.

@DjDeveloperr
DjDeveloperr dismissed their stale review December 2, 2026 22:20

Addressed at e9c20ef: the module parameter is gone and the host-test assertion is updated. The exact-head hardware row is what's left before merge.

@github-actions github-actions Bot removed the changes-requested A reviewer requested changes (bot) label Dec 2, 2026
One conflict, in drivers/soc/apple/clpc.c: the T8132 table gets .ane from
aurora-silicon#2856 and .idle_on_time from this branch on the same line. Keep both.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

I merged main (b902937859ec, with #2856) into this branch as a normal merge commit, 491e031bb680. Your commit is unchanged.

There was one conflict, in the T8132 table in clpc.c: #2856 adds .ane where this PR adds .idle_on_time. Both are kept, and the lines this PR adds and removes are the same as before.

Local checks on the merge (clang 23, arm64): W=1 clpc.o with 0 warnings, also with KUnit on (compiled, not run). run-host-tests.py --only clpc passes 9/9. checkpatch has 0 errors and 0 warnings. It also merges cleanly with #3868, and that combined tree passes the same build and host tests.

Still needed: a T8132 hardware row on this head.

@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026

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

Verdict: FINISH, then merge at 491e031bb6808aa5d1568f71cf16c32cc15cfb22

Blockers:

  1. A T8132 hardware row at this head. We will run it on J773g (M4 mini) in the next M4 composite. The J604 run in the PR body was an older build, so it doesn't count for this head. The row should show:
    • a short-sleep, memory-bound load gets its DCS and fabric floor right away (the latency this PR is about);
    • idle wakeups and idle power are no worse than main;
    • the ANE floor from #2856 still rises and drops;
    • one clean deep sleep, no new kernel errors.

The code has no blockers.

Checked: the whole diff against main, the merge commit, every board this reaches, the interaction with #2856 and #3868, and local builds. I didn't write the merge and read it fresh.

The merge commit. Beyond what git merges by itself it only resolves the T8132 table, keeping .ane from #2856 and .idle_on_time from this PR. The lines this PR adds and removes are the same as at e9c20ef1b0b3. The two points of the earlier review (the module parameter and the stale host-test assertion) are fixed.

Which Macs. idle_on_time is a field of the apple,t8132-clpc table, not a devicetree property. So every T8132 Mac gets it: J604, J623, J624, J713, J715 and J773g. The busy-share properties in t8132-memory.dtsi copy the table and keep the field. No other Mac changes. T6041, T6050 and T8142 already have it; T6040, T8140, T8152 and the generic table stay off. The PR text lists T8152 as already on, which is wrong; the code comment is right.

What changes on those Macs.

  • With no floor held, one pinned deferrable timer per online CPU replaces the single deferrable work item. It never wakes an idle CPU; a CPU that has been busy for a sample period starts the sampling.
  • GPU and ANE work still queues a sample at once. While a floor or the ANE CPU request is held, sampling stays on time, so the #2856 floor is released as before.
  • Suspend and unbind delete the timers and then cancel the work once more; resume arms them again. A failed allocation in probe frees the clusters and returns.
  • Booted with nohz_full=, these Macs would sample every 4 ms even when idle, as the other three tables already do. The default command line doesn't set it.

With #3868 (now in main): no conflict. The checks below ran on the two together.

Evidence

Local, on this head merged with main 5fe340acef00 and #3868 (tree a99f1ce542af, all 1830 CLPC, DT, binding and script sources matched to that tree by hash). clang 23.1.3, arm64:

  • W=1 drivers/soc/apple/clpc.o: 0 warnings, without KUnit and with CONFIG_KUNIT=y (compiled, not run).
  • run-host-tests.py --only clpc: 9/9, with the T8132 assertions this PR updates.
  • t8132-j773g, t8132-j604 and t8142-j815 DTBs build; dt_binding_check on both CLPC bindings is clean.

@RyanTheTide RyanTheTide closed this Dec 3, 2026
@RyanTheTide RyanTheTide reopened this Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (M4 Mac mini, Mac16,10, T8132, os-fw 27.2 / 26B123) hardware row at exact head 491e031bb680 (composite 7.3.0-j773g-comp6b+ over b902937859ec, CONFIG_HZ=250, boot_id=131ad383-3d5c-4124-9697-1c0a7ada6291): PASS.

  • 10-min idle (382800000.power-management:performance-controller@3/status):
    • avg_at=218.18/s (IDLE_MIN_1..10: 295.3, 229.8, 229.6, 225.6, 221.6, 202.4, 180.4, 181.2, 190.3, 225.3 /s).
    • clpc_samples_delta=7341 (~12.2/s active on-time sampling), update errors: 0 throughout.
    • Floor stepped down cleanly from 0x35 (dcs 5 soc 3) pre-idle -> 0x14 (dcs 4 soc 1) post-idle -> 0x0 (dcs 0 soc 0) post-s2idle.
  • 20 s full-CPU load + s2idle (rtcwake -d /dev/rtc1 -m freeze -s 5):
    • clpc_samples_delta=1811 (~90/s under load), update errors: 0; total 10,917 samples with 0 errors through s2idle wake.
    • SYSTEMD_FAILED=0, 0 kernel WARNING/Oops/BUG or CLPC error lines.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 3, 2026

@aurora-silicon-review aurora-silicon-review Bot 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 491e031
Checked: The T8132 SoC profile joins the existing pinned deferrable idle-timer path. I traced timer arming, CPU hotplug and suspend cleanup, and verified the final merge keeps both the ANE floor and idle_on_time. Both exact host suites passed and detected all 47 negative controls. The posted J773g composite includes this head and reports zero CLPC update errors through idle, load and s2idle. #3882 (comment)

Follow-ups: The PR description lists T8152 among the profiles with idle_on_time enabled. The current table leaves it off.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Mac16,10, T8132, os-fw 27.2 / 26B123) verification on 7.3.0-j773g-ship1 (exact head 491e031bb6808aa5d1568f71cf16c32cc15cfb22 merged with linux:main 51b0e18a6233, clean default cmdline, CONFIG_HZ=1000, active card1-DP-3 3840x2160@60):

  • CLPC idle sampling (5-minute idle sample, boot_id=fa6c2ed3-142b-420f-9c01-fbc00fd29355):
    • arch_timer total: 108379 over 300 s (361.26/s avg across all 5 min; quiet minutes 4–5: 270.07/s, 273.62/s, vs stock 7.3.0-ARCH-m4main-6c83a2a6 10-min baseline 304.58/s; prior CONFIG_HZ=250 10-min clean idle on this same head was 218.18/s in comment #7366257374).
    • clpc_samples_delta=7717 (25.72/s avg; quiet minutes 4–5: 20.75/s, 20.87/s).
    • update errors: 0 throughout (samples: 40038 -> 47859), dmesg CLPC errors/warnings: 0.
    • Idle floor settles cleanly to 0x00000000 (dcs state 0, soc state 0, last_vote: 0x0, saved 0x00000000).
  • CLPC ANE floor / sysfs:
    • ane_states: 5 3, ane_cluster_khz: 2616000, ane: active 0 request_ns 0 sequence 0 (note: /soc/ane is status = "disabled" in t8132-j773g.dts on ship1).
  • Suspend/resume device-phase test (pm_test=devices):
    • PASS (RC=0), CLPC + both external DCPs + display cleanly power-cycled and resumed with update errors: 0.
    • Note: committed deep sleep is tracked separately on #4007/#3809/#4164 and not gated on #3882.

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

T8132 opts into the existing pinned, deferrable idle timer path. The tests preserve the separate ANE floor, and the exact J773g row covers idle, load and s2idle with zero update errors.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
@DjDeveloperr

DjDeveloperr commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

J773g (Apple M4 Mac mini, Mac16,10, T8132, G16G B0, os-fw 27.2 / 26B123) committed deep x3 row on 7.3.0-j773g-ship1 #3 (Image b46c1c9933d001d8…, DTB 0bf95ef5430f53d8…, boot_id=cd32b8bc-004e-4a1b-b5fa-5d8464b07b4a, default s2idle [deep], pm_test=none): PASS (3/3).

Exact commits / DTB provenance on this boot (single J773g generation):

  • aurora-silicon/linux#4176 @ 40959794ea75b7b3e62fc84954e7237978f6ee37 (PCI: apple: set the T8132 ports up again after a deep sleep — J773g row only; shared T8132 reset table, J713 deep still owed)
  • aurora-silicon/linux#4007 @ c77edccad38852032d62f9d0b2b542c1d3f515f4 (t8132-apcie-port2: keep pcie0 sleep tunable register banks)
  • aurora-silicon/linux#3882 @ 491e031bb6808aa5d1568f71cf16c32cc15cfb22 (merged as 0c4c91bb7cc3)
  • aurora-silicon/linux#4031 @ 2fdae383ffa704b568a2c2302e995807538e7bb4 (merged as 9f672f0d9c85)
  • Correction on aurora-silicon/linux#4164: the booted boot3 DTB (0bf95ef5430f53d8…) was built from the earlier revision that included clkreq-gpios on pci@0,0, NOT 5a30f0960eab (which omitted clkreq-gpios). #4164 has since been updated to 0bc1cc98c029 to include clkreq-gpios on pci@0,0; an exact-head J773g DTB row at #4164 0bc1cc98c029 is queued next.

Verified results:

  • Committed deep sleep (3/3): suspend_stats/success=3, fail=0, last_failed_errno=0, boot_id unchanged across all 3 cycles (RTCWAKE rc=0 x3, apple-sleep: back from sleep, boot object resumes 0 -> 1 -> 2 -> 3, 302600000.gpu stop reported 1; physical sleep completed, 135 of 224 AP pins changed by the sleep, all put back, 0 SError / Call trace / BUG / Oops / WARNING).
  • PCIe & DART recovery (PCI: apple: set the T8132 ports up again after a deep sleep (J773g wake reset) #4176, arm64: dts: apple: t8132-apcie-port2: keep pcie0 sleep tunable register banks #4007): Boot logged pcie-apple 1cb0000000.pcie: T8132 multi-port deep sleep recovery registered. Every wake restored both DARTs and links in order: 490000000.iommu: restored after its host came back -> port 0: link restored after deep sleep; 492000000.iommu: restored after its host came back -> port 2: link restored after deep sleep. LnkSta unchanged pre-sleep = post-wake-1 = post-wake-3 (00:00.0 5GT/s x1, 00:02.0 2.5GT/s x1). Config space readable post-3 wakes (01:00.0 443414e4, 01:00.1 5f7214e4, 02:00.0 168214e4); end0 (tg3) returned 1000 Mbps full duplex after all 3 wakes. DT properties under /soc/pcie@1cb0000000: pci@0,0 has apple,tunable-{port,rc,rc-gen3,rc-gen4}, clkreq-gpios, reset-gpios; pci@2,0 has reset-gpios. (Note: brcmfmac/hci_bcm4377 returned -ENOENT at boot for absent firmware blobs on this rootfs, pre-sleep.)
  • External displays & PMC (arm64: dts: apple: t8132-j773g: wire display-power for deep sleep #4164 earlier rev, arm64: dts: apple: t8132: connect the external display pipes' PMC enables on every M4 Mac #4031): Both external DCPs (286e00000.dcp, 48ae00000.dcp) bound with 0 no apple,display-power warnings, returned RTKit: sleep return: ASC control 0x0, setting RUN across all 3 wakes, and restored card1-DP-3: status=connected enabled=enabled (3840x2160@60). Both pmc-dispext0-interface and pmc-dispext1-interface remained on in pm_genpd_summary after all 3 wakes (resume_early ran 3x, 0 errors).
  • GPU & CLPC (soc: apple: clpc: enable on-time idle sampling on T8132 #3882): aurora-g16 returned in 7653 / 9117 / 3879 us back to limit=S10. Post-wake-3 gpubench-vk passed (compute.light d=4 40.11 us, compute.uber d=4 486.40 us, crc=9963f56c valid=true); /sys/kernel/debug/aurora-g16/stats: health: failed 0 errno 0 degraded 0, jobs 43565 recoveries 0 hang_kills 0, sensor_errors 0; 0 CLPC errors in dmesg.
  • Type-C VDM routes: m5 (1-0a 0x731d3115) and neo (1-0c 0x73213102) both active post-wake-3.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Local checks on the merge of 491e031bb680 with main fcbb40063c54:

  • run-host-tests.py --only clpc: 9/9.
  • make W=1 drivers/soc/apple/clpc.o (aarch64 gcc 16.2.0): no warnings.
  • clpc.o against main: .text is the same. One byte of .rodata differs, inside apple_clpc_hw_t8132, so no other SoC changes.
  • checkpatch.pl --strict on e9c20ef1b0b3: 0/0/0.

Rows: J773g at this head (idle, load, s2idle on 12-03, then three deep sleeps today with the GPU back at full clock after each). J604 only on an older build. No row on J623, J624, J713, J715.

@DjDeveloperr
DjDeveloperr merged commit 0c4c91b into aurora-silicon:main Dec 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants