Skip to content

drm/asahi: g17: refuse render_direct when a sibling pair holds prefix work - #3301

Closed
funkzy wants to merge 1 commit into
aurora-silicon:mainfrom
funkzy:pr/linux-g17-direct-cross-pair
Closed

funkzy wants to merge 1 commit into
aurora-silicon:mainfrom
funkzy:pr/linux-g17-direct-cross-pair

Conversation

@funkzy

@funkzy funkzy commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What: Guard render_direct() against dropping cross-pair prefix dependencies on multi-pair G17 GPUs by refusing the direct lend whenever a sibling render pair for the same owner holds live wait_through[0]-covered work (including a pair currently lent out for preparation or heap growth), falling back to the device-mutex path (Fixes: d272a7060d20).

Tested: J775D (Mac Studio, M5 Ultra) at f21d6ff1a7aa9 on bare main (8c6992db4b9f) under published Aura aura-main-7bf44a63 on the 27.0 stub: render.light d8 (32.72 vs 32.90 us), render.light d64 (31.25 vs 31.13 us), render.heavy fill 1080p (38.19 vs 38.17 us), compute.light d8/d64, and 10 s two-pair concurrent render.light d8 stress all pass with 0 GPU faults, 0 recoveries, 0 refusals, 0 new kernel errors, and 0 new failed systemd units.

Risk: Two-way door · affects only multi-pair G17 GPUs (clusters >= 4, G17C and G17D) when a single owner submits renders across more than one render pair concurrently; single-pair boards and single-pair workloads take an O(1) early exit and stay on render_direct().

Not yet: G17C (J716c/K114c) multi-pair smoke row and a dedicated single-owner cross-pair wait_through[0] reproducer row.

Details

Why this shape

  • Where the gap lived. On multi-pair G17 boards, render_direct() lends a single render pair (slot) and collects its render dependencies with Pair::own_dependencies(), which inspects only that pair. Meanwhile, publication_barriers() omits same-owner renders covered by wait_through[0], relying on the render prefix to have ordered them. When the same owner has live prefix-covered work on a sibling render pair (either resident in entry.pair or lent out in entry.borrowed_dependencies), neither collector emitted a barrier for it.
  • The narrower alternative. Adding a narrow single-condition check on resident sibling pairs alone would miss pairs lent out for preparation or heap growth, and running the check after Pair::host_growth_target() would reset firmware page high-water accounting on a refused lend.
  • The one source used. Registry::has_other_pair_dependencies() reuses the exact same Pair::collect_dependencies() and BorrowedDependencies::collect() collectors that Registry::render_dependencies() uses, walking sibling pairs for the same owner with an immediate early exit when wait_through[0] is None. Calling it in lend_render() before Pair::host_growth_target() routes any cross-pair prefix dependency cleanly back to the device-mutex path without side effects.
  • Scope across boards. Single-pair GPUs have no sibling entry to inspect, and single-pair owners on multi-pair GPUs take the fast path unchanged with no extra locking or allocations.

Change

  1. f21d6ff1a7aa9 — drm/asahi: g17: refuse render_direct when a sibling pair holds prefix work: add Registry::has_other_pair_dependencies() in drivers/gpu/drm/asahi/g17/runtime/render/dependencies.rs and call it ahead of Pair::host_growth_target() in lend_render() (drivers/gpu/drm/asahi/g17/runtime/render/direct.rs).
Evidence

Testing

Own-base A/B row on J775D (Mac Studio, M5 Ultra): kit xpair-1 (window xpair2@20261126-1100) is bare main 8c6992db4b9f plus this commit (f21d6ff1a7aa9, no other PRs carried), compared against baseline kit xpair-1b (window xpair2@20261126-1100), bare main 8c6992db4b9f alone. Both arms ran one-shot with a read-only root on the default J775D command line under the 27.0 stub and published Aura aura-main-7bf44a63 (Hyprland stopped, Borealis 3fc21af143, client pinned to 4.608 GHz P-core on the GPU IRQ die; ALARM has no SELinux):

Metric Baseline kit xpair-1b PR kit xpair-1
Boot & steps (row_window.sh) BOOT-OK (57 s), steps_rc=0 BOOT-OK (55 s), steps_rc=0
render.light tri d8 (us/submit) 32.90 32.72
render.light tri d64 (us/submit) 31.13 31.25
render.heavy fill 1080p d8 (us/submit) 38.17 38.19
compute.light d8 / d64 (us/submit) 18.60 / 17.11 19.58 / 17.04
2-pair concurrent render.light d8 (10 s) both rc=0 (63.20 / 63.16 us) both rc=0 (65.96 / 65.98 us)
GPU faults / recoveries / timeouts / refusals 0 / 0 / 0 / 0 0 / 0 / 0 / 0
Failed systemd units / new kernel errors 2 / 0 2 (same 2) / 0
  • aurora.ko module build (CONFIG_DRM_ASAHI=m, CONFIG_DRM_ASAHI_M5=y): 0 new warnings.

… work

On multi-pair boards (clusters >= 4, G17C and G17D), render_direct()
lends one render pair and resolves its dependencies through
Pair::own_dependencies(), which only inspects that pair. Meanwhile
publication_barriers() skips same-owner renders covered by
wait_through[0], assuming the render prefix already ordered them. If
the same owner has live prefix-covered work on another render pair
(including a pair lent out for preparation or heap growth), neither
collector emitted a barrier for it.

Add Registry::has_other_pair_dependencies() to walk sibling pairs
(with an early exit when wait_through[0] is None and using the
existing pair / borrowed_dependencies collectors) and refuse the
direct lend to the device-mutex path when any sibling pair holds live
prefix-covered work. Run the check in lend_render() ahead of
Pair::host_growth_target() so this refusal never resets firmware page
high-water accounting.

Fixes: d272a70 ("drm/asahi: g17: publish steady-state renders through the port")
Signed-off-by: Jeff Queisser <[email protected]>
@funkzy
funkzy requested review from a team and DjDeveloperr as code owners November 26, 2026 19:15
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (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 f21d6ff1: not ready yet

Check Detail
CI at head ok 18 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at f21d6ff1
Conflicts no merge conflicts with main: merge it in (no force push)
PR text ok Risk: two-way · affects only multi-pair G17 GPUs (clusters >= 4, G17C and G17D) when a single owner submits renders across more than one render pair concurrently; single-pair boards and single-pair workloads take an O(1) early exit and stay on renderdirect().

Areas: area:gpu

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

@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: Code approved at f21d6ff1a7aa9. Targeted hardware evidence remains open.

Checked: The direct path tests the prefix before lending the pair or sampling heap growth. It checks both resident pairs and borrowed dependency state and falls back to the existing registry-wide dependency path. The guard is based on owner and prefix state. Apple build, host tests and KUnit are green.

Before merge, attach the same-owner cross-pair case and G17C peer row identified in the PR. The useful signal is a live sibling dependency that forces fallback and completes in order, with the ordinary direct path still exercised.

DjDeveloperr added a commit that referenced this pull request Nov 27, 2026
…refix work

Pair::own_dependencies() only inspects the lent pair, whereas
Registry::render_dependencies() walks every render pair of the owner
(including pairs lent out for preparation or heap growth via
borrowed_dependencies).

Coordinating with #3301, add Registry::has_other_pair_dependencies() and
call it in lend_render() ahead of Pair::host_growth_target() so any live
or borrowed sibling pair holding work covered by either wait_through[0]
or tiling_wait_through[0] (including a sibling whose dependency belongs
to the tiling prefix) falls back to the device-mutex path.

Extend g17-direct-stage-prefixes-tests.py with direct-vs-mutex parity
comparisons and live/borrowed/tiling-only sibling fallback tests plus 3
new mutation traps.

Signed-off-by: DjDeveloperr <[email protected]>
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks @funkzy for this fix. While forward-merging current main (2fd49a6) we found that main already carries it in extended form: 334dbc6 ("refuse direct staged render when sibling pair holds prefix work", merged with #3388) adds the same Registry::has_other_pair_dependencies() check in lend_render() before host growth. It also covers tiling_wait_through[0] and the tiling dependencies, and adds host tests with mutation traps.
The only conflicts are in dependencies.rs and direct.rs. Main's version is a superset of this PR's two hunks, so resolving them leaves no diff against main. We did not push a merge to your branch for that reason; the maintainers can decide whether to close this as superseded by #3388.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Closing as superseded: main already has this via #3388 (334dbc6c), which is a superset of the change here. Merging this branch with main leaves an empty diff. Thanks @funkzy, your render_direct guard is in. The J716c multi-pair fallback row now runs against main.

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) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (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.

2 participants