Repository navigation
soc: apple: clpc / drm/asahi: g17: preserve GPU busy share across brief idle gaps - #3407
Conversation
Prepare to decouple clearing CLPC's cached GPU busy share from brief inactivity clears in apple_clpc_gpu_set_active(gpu, false). Export apple_clpc_gpu_clear_busy() so GPU drivers can explicitly forget their reported busy share after genuine idle, and call it from apple_clpc_gpu_put() on teardown. Signed-off-by: Erik Bourget <[email protected]>
When Effort::idle() expires after IDLE_HOLD_NS (16 ms), Port::set_effort_full(false) unconditionally reset BusyShare and left paced 24-30 fps workloads (33-42 ms period) unable to complete a 200 ms BusyShare window before the next frame arrived inside CLPC's 32 ms rail hold. Record inactivity via BusyShare::note_inactive() and only reset the window and call apple_clpc_gpu_clear_busy() when activity resumes after at least BUSY_IDLE_RESET_NS (100 ms) of inactivity, as well as unconditionally on firmware teardown and system resume (since CLOCK_MONOTONIC does not advance across suspend). Brief inter-frame gaps preserve the 200 ms window so low-fps paced streams settle to the lower CLPC column, while genuine idle gaps still re-baseline and start new bursts at the top column. Add KUnit coverage in g17/power.rs. Signed-off-by: Erik Bourget <[email protected]>
Now that the sole apple_clpc_gpu_set_busy() consumer (drm/asahi g17) explicitly calls apple_clpc_gpu_clear_busy() after genuine idle gaps, system resume, and teardown, stop wiping gpu->busy_valid on every apple_clpc_gpu_set_active(gpu, false) call. Previously, paced 24-30 fps workloads (33-42 ms frame period) triggered g17's 16 ms effort clear between every frame while CLPC still held its rail vote for APPLE_CLPC_HOLD_MS (32 ms), wiping busy_valid and resetting the 400 ms down-step timer on every frame so DCS and fabric stayed pinned at the top column continuously. Add a KUnit test in clpc.c covering preservation across brief inactivity and explicit clear, and extend tools/asahi/clpc-gpu-demand-tests.py with end-to-end 24 fps paced coverage and negative controls. Signed-off-by: Erik Bourget <[email protected]>
There was a problem hiding this comment.
Verdict: HOLD at 206e5628ffd4
Blockers: Hosted CI and a T604x hardware regression. The J716c receipt includes the still-open #3400 ladder. Establish the landing order or qualify the final head on the intended base, and include a real suspend/resume row beyond the device-phase test.
Checked: Code approved. The revised paths preserve the share over short gaps and explicitly clear it for long-gap restart, teardown, and wake. Checked the saturation path also retires the inactive interval.
Evidence
The exact-head CLPC host fixture passed both positive groups and all 29 negative controls it printed, including the 24 fps, long-idle and legacy clear-on-inactive cases. This was a host run.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Exact-head hardware verification at Automated host check at
|
| Workload | DC Input Power (med) | Busy share | CLPC level | DCS / SOC state | Update errors |
|---|---|---|---|---|---|
| Idle (before) | 10,363 mW | 0 (none) |
3 (idle) | DCS 0 / SOC 0 (28/30) | 0 |
| 15 fps light | 10,720 mW | 0 (0–3, reported) |
0 (45/45) | DCS 1 / SOC 0 (41/45) | 0 |
| 24 fps light | 10,727 mW | 0 (0–0, reported) |
0 (45/45) | DCS 1 / SOC 0 (45/45) | 0 |
| 30 fps light | 10,572 mW | 0 (0–0, reported) |
0 (45/45) | DCS 1 / SOC 0 (43/45) | 0 |
| 60 fps light | 10,591 mW | 1 (1–1, reported) |
0 (45/45) | DCS 1 / SOC 0 (42/45) | 0 |
| 120 fps light | 11,156 mW | 2 (1–2, reported) |
0 (45/45) | DCS 1 / SOC 0 (41/45) | 0 |
| Heavy burst | 54,559 mW | 1000 (reported) |
3 (30/30) | DCS 6 / SOC 2 (30/30) | 0 |
| Post-burst idle (+0.2 s..+4.0 s) | — | 1000 (reported, active 0) |
3 (idle) | DCS 0 / SOC 0 (last_vote 0x0) |
0 |
Idle-to-burst reset check (BUSY_IDLE_RESET_NS = 100 ms)
- After 24 fps light (
level 0,DCS 1 / SOC 0) -> 150 ms genuine idle (DCS 0 / SOC 0,active 0) -> first burst submission: immediately clears busy to0 permille (none) level 3and jumps straight toDCS 6 / SOC 2(last_vote: 0x26 reason_bits 0x2).
s2idle (pm_test=devices with freeze) finding on J775c
J775c only exposes mem_sleep: [s2idle] (no deep-sleep DT nodes), so asahi's Shared::sleep_up() (which only runs after a deep-sleep firmware restart) does not run on s2idle resume, and apple_clpc_resume() does not call apple_clpc_gpu_clear_busy(clpc->gpu):
BEFORE (from 24 fps level 0):
dcs: rail 0 state 1 | soc: rail 1 state 0 | last_vote: 0x1 reason_bits 0x2
host_gpu busy: 0 permille (reported) level 0 | host_gpu: active 1 sequence 24337
AFTER pm_test=devices (freeze):
dcs: rail 0 state 1 | soc: rail 1 state 0 | last_vote: 0x1 reason_bits 0x2
host_gpu busy: 0 permille (reported) level 0 | host_gpu: active 1 sequence 24337
Post-resume GPU submission succeeded cleanly (rc=0), and dmesg had 0 Oops/BUG:/WARNING:/Call trace/GPU recovery lines and 0 failed systemd units.
Note for follow-up / before merge: On s2idle, CLOCK_MONOTONIC still freezes during timekeeping_suspend(), so leaving clear_effort_and_busy() only inside deep-sleep Shared::sleep_up() (and not clearing clpc->gpu->busy_valid in apple_clpc_resume() / non-deep g17 resume) leaves stale level 0 (reported) across s2idle suspend/resume. Clearing clpc->gpu busy in apple_clpc_resume() (and resetting BusyShare on s2idle resume too, or using boottime for the idle-reset threshold) would cover both deep and s2idle cleanly.
|
Addressing the HOLD items at
|
|
J700 (Neo, G17P) row at combined SHA Kernel: one-shot trial boot
Results
This PR: CLPC busy share. No CLPC debugfs |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approved. A brief idle now marks the busy share inactive instead of forgetting it, and a gap of 100 ms or more still clears it, both here and in CLPC through apple_clpc_gpu_clear_busy(). Teardown and sleep clear it as before, clear_busy() accepts a missing provider, and drivers that never report a busy share (g16, g18, m5) are unchanged. The J716c rows ran with #3400's ladder, which main now carries. The G17P row is in: a Neo (J700) boot of a candidate carrying this head unchanged ran render, compute and concurrent work and one deep sleep, with 0 GPU faults or timeouts and no new kernel errors.
|
Merging at |
Resolve tools/asahi/clpc-gpu-demand-tests.py against origin/main (#3407 and T8142 DT checks) by keeping T8132, T6050, and T8142 DT parsing and negative controls together with the brief-idle BusyShare and CLPC tests. Signed-off-by: Erik Bourget <[email protected]>
Resolve idle_check() in drivers/gpu/drm/asahi/g17/mod.rs against #3684 by keeping DirectIdle::observe() and passing active (in_flight || direct_publishing) into Effort::idle() and idle_hold(), resolve drivers/gpu/drm/asahi/g17/port.rs against #3407 by preserving both the direct-publisher tracking/admission helpers and brief-idle busy-share tracking (resume_busy_if_inactive(), set_effort_full(), clear_effort_and_busy()), and update tools/asahi/g17-m5-effort-tests.py to cover DirectIdle::observe(). Signed-off-by: Erik Bourget <[email protected]>
What: Separate clearing CLPC's cached GPU busy share (
apple_clpc_gpu_clear_busy()) from brief activity clears inapple_clpc_gpu_set_active(gpu, false), and only clearBusyShareand CLPC's share indrm/asahi: g17afterBUSY_IDLE_RESET_NS(100 ms) of inactivity, firmware teardown, or system resume. Fixes the 16 msIDLE_HOLD_NS/ 32 msAPPLE_CLPC_HOLD_MSdead zone that kept paced 24–30 fps workloads pinned at the top memory/fabric column continuously.Tested: Local checks pass at
206e5628ffd4(arm64 QEMU KUnitclpc.kunitconfig19/19 PASS,asahi/.kunitconfig491/491 PASS / 4 skipped withasahi_g17_idle_hold17/17 PASS;tools/asahi/clpc-gpu-demand-tests.pyPASS across both positive groups and 29 negative controls;./scripts/checkpatch.pl --strict0 errors/warnings/checks); live hardware at206e5628ffd4(default command line, default Stage 2, Linux 7.3.0): J716c (16-inch M5 Max, T6050) in batched candidatec3da8eed6f72(overmain9af21b007425, AC 100%, with#3400's ladder in the live DT) showed the rail floor released after a saturating GPU load (active 0,DCS 0 / SOC 0) while debugfshost_gpu busystill read(reported) 1000 permille, a stale value that clears lazily on the next activity (resume_busy_if_inactive); after apm_test=devicessuspend/resume it read(none)and a new burst went straight tolevel 3; J713 (M4 Air, T8132) in batched candidateb3dbf237542b(overmain9e38a276dcb4)aurora-g16/ CLPC non-regression clean (Vulkan workload #1200iters x4 MiBbad=0PASS, 3 s idle, 3xs2idleviartcwake -d /dev/rtc1 -m freeze -s 5, Vulkan workload #2200iters x4 MiBbad=0PASS,0GPU faults,0CLPC errors); an earlier J716c run at206e5628ffd4paired with#3400on default cmdline settled 15/24/30/60/120 fps paced Borealis/zink draws 45/45 samples tolevel 0/DCS 1 / SOC 0with1,175–1,502 mWheatpipe, lifted bursts tolevel 3/DCS 6 / SOC 230/30, released toDCS 0 / SOC 0at idle, and resethost_gpu busyonpm_test=devices).Risk: two-way door · G17 Macs using CLPC GPU busy-share scaling (T604x/T6050); drivers that never call
apple_clpc_gpu_set_busy()(g16,g18,m5) keepbusy_valid == falseunchanged.Not yet: Standalone clean
main(206e5628ffd4, without#3400, where the DT-selected CLPC busy-share ladder stays disabled) J716c row scoped tog17busy-share bookkeeping (the J716c rows so far ran with#3400's ladder in the live DT), reals2idle/ deep suspend and resume on J716c (onlypm_test=devicesran), and the T6041 (M4 Max) DT-selected busy-share ladder hardware run (external hardware not on site).Details
Three bisect-safe commits on
main(no code dependency on#3400; can land onmainbefore or independently of#3400):54bad83f2aaa(soc: apple: clpc: add apple_clpc_gpu_clear_busy()): exportapple_clpc_gpu_clear_busy()(plus#elseinline stub) and call it inapple_clpc_gpu_put(), keeping existingapple_clpc_gpu_set_active()behavior unchanged at this commit.883f0567e5d6(drm/asahi: g17: preserve CLPC busy-share window across brief idle gaps): addBUSY_IDLE_RESET_NS(100 ms),BusyShare::note_inactive(), andBusyShare::resume()ing17/power.rs, wired throughg17/port.rs,g17/clpc.{c,h},g17/mod.rs, andg17/sleep.rs. Brief inactivity clears (< 100 msafterIDLE_HOLD_NS = 16 ms) preserve the 200 ms measurement window; genuine idle gaps (>= 100 ms), firmware teardown (Firmware::drop()), and system resume (Shared::sleep_up(), sinceCLOCK_MONOTONICfreezes across suspend) clear bothBusyShareand CLPCbusy_validbefore reactivating so new bursts start at the top column.206e5628ffd4(soc: apple: clpc: keep GPU busy share across brief inactivity): remove the unconditionalif (!active) gpu->busy_valid = false;fromapple_clpc_gpu_set_active(), addapple_clpc_gpu_busy_clear_testKUnit coverage inclpc.c, and extendtools/asahi/clpc-gpu-demand-tests.pywith end-to-end 24 fps paced tests and negative controls (g17-brief-idle-resets-window,clpc-set-active-clears-busy).Why the bug happened:
Effort::idle()clearseffort_fulland callsapple_clpc_gpu_set_active(false)afterIDLE_HOLD_NS = 16 msof GPU idle.apple-clpcholds its previous rail vote forAPPLE_CLPC_HOLD_MS = 32 msafteractivegoesfalse(48 ms total).BusyShareandgpu->busy_valid), then the next frame arrived before the 48 ms combined hold expired, forcinglevel 3(DCS 6 / SOC 2) and resetting the 400 msAPPLE_CLPC_GPU_DOWN_MStimer on every frame so the top floor stayed locked at 100% duty cycle.Evidence
Live hardware at
206e5628ffd4(batched candidates, default cmdline, default Stage 2, Linux 7.3.0)c3da8eed6f72overmain9af21b007425, AC 100%,#3400's ladder in the live DT: after saturating GPU load, the rail floor was already released (active 0,DCS 0 / SOC 0) while debugfshost_gpu busystill read(reported) 1000 permilleat idle (a stale value that clears lazily on the next activity viaresume_busy_if_inactive); after apm_test=devicessuspend/resume it read(none), and a new burst went straight tolevel 3.b3dbf237542bovermain9e38a276dcb4:aurora-g16/ CLPC non-regression: Vulkan workload mux: apple-display-crossbar: replace the T602x selector fields instead of OR-ing them #1 (200iters x4 MiB,bad=0PASS), 3 s idle, 3xs2idle(rtcwake -d /dev/rtc1 -m freeze -s 5), Vulkan workload drm/apple: release a stale DPTX link before borrowing a Type-C route #2 (200iters x4 MiB,bad=0PASS);0GPU faults,0CLPC errors.Earlier J716c run at
206e5628ffd4paired with#3400(AC, headless 1080p Borealis/zink, default cmdline)Not yet run: clean
main(206e5628ffd4, without#3400) on J716c, and reals2idlesuspend/resume on J716c.Automated tests at
206e5628ffd4scripts/checkpatch.pl --strict --git a561e89792d5..HEAD: 0 errors, 0 warnings, 0 checks on all 3 commitstools/asahi/clpc-gpu-demand-tests.py: PASS (both positive groups + all 29 negative controls, includingg17-idle-keeps-window,g17-brief-idle-resets-window, andclpc-set-active-clears-busy)./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/soc/apple/clpc.kunitconfig: 19/19 passed (apple-clpc-gpu14/14,apple-clpc-policy5/5)./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/asahi/.kunitconfig: 491 passed, 4 skipped, 0 failed (asahi_g17_idle_hold17/17)