Skip to content

drm/asahi: accept FRAGMENT_BARRIERS on G13, G14 and G14X - #2785

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
prfix/fragment-barriers-r2-20261122
Nov 22, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
prfix/fragment-barriers-r2-20261122

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #2637 (and before it #1811). Same change as #2637 7450be6, rebuilt as one clean commit on integration/aurora f5f023b: the commit carries human identity and Signed-off-by: only (the old commit had an Assisted-by: trailer, and history is never force-pushed, so the fix is a new branch).

Problem

On G13/G14/G14X the legacy queue puts a render's wait for earlier renders on its vertex (tiling) queue, so the tiling of render N+1 cannot start before the fragment work of render N has finished, even when only the fragment half of N+1 depends on it.

Change

  • Advertise DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS on the #[versions(AGX)] backend. That backend serves G13 (M1 family), G14 (M2) and G14X (M2 Pro/Max/Ultra); the title and commit message now say so. G15 and later are unchanged (m3/g15 override feature_flags(); g16/g17/g18/m5 keep 0).
  • For a render with DRM_ASAHI_RENDER_FRAGMENT_BARRIERS, the vdm_barrier wait names only earlier fragment work of the same queue, which the fragment workqueue already runs first, so no barrier is added. Renders without the flag are unchanged.
  • Review nits: the comment above the barrier loop now says what the code does (no barrier with the flag, vertex queue without it), and the explicit barrier is built in one helper, add_explicit_barrier(), instead of two copies.

Testing

Still to run (on this head)

  • M1 Pro (G13S) and M2 (G14G): gpubench and the 2,402-case CTS render-ordering subset, plus a >= 1 h concurrent short-lived multi-context soak with 0 GPU faults, firmware crashes and timeouts, and the full regression counts (AVC denials, failed units, new kernel errors). Being run now; results will be posted here.
  • G14X (M2 Pro/Max), G13G (M1) and G13C/D (M1 Max/Ultra): we have no such Mac in the lab. Rows from someone with one are welcome; until then those are untested.
Earlier rows and detail from #2637

Replaces #1811, rebased onto current integration/aurora (conflicts in drivers/gpu/drm/asahi/queue/render.rs: the base moved the render flag and size checks from submit_render() into get_tiling_params(), so FRAGMENT_BARRIERS is added to the accepted flags there. Only the net commit 6a743fa is carried; the two cpufreq commits and their reverts cancel out and are dropped).

G13/G14: the legacy queue puts a render's wait for earlier renders on its vertex (tiling) queue, so the tiling of render N+1 cannot start before the fragment work of render N has finished, even when only the fragment half of N+1 depends on it.

This advertises the existing DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS on the G13/G14 backend. For a render with DRM_ASAHI_RENDER_FRAGMENT_BARRIERS, the wait named by vdm_barrier only refers to earlier fragment work of the same queue (index 0 is the queue's last fragment event, later indices are renders of the same submission). The fragment workqueue already runs that work first, so no barrier is added. Each fragment half still waits for its own vertex half, and compute dependencies keep ordering the vertex half. Renders without the flag are unchanged.

Userspace: mesa Borealis sets the flag on serialized G13/G14 queues only when the recorded dependencies show the vertex half reads nothing an earlier render produced (aurora-silicon/mesa#265).

Results (gpubench 0dae261, us per submission, lower is better; same boot, Mesa with the flag off vs on, two interleaved runs each, which agree within 1%):

row M1 Pro (G13X) off -> on M2 (G14G) off -> on
render.heavy geom 1080p d16 339 -> 162 553 -> 294
render.tvb 32k tris d4 3378 -> 2049 5102 -> 2717
render.heavy fill 720p d16 210 -> 139 315 -> 256
render.heavy fill 1080p d16 391 -> 312 643 -> 577
render.light tri d16 49.9 -> 46.0 62.7 -> 56.0
depth-1 rows, compute.light, compute.heavy unchanged unchanged

Vulkan CTS 1.4.7.0: a 2,402-case render-ordering subset (synchronization2 graphics write -> vertex/fragment/indirect reads, pipeline barriers, transform feedback, renderpass2 suballocation, occlusion queries) is case-for-case identical with the flag off and on, on both Macs (833 Pass / 1569 NotSupported / 0 Fail). On the M2 a 46,515-case broad run (api, query_pool, synchronization, synchronization2, ubo, glsl, texture, graphicsfuzz, ssbo, transform_feedback.simple, draw indirect) is also case-for-case identical (20947 Pass / 25564 NotSupported / 4 QualityWarning in both / 0 Fail).
vkmark: M1 Pro 10463 -> 10492, M2 8541 -> 8641. 0 AVC denials, no GPU faults or timeouts.

Rebased onto integration/aurora c3d01cb (2026-11-21): drivers/gpu/drm/asahi/ builds for arm64 (LLVM=1, W=1, defconfig + asahi.config) with no warnings in the touched files; KUnit asahi* on arm64 qemu 323/324 passed (1 unrelated skip), including asahi_render_tiling_params 4/4; run-host-tests.py --only legacy-frequency 1/1, agx-stats-busy 2/2, asahi-stats-raw 1/1; checkpatch.pl --strict clean.

Assisted-by: LLM (Claude:Opus 5.5)

The legacy queue puts a render's wait for earlier renders on its vertex
queue, so the tiling of render N+1 cannot start until the fragment work
of render N has finished, even when only the fragment half of N+1
depends on it.

Advertise DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS on the backend shared by
G13 (M1 family), G14 (M2) and G14X (M2 Pro/Max/Ultra): the
#[versions(AGX)] GpuManager implementation. For a render carrying
DRM_ASAHI_RENDER_FRAGMENT_BARRIERS that wait names only earlier fragment
work of the same queue, which its fragment workqueue already runs first,
so no barrier is added at all. The fragment half still waits for its own
vertex half, and compute dependencies keep ordering the vertex half.

The explicit barrier is now built in one helper,
add_explicit_barrier(), used for both the deferred render wait and the
other queue barriers.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

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

Reviewed 24a7cfa37871f2e168abf5332fcf394300a88745 against pre-pr-checklist.md (§1–§6): REQUEST_CHANGES (code and §1–§4/§6 are clean; blocked on §5 hardware evidence and CI completion on this head).

What looks good

  • Barrier semantics (drivers/gpu/drm/asahi/queue/mod.rs): events[SQ_RENDER][0] is the queue's own prior q_frag event and subsequent entries are earlier renders of the same submission, all ordered by the in-order fragment workqueue. Deferring SQ_RENDER waits for DRM_ASAHI_CMD_RENDER and omitting the explicit barrier when DRM_ASAHI_RENDER_FRAGMENT_BARRIERS is set matches uapi/drm/asahi_drm.h while preserving barrier index validation, cdm_barrier vertex ordering, and unchanged vertex barriers when the flag is absent.
  • Prior #2637 review nits addressed: Explicit barrier creation is cleanly factored into Queue::ver::add_explicit_barrier(), and the comment above the barrier loop now accurately matches the implementation.
  • Backend scoping & flags (gpu.rs, queue/render.rs): backend_feature_flags() on #[versions(AGX)] impl Gpu for GpuManager::ver cleanly advertises DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS only for G13/G14/G14X without affecting m3/g15 (which override feature_flags()) or g16/g17/g18/m5 (default 0). get_tiling_params() admits DRM_ASAHI_RENDER_FRAGMENT_BARRIERS and the flag bit is never forwarded raw to firmware.
  • §1 / §2 / §3 / §4 / §6: Clean. No chip/board/fw gates, no cmdline/module params, no hardcoded safety constants, single clean commit with human author/committer and Signed-off-by: only (PR body carries Assisted-by:), Borealis naming clean.

Blockers before approval

  1. §5 Live hardware verification on 24a7cfa3 (still pending): As noted under Still to run, the performance and CTS rows in <details> predate the rebase onto integration/aurora (f5f023bc) and the add_explicit_barrier() refactor, and no soak row has been posted yet. Before approval, please post exact-head (24a7cfa3) rows on default kernel command line for M1 Pro (G13S) and M2 (G14G):
    • Same-machine A/B gpubench + 2,402-case Vulkan CTS render-ordering subset (conformance unchanged);
    • ≥ 1 h concurrent short-lived multi-context soak with Mesa setting DRM_ASAHI_RENDER_FRAGMENT_BARRIERS (important given G13S's concurrent short-lived context TE/firmware-crash sensitivity) confirming 0 GPU faults, 0 firmware crashes, 0 timeouts;
    • Full regression row (0 SELinux/AVC denials, 0 failed units, 0 new kernel errors).
      (Good disclosure that G14X / G13G / G13C/D are not in the lab and rows from owners are welcome.)
  2. CI (Host tests / host-tests): Still IN_PROGRESS at review time; needs to finish green on 24a7cfa3.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The exact-head kernel kit for 24a7cfa3 is available in the draft test release, with checksums and the benchmark and CTS case lists.

A G14X row on an M2 Pro or Max would complete the hardware coverage. Please use a guarded one-shot with the default kernel command line and report the interleaved gpubench comparison, the 2,402 CTS case results, and a one-hour concurrent render soak. Include GPU faults, new kernel errors, SELinux denials and failed-unit counts. The M1 Pro and base M2 runs are underway.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

At 24a7cfa3, I ran both reference Macs on guarded one-shots with the saved fleet command line. The same Borealis build was used for both arms of the interleaved A/B.

Row M1 Pro (G13X) M2 (G14G)
1080p geometry, depth 16, control → default (µs/submit) 339.93 → 162.66 553.10 → 290.70
32K-triangle TVB, depth 4 (µs/submit) 3378.38 → 2057.93 5263.74 → 2747.25
2,402 Vulkan CTS cases, both settings 833 pass, 1,569 not supported, 0 fail 833 pass, 1,569 not supported, 0 fail
Concurrent render soak 3602 s, 89 successful runs per context 3603 s, 89 successful runs per context

The CTS status files matched case for case. Two contexts ran concurrently during each soak. The periodic checks showed zero GPU fault markers and audit denials, and neither Mac had any failed units. Some M1 Pro depth-one samples varied across arms, so the table reports the stable depth-16 geometry and depth-4 TVB rows.

Each lean test kernel logged one new bpf-restrict-fs startup error, and both lacked /sys/kernel/btf/vmlinux. I'm rebuilding this head with the fleet BTF configuration for the clean boot check. Both Macs were restored to fleet78. G14X is still pending.

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

Re-reviewed 24a7cfa37871f2e168abf5332fcf394300a88745 against pre-pr-checklist.md (§1–§6): APPROVE.

All blockers from the earlier review are now satisfied on exact head 24a7cfa37871f2e168abf5332fcf394300a88745:

  • CI (Host tests / host-tests): SUCCESS on 24a7cfa37871f2e168abf5332fcf394300a88745.
  • §5 Hardware evidence on 24a7cfa3 (default/saved fleet command line, guarded one-shots, same Borealis build for both arms):
    • Interleaved A/B gpubench shows large, consistent speedups on both G13 and G14:
      • 1080p geometry, depth 16: M1 Pro (G13X) 339.93 → 162.66 µs/submit, M2 (G14G) 553.10 → 290.70 µs/submit.
      • 32K-triangle TVB, depth 4: M1 Pro (G13X) 3378.38 → 2057.93 µs/submit, M2 (G14G) 5263.74 → 2747.25 µs/submit.
    • 2,402-case Vulkan CTS render-ordering subset: 833 pass, 1,569 not supported, 0 fail on both settings on both Macs, with status files matching case-for-case.
    • > 1 h concurrent multi-context render soak: 3602 s on M1 Pro and 3603 s on M2 (2 concurrent contexts, 89 successful runs per context), with 0 GPU fault markers, 0 audit/SELinux denials, and 0 failed units.
  • §1 / §2 / §3 / §4 / §6: Remain clean (single commit with human authorship and Signed-off-by: only, PR body Assisted-by: disclosure, Borealis naming, clean #[versions(AGX)] scoping via backend_feature_flags()).

Non-blocking notes

  • Clean-boot BTF check (bpf-restrict-fs): The single bpf-restrict-fs startup error on both lean test kernels is attributable to the lean test config lacking /sys/kernel/btf/vmlinux (CONFIG_DEBUG_INFO_BTF), unrelated to the 3 drivers/gpu/drm/asahi/ files touched here. Posting the fleet-BTF rebuild clean-boot result (0 new kernel errors) before fleet batching is appreciated, though not a code blocker.
  • G14X (M2 Pro/Max) coverage: G14X instantiates the exact same #[versions(AGX)] GpuManager::ver / Queue::ver backend (GpuManagerG14XV13_5 in drivers/gpu/drm/asahi/driver.rs) already proven on both G13 (M1 Pro) and G14G (M2). Since G14X is not in the lab and a test kit + call for runs has already been posted per §1, this does not block approval; a follow-up G14X confirmation row from an owner remains welcome.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX3) at 24a7cfa: no blockers. Merges clean on integration/aurora 933a43f.

Full review

VERDICT: NO BLOCKERS

Checked:

  • What the flag does on these generations. Nothing is sent raw to firmware. render.rs:54-62 only adds the bit to the
    accepted-flags mask, and the other flag uses are 224, 265, 377, 446, 874 and 1329. The behaviour change is in the kernel:
    • A render's vdm_barrier wait is deferred (queue/mod.rs:1289-1291).
    • It is then dropped when the flag is set (1316-1329) and added to the vertex job when it is not.
    • events[SQ_RENDER] only ever holds the queue's own q_frag event (index 0, mod.rs:1157-1160) or frag events of earlier
      renders in this submission (1341-1353). So the dropped wait always names earlier fragment work of the same fragment workqueue.
    • That queue completes in order (workqueue.rs:1065: "a later stamp proves this one's firmware tail is done"), so fragment N+1
      still runs after fragment N. This matches the UAPI text (include/uapi/drm/asahi_drm.h:1624-1638).
  • Kernel safety. Dropping the wait is the same as vdm_barrier = DRM_ASAHI_BARRIER_NONE, which every client can already
    submit (mod.rs:1282-1284). So the flag opens no hazard on shared queue resources (TVB/heap, scene slots) that the UAPI did not
    already allow. Scenes are allocated at submit time, so the number in flight does not change.
  • UAPI compatibility. Existing userspace that does not set the flag keeps the same barrier on the vertex job. The flag was EINVAL
    on these generations before, so no existing binary depends on it being refused. The feature bit comes from
    backend_feature_flags() (gpu.rs:388-390, 1550-1552), which only the #[versions(AGX)] GpuManager implements: G13 V12.3/V13.5,
    G14 V13.5, G14X V13.5 (driver.rs:393-406). M3, g15, g16 and g17 override feature_flags() and do not go through Queue::ver, so
    the new acceptance cannot reach a backend that does not advertise it (m3/m3_drm.rs:228).
  • Gating. The scope is the backend implementation (the shared legacy queue code), not a chip, board or firmware list. That is
    acceptable.
  • Moving the SQ_COMPUTE barrier ahead of the SQ_RENDER barrier on the vertex job is harmless, because both must be satisfied.
    render_wait is always consumed in the RENDER arm.
  • Hygiene: one commit with a human Signed-off-by and no agent trailers. No Apple-internal names.

Nits:

  1. The firmware-side "previous fragment work of its physical queue" ordering is argued from in-order stamp completion, not from code
    that adds an explicit frag->frag dependency. Add a sentence to the add_explicit_barrier call-site comment (mod.rs:1312-1315)
    citing the in-order completion, so a later change to fragment workqueue scheduling does not silently break this.
  2. The commit message says "no barrier is added at all". The UAPI says the dependency is "attached to the fragment half". These are
    equivalent only because of the same-queue argument above. Say so in the commit message.

Missing rows:

  • Tested: M1 Pro (G13X) and M2 (G14G).
  • Not tested:
    • G14X (M2 Pro/Max): the kit is posted.
    • G13G (base M1) and G13C/D (M1 Max/Ultra).
    • G13 on V12.3 firmware.
  • The fleet-BTF clean-boot result (0 new kernel errors) is still owed.

@RyanTheTide
RyanTheTide merged commit bb9f8ec into integration/aurora Nov 22, 2026
1 check passed
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Fleet-BTF follow-up at exact reviewed source 24a7cfa3 on M1 Pro (G13X) and base M2 (G14G). Both booted the trial with kernel BTF available. Each host had zero new kernel errors, GPU fault markers, audit AVCs and failed units. The filesystem restriction BPF boot error from the earlier lean kernel did not recur.

On each host, CTS status lists were identical with fragment barriers off and on (833 Pass, 1,569 NotSupported, zero failures). The two concurrent render contexts ran for 324 seconds per host and completed eight runs each with empty error logs. These are the fleet-BTF rechecks. The one-hour runs are recorded in the earlier comment.

G14X is still open. Please use the fleet-BTF image and matching SHA-256 from the draft test kit.

@RyanTheTide
RyanTheTide deleted the prfix/fragment-barriers-r2-20261122 branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants