Repository navigation
drm/asahi: g17: track direct publishers across idle_check handoffs - #3415
Conversation
When a lockless direct submission starts and retires before idle_check() runs, port.submissions() advances while in_flight is already false. Passing (in_flight || submitted) into Effort::idle() and idle_hold() caused both to return None instead of arming their recheck timers: - Effort::idle(now_ns, true) cleared idle_since and left IDLE_WORK unarmed, keeping effort_full, Region C full effort, and CLPC host_gpu active stuck true indefinitely until the next submission (costing ~1.1 W at desktop idle on T6050 once direct renders are active). - Hold::step(now_ns, true, ...) returned HoldAction::None when a hold was active (or right after asserting it), leaving the GPU core idle hold asserted indefinitely on non-M5 Macs with idle_off_delay_ms > 2. Simply passing in_flight alone is not enough when a direct publisher pauses between port admission and publication/pair return: an idle pass can observe the admission counter with an empty queue (or a lent render pair with borrowed_active == false) and expire Effort or Hold before the paused publisher exposes its work. Track admitted lockless direct publishers with a DirectSubmissionGuard (direct_publishers + direct_exits on Port), sample direct_publishing before queue scans, and route the idle check through power::DirectIdle: - Already-retired direct submissions still clear idle_since via effort.submit() while passing active = false so Effort and Hold arm their recheck timers. - In-flight direct publishers keep active = true and arm a bounded IDLE_WORK recheck, and bump direct_exits on guard drop so post-retirement idle windows restart cleanly. - Close lockless direct admission (effort_full = false) without touching CLPC demand or the busy-share window before validating Effort clear and Hold release, keeping admission closed through set_idle_control() and committing CLPC demand teardown only inside apply_effort(0) once validation succeeds. - When observe_returned_render() retires the last render synchronously (FastRenderOutcome::Done), wake IDLE_WORK if no renders remain in flight. Add KUnit coverage in asahi_g17_idle_hold exercising DirectIdle, Effort, and Hold across retired direct submissions, paused direct publishers, and guard-exit handoffs. Fixes: 1cdac9b ("drm/asahi: publish G17 compute into a bound queue without the device mutex") Signed-off-by: Erik Bourget <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
…snapshot Update the structural assertions and mutation patterns in the g17 host tests to match the added direct snapshot parameter in Firmware::idle_check() and the synchronous IDLE_WORK wakeup on FastRenderOutcome::Done in render_direct(). Signed-off-by: Erik Bourget <[email protected]>
|
Fixed all three
Commit Verified at
|
There was a problem hiding this comment.
Verdict: MERGE at 8c1b6d9d
Blockers: none in code (note: queued KUnit CI jobs must finish green before merge; a second-family smoke row such as G17P/M4 Pro or Neo is recommended for blast:m4,m5,neo).
Checked: no Apple material, no AI attribution, no new chip/board/firmware gates, no cmdline hacks, human Signed-off-by, SeqCst ordering across begin_direct_submission() / DirectSubmissionGuard::drop() / direct_snapshot(), close_direct_admission()/reopen_direct_admission() validation before CLPC demand clear or set_idle_control(true), DirectIdle::observe() recheck arming on retired direct submissions, direct.take() + FastRenderOutcome::Done queue_idle(0) in direct.rs, 238/238 g17 host tests + 491 KUnit asahi tests, J716c M5 Max hardware row PASS, apple-build/host-tests/pr-text green.
Evidence
- Inspected all 6 driver files (
mod.rs,port.rs,power.rs,runtime.rs,runtime/events.rs,runtime/render/direct.rs). - Verified concurrency handoff:
begin_direct_submission()incrementsdirect_publishersthensubmissions(SeqCst) before loadingeffort_full; iffalse, decrementsdirect_publisherswithout assertingnote_gpu_activity().DirectSubmissionGuard::drop()bumpsdirect_exitsbefore decrementingdirect_publishers(SeqCst).direct_snapshot()readssubmissions,direct_publishers,direct_exits(SeqCst) before scanning queues, ensuring every admitted publisher is seen insubmissions,publishing, or the queue scan.- Both
Effort::ClearandHoldAction::Releaseclose direct admission (effort_full = false) without dropping CLPC demand, rechecksubmissionsanddirect_publishing, and reopen admission if a publisher slipped in. DirectIdle::observe()recordseffort.submit()onsubmissions/exitsprogress while returningin_flight || direct_publishing, preventing unarmedIDLE_WORKafter already-retired direct submissions.
- Hardware row (J716c M5 Max, default cmdline,
3e5458c0driver code unchanged in8c1b6d9d): 60-frame Borealis/Waylandvkcube,effort_full/cores_powered/host_holdall clear cleanly after retirement; 0 new kernel errors. - CI at
8c1b6d9d:apple-build,host-tests,pr-text,KUnit ane-boot/ane-pm/dcp-fabric/dcp-topologyPASS; remaining KUnit jobs queued.
|
All 21 CI checks at Verified at
Updated the PR body with
|
|
J700 (Neo, G17P) row at combined SHA Kernel: one-shot trial boot
Results
This PR: non-M5 G17 hold path. With |
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]>
|
Merged live Verified at
Updated the PR body to record the new merge head |
RyanTheTide
left a comment
There was a problem hiding this comment.
The merge preserves the pre-scan publisher snapshot and recheck while retaining main’s queue in-flight and BusyShare accounting. Effort clear and hold release both use the combined active state. The focused host tests and Asahi KUnit passed. The reported owed-stamp compile failure is on the merge base.
|
Merging at |
What: Track admitted lockless direct GPU publishers across
idle_check()handoffs so paused direct publishers cannot haveEffortorHoldcleared underneath them, late admissions are validated beforeeffort_fullis closed, and rejected direct attempts cannot leave CLPC demand asserted. The retired-direct-submission case (a submission that retires beforeidle_check()runs must still armIDLE_WORK, soeffort_full/ CLPChost_gpuor the non-M5Holdis not left stuck) is already fixed onmainby #3684 (766fd2aa4699); this PR keeps that behaviour and adds the publisher tracking and admission handling on top of it, alongside #3407's brief-idleBusySharepreservation indrivers/gpu/drm/asahi/g17/port.rs. Follows the idle-recheck leak introduced in1cdac9ba0ddd(drm/asahi: publish G17 compute into a bound queue without the device mutex).Tested: At
6d76a4f2f10d(merge oforigin/main19ee1b5bc9d5into8c1b6d9d0a02, resolvingdrivers/gpu/drm/asahi/g17/mod.rsagainst #3684,drivers/gpu/drm/asahi/g17/port.rsagainst #3407, andtools/asahi/g17-m5-effort-tests.pyforDirectIdle::observe()):python3 -I tools/asahi/run-host-tests.py --only g17(292/327passed — all 292 non-render-owed-stampcases includingg17-m5-effort-tests,g17-m5-idle-housekeeping-tests,g17-m5-sibling-gate-tests, andg17-render-return-observe-testspass; the 35 failures are ing17-render-owed-stamp-testsfrom a pre-existingorigin/maincompile break in unrelated files),python3 tools/asahi/clpc-gpu-demand-tests.py(passed), arm64 QEMU KUnitdrivers/gpu/drm/asahi/.kunitconfig(521/525passed,4skipped;asahi_g17_idle_hold18/18passed), and./scripts/checkpatch.pl --strict --no-signoff(0errors,0warnings,0checks onorigin/main..6d76a4f2f10d). Prior pre-merge hardware rows before the19ee1b5bc9d5merge: J716c (16-inch M5 Max,T6050, firmware 27.2, AC, default command line, default Stage 2) at465059fc3976(prior merge overa171afd2123f, Linux7.3.0) verifiedvkcube --c 600 --wsi wayland(BorealisApple M5 Max (G17C B1)) takingeffort_fullfalse -> truewithin 1 s (direct_submissions298 -> 2225) and back tofalse1 s after exit, stayingfalse(cores_powered=false,host_hold=false,idle_hold_ms=2) for the next 12 s, plus clean smoke (eDP-13456x2234@120, Apple MTP input,wlan00% loss over 3 pings,AppleJ716PCMs present without playback,vkcube --c 240 --wsi waylandclean, 1 pre-existing failed unitaurora-peripherals.service, 0 LSM denials, 0 GPU/MMU faults or WARN); earlier J716c rows at8c1b6d9d0a02(3545ebecb76f) and3e5458c00b30also passed; Neo (J700,G17P,Tested-by: DjDeveloperr) in candidate936d72d0(mainfe9af4b6+#3684+#3407+#3306+#3415at8c1b6d9d0a02+#3346, one-shot trial boot472ed0ed) verifiedeffort_fullidle release (~0.3 s),idle_off_delay_ms=50hold assert/release without sticking, render/compute/concurrent workloads, and deep sleep (rtcwake -m mem -s 30) with 0 faults/errors.Risk: two-way door · M4 Pro/Max (
T6040/T6041), M5 (T6050), and Neo (T8140) Macs (drivers/gpu/drm/asahi/g17/).Not yet: hosted GitHub CI, team review, and a fresh J716c boot at the new merge head
6d76a4f2f10d(the J716ceffort_fullrow ran at465059fc3976and the Neo row ran at8c1b6d9d0a02/ candidate936d72d0before merging19ee1b5bc9d5); second-family boot/smoke rows and liveidle_off_delay_ms > 2hold verification on M4 Pro/Max (T6040/T6041, G17P/G17C) (external hardware not on site;J713isT8132/G16G andJ313isT8103/G13G, neither of which bindsg17; hold/recheck logic covered by KUnitasahi_g17_idle_hold).Details
Problem
mainby drm/asahi: g17: arm idle recheck when a direct submission already retired #3684,766fd2aa4699; kept here): When a lockless direct submission starts and retires beforeidle_check()runs,port.submissions()advances (submitted == true) whilein_flightis alreadyfalse. Passingin_flight || submittedintoEffort::idle()andidle_hold()caused both to returnNoneinstead of armingIDLE_WORK. On T6050 (especially once direct renders land), this lefteffort_full=trueand CLPChost_gpuactive (DCS 6 / SOC 2, ~1.1 W extra heatpipe power) stuck indefinitely at desktop idle; on non-M5 Macs withidle_off_delay_ms > 2, it left the GPU core idle hold asserted indefinitely.in_flightalone (as in766fd2aa4699) allows an idle pass to observe the admission counter with an empty queue (or a lent render pair withborrowed_active == false) and expireEffortorHoldbefore a paused direct publisher exposes its work. Closingeffort_fullviaset_effort_full(false)before validating late admissions also transiently dropped CLPC active demand and cleared the busy-share window, and callingnote_gpu_activity()before checkingeffort_fullallowed a rejected direct attempt whose fallback aborted to leave CLPC demand active.observe_returned_render()retired the last in-flight render synchronously (FastRenderOutcome::Done) after an earlier event pass had seen the lent pair as active, no idle check was queued.Design
Port(drivers/gpu/drm/asahi/g17/port.rs): Replacenote_submission() -> boolwithbegin_direct_submission() -> Option<DirectSubmissionGuard<'_>>, backed bydirect_publishers: AtomicU32anddirect_exits: AtomicU64(SeqCst). Callnote_gpu_activity()only inside the accepted (effort_full == true) branch. On drop,DirectSubmissionGuardbumpsdirect_exitsbefore decrementingdirect_publishers. Exposedirect_snapshot()loading(submissions, direct_publishers != 0, direct_exits)inSeqCstorder, plusdirect_admission_open(),close_direct_admission(), andreopen_direct_admission()without altering CLPC demand. Preserves soc: apple: clpc / drm/asahi: g17: preserve GPU busy share across brief idle gaps #3407'sresume_busy_if_inactive(),set_effort_full()brief-idleBusySharepreservation, andclear_effort_and_busy().drivers/gpu/drm/asahi/g17/runtime.rs,drivers/gpu/drm/asahi/g17/runtime/render/direct.rs): HoldDirectSubmissionGuardthrough compute cell unlock afterqueue.publish()and throughfirmware.return_render()under the device mutex. OnFastRenderOutcome::Done, queueIDLE_WORK(queue_idle(0)) when!firmware.queues.render_in_flight().drivers/gpu/drm/asahi/g17/runtime/events.rs): Takefirmware.port.direct_snapshot()before scanning compute and render queues in both the fast path and full path.DirectIdle&idle_check(drivers/gpu/drm/asahi/g17/power.rs,drivers/gpu/drm/asahi/g17/mod.rs): Consume(submissions, exits)intoeffort.submit()while passingactive = in_flight || direct_publishingtoEffort::will_clear,Effort::idle, andidle_hold, and keep a boundedIDLE_HOLD_NSrecheck armed wheneverdirect_publishingis true. BothIdleAction::ClearandHoldAction::Release(including when lowered to 2 ms) close direct admission before validating against pre-scansubmissionsanddirect_publishing(), preserve the prior admission state (was_open) on deferral, and commit CLPC demand teardown only insideapply_effort(0)after validation succeeds.origin/main(6d76a4f2f10d): Resolvesdrivers/gpu/drm/asahi/g17/mod.rsagainst drm/asahi: g17: arm idle recheck when a direct submission already retired #3684 (766fd2aa4699) by keepingDirectIdle::observe()andactive(in_flight || direct_publishing) passed intoEffort::idle()andidle_hold(), resolvesdrivers/gpu/drm/asahi/g17/port.rsagainst soc: apple: clpc / drm/asahi: g17: preserve GPU busy share across brief idle gaps #3407 (43715890e29f) by preserving both the direct-publisher tracking/admission helpers andresume_busy_if_inactive()/set_effort_full()/clear_effort_and_busy(), and updatestools/asahi/g17-m5-effort-tests.pyto extractDirectIdleand exercise both retired and in-flight direct submissions (including--mutation idle-counts-submitted).tools/asahi/): Update the structural assertions and mutation patterns ing17-m5-effort-tests.py,g17-m5-idle-housekeeping-tests.py,g17-m5-sibling-gate-tests.py, andg17-render-return-observe-tests.pyforDirectIdle::observe(), the addeddirectsnapshot argument inFirmware::idle_check(), and theFastRenderOutcome::Doneidle wakeup inrender_direct().Evidence
6d76a4f2f10d6197208e836a1fee9b3e3c91c025(merge oforigin/main19ee1b5bc9d533b7edc2629e55e9a99f54c0984binto8c1b6d9d0a02b949a5c581ce57bdbc76d49a0567; feature commits3e5458c00b30and8c1b6d9d0a02)../scripts/checkpatch.pl --strict --no-signoff:0 errors, 0 warnings, 0 checksonorigin/main..6d76a4f2f10d(607lines).6d76a4f2f10d):python3 -I tools/asahi/run-host-tests.py --only g17:292/327 passed(g17-m5-effort-tests,g17-m5-idle-housekeeping-tests,g17-m5-sibling-gate-tests, andg17-render-return-observe-testswith all mutations passed;35failures ing17-render-owed-stamp-testsare a pre-existingorigin/maincompile error inqueue/render/observation.rs/completion.rsunrelated to this PR).python3 tools/asahi/clpc-gpu-demand-tests.py: passed../tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/asahi/.kunitconfigat6d76a4f2f10d):Ran 525 tests: passed: 521, skipped: 4(apple_g17_rx_util_min_testneedingCONFIG_UCLAMP_TASKplusj713_accepts_all_loaded_images,j773g_accepts_its_loaded_image, andt8132_25g83_b000_zeroes_what_iboot_fills;asahi_g17_idle_hold18/18passed includingdirect_idle_arms_recheck_for_retired_submission_and_guards_paused_publisherandpaced_low_fps_preserves_window_across_effort_clears).19ee1b5bc9d5merge):T6050, firmware 27.2, AC, default command line, default Stage 2) at465059fc3976(prior merge overa171afd2123f, Linux7.3.0):vkcube --c 600 --wsi wayland(BorealisApple M5 Max (G17C B1)) tookeffort_fullfalse -> truewithin 1 s (direct_submissions298 -> 2225) and back tofalse1 s after exit, stayingfalse(cores_powered=false,host_hold=false,idle_hold_ms=2) for 12 s; 5-item smoke clean (eDP-13456x2234@120, MTP input,wlan00% loss,AppleJ716PCMs enumerated, 1 pre-existing failed unitaurora-peripherals.service, 0 LSM denials, 0 GPU/MMU faults).J700,G17P,Tested-by: DjDeveloperr) at combined candidate936d72d0(mainfe9af4b6+#3684+#3407+#3306+#3415at8c1b6d9d0a02+#3346, one-shot trial boot472ed0ed, default command line): gpubench 4-queue render (per-queue CRC ok), 2-queue compute, concurrent render + compute,vkcube --c 300;effort_fulltrue during work (48/49 samples) and cleared within ~0.3 s of idle; host hold stayed off atidle_off_delay_ms=2and asserted during work (18 samples) then released cleanly atidle_off_delay_ms=50; deep sleep (rtcwake -m mem -s 30) + post-sleep render readback valid; 0 GPU faults/timeouts/WARN/AVC/failed units.T6050, firmware 27.2, AC, default command line) in batched trial kernel3545ebecb76fat8c1b6d9d0a02:vkcube --c 600 --wsi wayland(default Mesa):/sys/kernel/debug/aurora-g17/powersamples showedeffort_full=falseat idle,truewhile the cube ran, andfalseagain 10 s after exit (cores_powered=false,host_hold=false,idle_hold_ms=2;direct_submissions=2unchanged). Prior standalone3e5458c00b3060-frame row also passed (effort_fulltrue -> falsecleanly 250 ms after exit).