Repository navigation
drm/asahi: g17: enable direct compute submission on M5 and coalesce event locks - #2947
4 commits merged into
Conversation
RyanTheTide
left a comment
There was a problem hiding this comment.
FOLLOW-UP · source review of e07a4facfb7a
The patch adds concurrency between direct compute publication, locked render publication and event processing. The credit test is sequential, and the direct-submission counter shows the fast path was hit but not that the publishers contended while recovery or suspend was draining builders. Please add a mixed render/compute row covering ring wrap and a generation change with a queued claim. The report-drain change overlaps #2909, so qualify that ordering on the combined head and record whether report cadence changes completion or recovery behavior.
Verification here was by source inspection.
|
@DjDeveloperr Could you reconcile the report ordering with #2909 and test the combined head on M5? Git merge-tree confirms a content conflict in |
47d3a0a to
344d6a9
Compare
|
R2 pushed at
Verification: |
|
Hardware qualification update on Apple M5 Pro (
|
On M5 (G17S/G17C/G17D), compute_direct() returned None unconditionally because M5 compute shares the per-priority outer work ring with render and issues host-port gating and submission-history updates. As a result, every steady-state M5 compute submission fell back to the global device mutex (shared.state), serializing concurrent compute queues against each other and against the event worker. Add a dedicated port-level M5 outer-ring mutex (Port::m5_outer) ordered after the compute queue cell and render publication lock (device mutex -> compute cell -> port.render -> port.m5_outer -> port.qos/mailbox), and expose non-interfering direct credit consumption on OuterCredits (is_scoped() / consume_direct()) plus direct port views for M5's shared outer ring and submission-history table. Guard device-mutex M5 compute and render outer-ring publications with m5_outer_lock(), reset the cached history geometry on recovery restart, and allow steady-state M5 compute submissions to publish through compute_direct() without taking shared.state. Add a KUnit test covering direct credit consumption alongside OuterScope. Signed-off-by: Diljit Singh <[email protected]>
Each completion pass in run_runtime_events() / runtime_event_turn() previously took the global device mutex (shared.state) up to five times and ran M5 firmware.drain_reports() (trace/statistics rings plus GPU power register reads) on every completion interrupt, even during tight compute loops where no render mask was pending. Coalesce the worker_deferred take and empty-batch restore into the existing device-mutex holds, avoid dropping and immediately re-acquiring shared.state around a no-op observe_renders() when render masks are zero, and throttle M5 post-signal report draining (drain_post_signal_reports()) to the HOUSEKEEPING_NS (1 ms) cadence while work remains in flight. On recovery passes, drain post-signal reports before service_runtime_recovery() resets firmware rings (matching the unthrottled post-signal ordering and #2909) without double-draining in housekeeping. Add host tests (g17-m5-direct-compute-tests.py) covering mixed render/compute ring wrap, generation-change queued-claim handling, concurrent direct/scoped credit safety, and post-signal/pre-recovery report ordering. Signed-off-by: Diljit Singh <[email protected]>
344d6a9 to
9723957
Compare
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Rebased onto Conflicts were all in
Every other commit is unchanged ( Host tests: |
Bring in main up to 6ec49ac (the T6050 GPU, fan and display work and the later G17 effort, command-port and lock changes). Conflicts: - drivers/gpu/drm/asahi/g17/initdata/m5.rs: main added set_m5_policy_layouts() where this branch adds m5_history_view(); both are kept. main also reads the M5 submission-history fields through the loaded firmware build's status-config relocation instead of fixed 26A428 offsets, so m5_history_view() now takes its generation, geometry and slot addresses from the same relocation as note_m5_submission_history(). - tools/asahi/run-host-tests.py: both sides register a new g17 test; both are kept. Signed-off-by: Diljit Singh <[email protected]>
|
Merged current |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Blocking finding (1): don't merge this PR by itself. Land it through #2955, which already has the fix.
-
drivers/gpu/drm/asahi/g17/runtime/events.rs:598(atd10e12acc8f6): the newif masks != [0; 2]skipsobserve_renders()on every pass that brings no new firmware records. Those passes are exactly the ones that finish render observations nothing else will:- the 1 ms rescan poll for a pair whose completion record arrived before its stamp (
stamp_waiting()).observe_renders()re-arms that poll itself (render/observe.rs:193-199), so once it is skipped no further poll is queued; - the pass a borrower queues on return for a completion that arrived while the pair was lent (
take_missed_event(), thenqueue_events()); - returned pairs with a deferred error, timeout or close (
apply_render_deferred()runs only there).
In each case that render's fence waits for an unrelated render completion or for the job watchdog. This is shared G17 code, so Neo is affected too.
Fix: #2955 already gates this onmasks != [0; 2] || firmware.render_observation_needed()and adds the helper inrender/observe.rs. Either move that one condition and the helper into this PR, or merge #2955 instead (it carries these commits unchanged), and GitHub will mark this PR merged with it. - the 1 ms rescan poll for a pair whose completion record arrived before its stamp (
Everything else in the delta is fine.
What I checked
- The merge of
maininm5_history_view(): it now uses the relocated status-config fields (M5_STATUS_CONFIG_HISTORY*viam5_status_config.relocate()) exactly asnote_m5_submission_history()onmaindoes. The result is equivalent, and it builds from the same expressions. Port::m5_outerlock order and coverage: every host writer of the shared M5 ring holds it (direct compute, the device-mutex compute path,publish_render, including retained pairs). The device path callsregs.submit_m5_work_helddirectly, so it never re-takes the lock.- Credit accounting: direct reservations count in
reserved[], room checks subtract them, andconsume_directnever touchespublished[]. - The
worker_deferredtake and restore on every exit ofruntime_event_turn(). - No AI attribution in the commits or the body.
To merge (via #2955):
- a T6050 / J714s (M5 Pro) row built from this head (a batched fleet candidate that contains this head unchanged counts).
- a T8140 / J700 (Neo, G17P) regression row at this head, because this PR changes shared G17 code that also runs on Neo.
- CI: the only red check is
host-tests, and its three failures (m3-recovery-tests,m3-recovery-tests --mutate,m3-runtime-tests) fail the same way onmainitself (0c4e19df, run 45466941208). They are not from this PR. Every G17 host test passes. - Base:
mainhas moved past6ec49ac7(now77561654). The new commits touch none of this PR's files and the head merges cleanly, so a branch update needs no new row.
|
Hardware row at Build: fleet candidate Since the 11-24 row (at Result:
Not run: GLES CTS (the surfaceless |
|
Neo (J700, T8140 / G17P B1) non-regression PASS at d10e12a (via Wave C fleet candidate 9ab6f78, REQ 46078bfa, covering #2947..#3035; aurora.ko sha 004e299ee9668db4, default cmdline, Stage 2 b17): exercises shared G17 submission/fence/event/port/runtime paths (M5 direct-submit paths gated off on T8140); gpubench-vk 8/8 OK (render.heavy 720p fill d1 407us/d4 260us, compute.heavy alu d1 1493us/d4 1282us, bw d1 3030us/d4 2804us), gl-smoke 32/32 + gpubench-gl 2/2 OK, dEQP-VK short CTS 30/30 PASS, s2idle 1/1 (10 s) + post-sleep GPU PASS, 0 GPU faults/timeouts/recoveries, 0 failed units, Enforcing + 0 AVC, 0 new GPU kernel errors; restored to saved fleet89. |
Bring in main up to a73023b (among others the G17 submit-latency, compute completion fast path, completion cluster and page-fault blame work). Conflict: - drivers/gpu/drm/asahi/g17/runtime/events.rs: main now drains the trace and statistics reports after the pass's completions are signalled on every G17 (c56132f, from #2909), where it was M5 only. This branch throttles that post-signal drain to the housekeeping cadence while work is in flight and drains first on a recovery pass, through drain_post_signal_reports(), which drained on M5 only because only M5 deferred the reports. As every G17 defers them now, the helper and its is_m5() check go away and the throttled sites call drain_reports() directly, as planned when this branch was reconciled with #2909. g17-m5-direct-compute-tests.py checks the same order under the new name. Signed-off-by: Diljit Singh <[email protected]>
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 5a44dc68f23c
Blockers: none
Checked: Full diff audit of drivers/gpu/drm/asahi/g17/ (initdata/m5.rs, initdata/outer_credit.rs, mod.rs, port.rs, queue/compute.rs, runtime.rs, runtime/events.rs, runtime/render.rs, runtime/render/observe.rs, runtime/render/submit.rs) plus paginated CI and J714s hardware row verification.
Evidence
- Direct M5 compute & credit accounting:
Credits::consume_direct()debits onlyclaim.remainingandreserved[]without touchingpublished[], leaving device-mutexOuterScopeaccounting intact (covered by KUnitasahi_g17_outer_credit).Port::m5_outerserializes shared outer-ring writes,submit_m5_work_held_locked, andnote_m5_submission_history_locked, droppingm5_outer_guardbefore ringing the mailbox doorbell. - Report throttling & single-lock compute event turn:
Shared::worker_deferredmoves out ofRegistry, report drains run at housekeeping cadence and pre-recovery before firmware restart resets report rings, and pure-compute passes complete in one device-mutex hold whenrender_observation_needed()is false and no replay/housekeeping/waiters are pending. - CI & hardware evidence: Paginated numeric-ID check-runs 19/19 passed (
0 active / 0 bad), commit statuses clean, exact-head J714s Apple M5 Pro pass row posted (wip/m5-wavec-fleet-candidate-20261125atb7b130a75bab); unrun boards are explicitly noted inNot yet:.
|
Tested (
|
What: M5 (G17S/G17C/G17D) compute shares the per-priority outer work ring with render, so
compute_direct()returnedNoneand every steady-state M5 compute submission went through the global device mutex (shared.state). This adds a port-levelPort::m5_outermutex plus direct credit and history views and enables steady-state direct compute on M5, then coalesces event-worker device-lock holds and throttles M5 report drains to the 1 ms housekeeping cadence while work is in flight. Commit 2 overlaps #2909 at thedrain_reports()call site.Tested: J714s M5 Pro (G17S B1): direct compute path live (
direct_submissions = 696,465), 0 oops, 0 GPU faults; light compute (d=4) −12.2 % submit latency, light clear (d=4) −6.7 %, occlusion query (d=16) −5.2 %.asahiKUnit 275/275 pass; full arm64 LLVM build onintegration/aurorab10280c04c2d+ this series.Risk: two-way · M5 family; the event-worker lock coalescing and the report-drain throttle are shared G17 code and also run on Neo (G17P).
Not yet: Neo (G17P) at this head (its last row predates the
mainmerge), M5 (J813), M5 Max (J716C) and M5 Ultra (J775D) not run.After the
mainmerge (11-25,maina73023bc5f1f): the report drain:mainnow drains the trace and statistics reports after signalling on every G17 (#2909), so the throttled post-signal drain covers every G17 and the M5-onlydrain_post_signal_reports()helper is gone.Details
Enable direct compute submission on M5 (
G17S/G17C/G17D):compute_direct()returnedNoneunconditionally on M5 because M5 compute shares the per-priority outer work ring with render and issues host-port gating and submission-history updates, forcing every steady-state M5 compute submission through the global device mutex (shared.state).Port::m5_outer) ordered strictly after the compute queue cell and render publication lock (device mutex -> compute cell -> port.render -> port.m5_outer -> port.qos/mailbox), add non-interfering direct credit consumption (OuterCredits::is_scoped()/consume_direct()) plus direct port views for M5's shared outer ring and submission-history table, guard device-mutex M5 outer-ring publications withm5_outer_lock(), reset cached history geometry on recovery restart, and enable steady-state M5compute_direct().asahi_g17_outer_creditverifying direct credit consumption alongsideOuterScope.Throttle report drains and coalesce event-worker device locks:
worker_deferredtake/restore into the existingshared.stateholds inruntime_event_turn(), skip dropping and re-acquiringshared.statearound a no-opobserve_renders()when render masks are empty, and throttle the post-signalfirmware.drain_reports()(every G17 since drm/asahi: g17: signal G17P completions before draining reports; skip the core power read on back-to-back work #2909) to theHOUSEKEEPING_NS(1 ms) cadence while work stays in flight (still draining immediately on idle, recovery, requested passes, or capacity waiters).Commit 2 touches the
drain_reports()call site indrivers/gpu/drm/asahi/g17/runtime/events.rs, which #2909 also changed; themainmerge reconciles the two.Evidence
scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks on both commits.integration/aurora(b10280c04c2d) + this series (tree b5e76304ea2d):vmlinux,Image,aurora.ko, and 1774 modules built and linked cleanly.asahiKUnit suite: 275/275 PASS (including newasahi_g17_outer_credit).J714s/G17S B1):/sys/kernel/debug/aurora-g17/power:direct_submissions = 696,465, 0 oops, 0 GPU faults.