Skip to content

drm/asahi: g17: map validated command and queue records firmware-only - #3225

Merged
RyanTheTide merged 2 commits into
mainfrom
fix/g17-fw-only-records
Dec 1, 2026
Merged

RyanTheTide merged 2 commits into
mainfrom
fix/g17-fw-only-records

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: Map the G17 records the kernel validates and the firmware then reads firmware-only in the kernel's upper half, which every execution context includes:

  • on G17P: render kick rings, render and compute command descriptors, each context's scheduler page and the device-wide compute scheduler;
  • on G17P and M5: render queue records, configuration records and support pages, plus each compute queue's graph, announcement and configuration records, preemption buffer and usage page.

GPU work from any client could rewrite these after the kernel checked them and before the firmware read them. The GPU's own access goes through the read-only lower aliases and the client-VM aliases, which don't change. M5 already mapped its kick rings, descriptors and scheduler pages this way (68e51c0, 64a142c).

Tested: Built at 59942890a5fc (asahi profile, Image + modules) with no new warnings. Host tests: G17 220/220, Neo 14/14, M5 97/97, T6040/T6041 1/1 each. J700 (G17P) smoke of the same change at 71bb8d314626, together with #3242's commits and log-only lines:

  • 0 MMU faults, recoveries or new kernel errors;
  • a compute shader that found its own kick entry through its read-only view read zero from the descriptor and queue record that entry names, where the default kernel returns live data;
  • gpubench VK/GL ok.

The 48 multiview query/timestamp CTS cases that failed on that kernel fail the same way on main without it (#3243).

Risk: Two-way · every G17 GPU (A18 Pro, M4 Pro/Max, M5 family); shared drm/asahi G17 code.

Not yet: J700 (G17P) and J714s (G17S) rows, queued at #3242's head 9583ee437211, which carries this commit unchanged: Vulkan CTS sync, compute, draw and renderpass subsets vs main, GL and VK gpubench smoke, a gpubench-vk ABBA/BAAB perf A/B, and the raw-address shader on both Macs. M4 Pro/Max rows after merge. Textual overlap with #3186 (adjacent lines in context.rs and queue/compute.rs); whichever lands second resolves it. prot keeps its name in Graph::new, so #3186's cache-policy test still matches.

Details

Only protections change; cache attributes, sizes and placements stay as they were. The pooled families keep one protection per family (descriptors, queue state, queue config, scheduler), so a reused pooled object never comes back with a different one. The compute queue's stamp page and the G17P work-state, stamp and free-list pages follow in a separate PR.

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]>
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

Reviewed 59942890a5fc against the G17/UAT paths (including T6040/T6041 clean_tables, native_gpu_permissions, set_fw_cached_prefix(), Pool::allocate() family uniformity, and lower/client alias consumers). The diff looks clean—every changed upper-half mapping only feeds firmware paths (GPU hardware uses the lower/client aliases), Pool::allocate() keeps uniform prot per family, and set_fw_cached_prefix() / reprot_pages() preserve AP_FW and PoC cleaning cleanly.

Two adjacent upper-half PROT_GPU_FW_SHARED_RW allocations that don't appear in #3242 either (non-blocking follow-up candidates):

  • drivers/gpu/drm/asahi/g17/queue/render/memory.rs:434-447 (NeoGeneration::new): fragment is still alloc.kernel(..., PROT_GPU_FW_SHARED_RW) in the upper half while GPU register 0x14080 uses fragment_client (PROT_GPU_SHARED_RW) and firmware reads status_fw_va—same pattern as compute::Graph::usage here, and M5's status_fw in generation.rs:117-120 is already PROT_FW_SHARED_RW. (Worth noting tools/asahi/neo-auxiliary-tests.py:38 currently asserts p == 3 on that allocation if/when changed.)
  • drivers/gpu/drm/asahi/g17/buffer.rs:821-839 (Manager::new graph): parameter-buffer graph in kernel_vm, while the GPU gets the client-VM page_list alias (m5/resources/graphics_job.rs:116-117 / parameter_buffer.rs:78 map the high view firmware-only).

Happy to run a J616C (M4 Max / T6041) hardware row once the G17P test runs are ready.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review, and for checking the T6040/T6041 paths.

Agreed on both. I'll take them in a follow-up PR with its own J700 smoke, rather than widen this one while its rows are queued:

  • the G17P fragment status page;
  • the parameter-buffer graph. That one needs checking against what the G17P tiler itself writes in the state and scene entries before it can go firmware-only.

A J616C row would be very welcome. Please test #3242's head 9583ee437211, which carries this commit unchanged, against base main 7be48f374c67. The useful checks are the Vulkan CTS synchronization, compute, draw and renderpass subsets vs base, plus a GL/VK gpubench smoke and any GPU fault or recovery lines. Main currently fails some multiview timestamp cases on its own (#3243), so those should fail the same way on both.

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 26, 2026 19:27
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 26, 2026 19:27
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 6bf65945: not ready yet

Check Detail
CI at head no failing: host-tests, apple-build, host-tests, KUnit ane-boot, KUnit ane-pm, KUnit dcp-fabric
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 6bf65945
Conflicts ok none
PR text ok Risk: two-way · every G17 GPU (A18 Pro, M4 Pro/Max, M5 family); shared drm/asahi G17 code.

Areas: area:gpu

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

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

Verdict at 59942890: HOLD. I found no code blocker, but it isn't merge-ready.

Missing before merge

  1. Rebase. It now conflicts in g17/queue/compute.rs after #3186 made the G17P compute descriptors firmware-cached. The rebased head combines firmware-only with cached on G17P, which has never booted. That's low risk, because render descriptors already do it, but it needs a row.
  2. A row at the head, on both families.
    • The J700 smoke ran at 71bb8d31, before #3186, together with #3242's commits and log-only lines. The head itself was only built.
    • M5 protections also change: render queue/config records, the render support page, and the compute graph, records, preemption and usage pages. No M5 Mac was booted.
    • Needed: J700 (G17P) and J714s (M5) at the new head, with renders, compute and timestamps exercised.

Please confirm

  • On M5, m5_usage() (memory.rs:254) hands addresses in the now firmware-only render support page to the command tail (resolved_tail_value). Does only the firmware write there?
  • On G17P, the render Support page holds parameter-buffer state and scene entries that point back into it (block_table, counter, statistics). On the parameter-buffer graph you said you'd first check what the tiler writes. The J700 smoke's 0 faults suggests these are firmware-only, but please state it.

Checked

  • Every changed upper-half object against GPU use. Preemption, usage and operand pages reach the GPU through client aliases from bind(), and kick rings and descriptors use the low aliases. m5_timestamps and the G17P compute support page deliberately stay GPU-mapped.
  • Each pooled family keeps one protection. It removes is_m5 gates and adds none.
  • --only g17 220/220.

Non-blocking: a host test pinning the new protections, like #3186's cache-policy check, would keep them from regressing.

#3242 stays held behind this.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 27, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train note at 59942890: this conflicts with main (g17/ moved under #3388, #3437 and #2724 tonight). <@422957901716652033>, please merge main in. The review continues at the new head (App + CI + a G17 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]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

@DjDeveloperr: forward-merged main (normal push, no rebase); new head 6bf659451f28.
The only real conflict was g17/queue/compute.rs: main (#3186) made the G17P compute descriptors firmware-cached, and this PR makes them firmware-only. The merge keeps both: cached on G17P as main has it, PROT_FW_SHARED_RW on every G17. context.rs only needed main's Exposure line next to your comment. The diff against main is the same as your commit's apart from comment wrapping.
Tests: tools/asahi/run-host-tests.py --only g17 283/283 pass. No local Rust kernel build, so CI covers that.
Still needed: J700 and J714s rows at this head (renders, compute, timestamps; G17P cached + firmware-only descriptors has never booted), answers to questions 3 and 4 from the review, and App review at head. #3242 has been updated on top of this.

RyanTheTide added a commit that referenced this pull request Nov 30, 2026
…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]>

@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: HOLD at 6bf65945

Blockers:

  • Hosted CI checks on 6bf65945 are still queued (apple-build, host-tests, KUnit matrix, pr-readiness, pr-text).
  • Exact-head hardware rows on 6bf65945 are still needed on both families — J700 (G17P) and J714s (M5) — exercising render, compute, and timestamps, because forward-merging main (#3186) combines G17P firmware-cached compute descriptors (cached_bytes = size) with PROT_FW_SHARED_RW for the first time.
  • Two open confirmation questions from the prior review remain unanswered (m5_usage() in memory.rs and G17P render Support page self-pointers being firmware-only writes).

Checked:

  • Forward-merge resolution (6bf65945, DCO on both commits, MERGEABLE on main):
    • drivers/gpu/drm/asahi/g17/queue/compute.rs: cleanly combines main's G17P firmware-cached prefix (if alloc.uat.is_m5() { 0 } else { size }) with mmu::PROT_FW_SHARED_RW on DescriptorRing::new(), keeps lower = mmu::PROT_GPU_FW_SHARED_RW for operand and context_low, keeps support_prot split for #3242, and keeps m5_timestamps GPU+FW mapped.
    • drivers/gpu/drm/asahi/g17/context.rs: preserves main's Exposure line and kernel_prot (still used for work_state until #3242), moving scheduler (both M5 pooled and G17P ordinary) to PROT_FW_SHARED_RW.
    • drivers/gpu/drm/asahi/g17/initdata.rs, kick.rs, queue/render/memory.rs: ComputeScheduler, render kick ring high, and render descriptors/records/support pages use PROT_FW_SHARED_RW while GPU reads lower/client aliases; pooled families keep uniform protection.
  • Host tests reported passing locally (run-host-tests.py --only g17 283/283).
Evidence
  • Diff vs main: +30/-24 across 5 files, 2 commits (59942890, 6bf65945), DCO on both, MERGEABLE on main.
  • Code and merge-resolution audit found no blockers; ready to approve once hosted CI is green, exact-head J700 + J714s rows pass, and the two confirmation items are answered.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) ci-failing A check failed at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 30, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

@DjDeveloperr #3225 is now at 6bf65945 (a merge of main) and #3242 at 3ed5ddef. The review app's HOLD on both asks only for CI and exact-head rows on J700 and J714s. We're queueing the J700 rows. Can you take the J714s render/compute/timestamp row on both heads? #3225 lands first.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 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 6bf659451f28

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 (6bf65945, DCO on both commits, MERGEABLE on main):

  • drivers/gpu/drm/asahi/g17/queue/compute.rs: cleanly combines main's G17P firmware-cached prefix (if alloc.uat.is_m5() { 0 } else { size }) with mmu::PROT_FW_SHARED_RW on DescriptorRing::new(), keeps lower = mmu::PROT_GPU_FW_SHARED_RW for operand and context_low, keeps support_prot split for #3242, and keeps m5_timestamps GPU+FW mapped.
  • drivers/gpu/drm/asahi/g17/context.rs: preserves main's Exposure line and kernel_prot (still used for work_state until #3242), moving scheduler (both M5 pooled and G17P ordinary) to PROT_FW_SHARED_RW.
  • drivers/gpu/drm/asahi/g17/initdata.rs, kick.rs, queue/render/memory.rs: ComputeScheduler, render kick ring high, and render descriptors/records/support pages use PROT_FW_SHARED_RW while GPU reads lower/client aliases; pooled families keep uniform protection.
  • Host tests reported passing locally (run-host-tests.py --only g17 283/283).

Follow-ups (not blocking): queued CI; exact-head J700/J714s rows; answer m5_usage and support-page questions

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 6bf659451f28 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 6bf6594 that the readiness check found (PR body or comment). CI: linux train L4 = main (after L3) + 34 approved PRs (#3419 dropped: conflicts): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-fabric/dcp-topology/dcp-display/macaudio/asahi/sep all pass, host tests apple-dcp + apple-scaler-recovery pass (the red host-tests on some heads were base failures since fixed on main). The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 8db4eb2 into main Dec 1, 2026
24 of 43 checks passed
@RyanTheTide
RyanTheTide deleted the fix/g17-fw-only-records branch December 1, 2026 09:06
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) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants