Repository navigation
drm/asahi: g17: keep completion witnesses and the device-wide compute pool out of client GPU reach - #3242
drm/asahi: g17: keep completion witnesses and the device-wide compute pool out of client GPU reach#3242DjDeveloperr wants to merge 5 commits into
Conversation
Every G17 execution context includes the kernel's upper half. The kernel builds and checks records there that the firmware then reads: kick entries, command descriptors, queue records with their pointer blocks and item rings, per-publication configuration records, and scheduler pages. Several of those mappings also gave the GPU write access: - on G17P, the render kick rings, the render and compute command descriptors, each context's scheduler page and the device-wide compute scheduler; - on G17P and M5, the render queue records, configuration records and support pages, and each compute queue's graph, announcement and configuration records, preemption buffer and usage page. GPU work from any client could therefore rewrite another client's command, or a queue's pointers, owner and context, after the kernel had checked them and before the firmware read them. Map them firmware-only. The GPU reads kick rings and command descriptors through their read-only lower aliases. It reaches a compute queue's preemption buffer and usage page through the aliases a binding maps into its client VM. Neither changes. M5 already mapped its kick rings, descriptors and scheduler pages this way (commits 68e51c0 and 64a142c). Signed-off-by: Dj <[email protected]>
…n G17P The host retires render and compute work on stamps the firmware stores after the work's cache maintenance, and on the work-state nodes that count an ioctl's kicks. On G17P the render stamp pages, each compute queue's stamp page and the work-state pages sat in the upper half every execution context includes, with GPU write access. GPU work from any client could store a stamp that covered another client's work, or hold one back. A covering stamp retires work before the firmware is done with it: it releases the VM's pins on the work's mappings and signals the fence. A stamp held back makes every render group wait out the stampless bound. Map them firmware-only, as M5 does (commit 64a142c). The boot and compute free-list controls and states next to them, which only the firmware reads and writes, become firmware-only too, as the render free list's already are. Signed-off-by: DjDeveloperr <[email protected]>
…ion rings into client VMs On G17P the first compute submission installs a device-wide compute pool and maps its page list, run list and blocks, along with both completion rings, read-write into every client VM that runs compute. The pool's control names those lists by address, and the host retires every client's compute work on the rings' records. GPU work from any client could therefore rewrite the lists every compute queue allocates from, or forge a record that fails another client's VM. Neither the firmware nor the GPU needs them there. With nothing of them mapped into client VMs, every compute command on the A18 Pro still retired on its completion record, and the pool's control counters never moved. Map nothing into client VMs, and drop the pool's page list, run list and blocks, which nothing else maps. That frees 24 MiB. Signed-off-by: DjDeveloperr <[email protected]>
|
Verdict at Blockers: none This covers the two commits on top of #3225 ( Checked:
Evidence
|
|
J700 (MacBook Neo, G17P) at Four one-shot boots in ABBA order (base, head, head, base). Both kernels are built from the Neo's 7.3.0-41 config and run with stock Mesa 26.3.0-30. Every boot returned to stock with the install undone and checked against the pre-install baseline. 1. Clean boot. On all four boots: 0 MMU faults, 0 recoveries and 0 WARN/BUG. The three boots that ran to the end also had 0 new kernel error lines compared with stock, 0 core dumps, 0 failed units, and no process stuck in uninterruptible sleep. On the first base boot, my test script stalled after the reproducer's background render job, which ran 8 minutes because of a setting in my script, and the fallback timer rebooted the Neo. That boot's journal shows no faults, recoveries or hung tasks, and it shut down cleanly. I shortened the job to 40 s for the other boots, and none of them stalled. 2. deqp-vk: 0 differences between base and head, case by case, over 74,660 cases.
3. Smoke: gpubench-vk render.heavy and compute.heavy, and gpubench-gl render.heavy and compute.heavy, all report 4. Perf (gpubench-vk, us per submit, lower is better): 3 passes per boot, 6 per arm. Noise is the larger of the two arms' boot-to-boot spread. Every row is within noise.
5. Retirement counters: "render groups retired on their pass record" and "compute commands retired … without a completion stamp" stayed at 0 on all four boots, the same as base. The driver logs the first one, and no such line appeared. 6. Reproducer (g17peek, run as the ordinary user while a render job runs):
|
|
J714s (MacBook Pro 14" M5 Pro, G17S B1) full row at Setup:
1. g17peek (
2. deqp-vk (325,316 cases:
3. Smoke: gpubench-vk (render.light, compute.light, concurrent.cr, render.postfx, compute.heavy at d1/d2) 9/9 ok, and gpubench-gl (all 13 tests, 4. Perf A/B, gpubench-vk
All 32 rows (base, head, change, base/head boot-to-boot spread)
5. Counts against base:
6. Faults:
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at 9583ee43: approve (code). Merge after the full J700 row at this head that the body lists.
Blockers: none in the code.
Checked
- Render stamp pages, compute stamp pages, the work-state and scheduler pages and the boot/compute free-list controls and states, all in the upper half every context includes, go from GPU+FW to firmware-only on G17P, as M5 already does.
- The device-wide compute pool's page list, run list and blocks, and both completion rings, are no longer mapped into client VMs. The pool backing (24 MiB) goes, since nothing else used it.
- Client GPU work can no longer rewrite state the host retires every client's work on.
install_compute_pool_mappingskeeps the readiness identity with an empty mapping list. - #3225 is merged, so only this PR's own commits are left.
- The smoke row at
71bb8d31supports the claim: 262,144/262,144 compute commands retired on their records, the pool counters never moved, raw-address probes read zero, and there were no faults.
Before merge: the J700 row at this head against main (CTS sync, compute, draw, renderpass). The J714s row and the gpubench ABBA/BAAB perf A/B can follow.
RyanTheTide
left a comment
There was a problem hiding this comment.
Corrected verdict at 9583ee43: the code of this PR's own two commits is fine. Hold the merge until #3225 is reviewed and merged and the full J700 row at this head is in. (My dismissed approval wrongly said #3225 was merged. It is open, and this PR carries its commit, so an approval here would land #3225 unreviewed through auto-merge.)
Checked (this PR's commits)
- Render and compute stamp pages, the work-state and scheduler pages and the boot/compute free-list controls and states, all in the upper half every context includes, become firmware-only on G17P, as on M5.
- The compute pool's lists and blocks and both completion rings are no longer mapped into client VMs, and the unused 24 MiB backing goes.
- The smoke row at
71bb8d31supports it: 262,144/262,144 retired on records, the pool counters were idle, raw-address probes read zero, and there were no faults.
Before merge
- #3225 reviewed and merged.
- This branch updated (it's DIRTY now).
- The J700 row at the new head against main.
|
Merge-train note: <@422957901716652033>, this conflicts with main after tonight's merges. Please merge main in (normal push). The review continues at the new head: App review, CI, and an exact-head hardware row. |
Bring the branch up to date with main. main made the G17P compute descriptors firmware-cached (#3186); this branch maps them firmware-only. Keep both: cached on G17P as main does, firmware-only on every G17. Signed-off-by: Ryan Murray <[email protected]>
…n-state Take #3225's forward merge of main, which this branch builds on. main made the G17P work-state pages firmware-cached; this branch maps them firmware-only. Keep both: cached on G17P as main does, firmware-only on every G17, which leaves kernel_prot unused, so drop it. Signed-off-by: Ryan Murray <[email protected]>
|
@DjDeveloperr: merged #3225's new head |
There was a problem hiding this comment.
Verdict: HOLD at 3ed5ddef
Blockers:
- Stacked on
#3225(carries#3225's commits;#3225must land first). - Hosted CI checks on
3ed5ddefare still queued (apple-build,host-tests, KUnit matrix,pr-readiness,pr-text). - Exact-head hardware rows on
3ed5ddefare still needed on J700 (G17P: CTS sync/compute/draw/renderpass vsmain, plusgpubench-vkA/B) and J714s (M5), because forward-mergingmain(#3186) combines G17P firmware-cached work-state and compute descriptor pages withPROT_FW_SHARED_RWfor the first time (the prior PASS rows were at9583ee43before#3186).
Checked:
- Forward-merge resolution (
3ed5ddef, DCO on all 5 commits,MERGEABLEonmain):drivers/gpu/drm/asahi/g17/context.rs: cleanly combinesmain's G17P firmware-cachedwork_stateprefix (if alloc.uat.is_m5() { 0 } else { UAT_PGSZ }) withmmu::PROT_FW_SHARED_RWand drops now-unusedkernel_prot.drivers/gpu/drm/asahi/g17/initdata.rs: removes unused 24 MiBComputeSharedbacking (pages,runs,blocks), keepsidfor VM readiness tracking (cache_compute_vm()clears old mappings and installs emptyKVec::new()undershared.idsocompute_vm_cached()stays idempotent), and moves boot/compute free-list controls/states and render stamp pages (DESCRIPTOR_PAGE_A/B) toPROT_FW_SHARED_RW/PROT_FW_PRIV_RW(preserving the private/shared split).drivers/gpu/drm/asahi/g17/queue/compute.rs: moves computesupport(completion stamp) page toPROT_FW_SHARED_RWon both M5 and G17P.drivers/gpu/drm/asahi/g17/runtime.rs&tools/asahi/g17-compute-constructor-tests.py:ComputeShared::new()drops unuseddev/uat/allocoutside the mutex while preservingcompute_buildingserialization and matching host-test fixture.
- Host tests reported passing locally (
run-host-tests.py --only g17283/283).
Evidence
- Diff vs
main:+78/-138across 7 files, 5 commits (59942890,7eeb3974,9583ee43,6bf65945,3ed5ddef), DCO on all 5,MERGEABLEonmain. - Code and merge-resolution audit found no blockers; ready to approve once
#3225merges, hosted CI completes green, and the exact-head J700 + J714s rows pass.
There was a problem hiding this comment.
Verdict: MERGE at 3ed5ddefa9e6
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Forward-merge resolution (3ed5ddef, DCO on all 5 commits, MERGEABLE on main):
drivers/gpu/drm/asahi/g17/context.rs: cleanly combinesmain's G17P firmware-cachedwork_stateprefix (if alloc.uat.is_m5() { 0 } else { UAT_PGSZ }) withmmu::PROT_FW_SHARED_RWand drops now-unusedkernel_prot.drivers/gpu/drm/asahi/g17/initdata.rs: removes unused 24 MiBComputeSharedbacking (pages,runs,blocks), keepsidfor VM readiness tracking (cache_compute_vm()clears old mappings and installs emptyKVec::new()undershared.idsocompute_vm_cached()stays idempotent), and moves boot/compute free-list controls/states and render stamp pages (DESCRIPTOR_PAGE_A/B) toPROT_FW_SHARED_RW/PROT_FW_PRIV_RW(preserving the private/shared split).drivers/gpu/drm/asahi/g17/queue/compute.rs: moves computesupport(completion stamp) page toPROT_FW_SHARED_RWon both M5 and G17P.drivers/gpu/drm/asahi/g17/runtime.rs&tools/asahi/g17-compute-constructor-tests.py:ComputeShared::new()drops unuseddev/uat/allocoutside the mutex while preservingcompute_buildingserialization and matching host-test fixture.- Host tests reported passing locally (
run-host-tests.py --only g17283/283).
Follow-ups (not blocking): Merge parent #3225 first; follow-ups: queued CI, J700/J714s rows
What: Keep the state the host retires G17P work on, and the device-wide compute state, out of reach of client GPU work:
Client GPU work then no longer reaches state that the host and firmware use for every client's work.
This carries #3225's commit unchanged. Merge #3225 first; the last two commits are this PR.
Tested: Built at
9583ee437211(asahi profile). Host tests: G17 220/220 (the compute-constructor test follows the pool's new constructor), Neo 14/14, M5 97/97. On J700 (G17P), the same changes at71bb8d314626(plus log-only lines):Risk: Two-way · G17P GPUs (A18 Pro, M4 Pro/Max); shared drm/asahi G17 code. M5 changes only through #3225's commit.
Not yet: