Skip to content

drm/asahi: g17: allow inline cross-engine publication behind already-published producers - #3390

Open
DjDeveloperr wants to merge 4 commits into
mainfrom
perf/g17-inline-cross-engine-pub
Open

DjDeveloperr wants to merge 4 commits into
mainfrom
perf/g17-inline-cross-engine-pub

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: Allow G17 inline (try_render_early / try_compute_early) publication of cross-engine consumers behind producers that are already published to firmware, instead of forcing every cross-engine consumer onto the drm_sched worker thread.

  • Track Fences::inline_published and omit adding producer.scheduled to a consumer's host dependencies in Queue::enqueue() when the producer was already inline-published or its scheduled fence is already signaled (fence_status > 0).
  • Keep all producer.completed host waits intact (query-access computes and timestamped writers still wait on the host; orthogonal to drm/asahi: g17: keep timestamp writers behind cross-engine publication #3246).
  • Gate try_compute_early() and try_render_early() on has_host_dependencies() (ignoring pure firmware-ordered producers) and verify check_firmware_producers() before inline publication so an unpublished or failed producer still falls back cleanly.

Tested:

  • Host tests at 6c79a541616a4: python3 tools/asahi/run-host-tests.py --only g17 (237/237 pass, including new tools/asahi/g17-inline-cross-engine-tests.py with 5 mutation traps). scripts/checkpatch.pl --strict 0 errors, 0 checks. Local asahi.config build of drivers/gpu/drm/asahi/aurora.o succeeds cleanly.
  • J714s (Apple M5 Pro, G17S B1) same-slot, same-Mesa-kit (inst-A), same-DTB (origin/main DTB, MCC/SLC disabled) A/B (notsws2-rescan vs slot3-direct adding 6c79a541616a4 + WQ_HIGHPRI drm_sched + direct staged/compute render over origin/main + #3319 + #3330 + #3380):
    • VK CTS (1.4.7.1): 594/594 executed passed, 0 failures (synchronization2.op.single_queue.barrier.*_read_image_compute*: 412/412; occlusion_query.copy_*: 152/159 + 7 NS; multiview.queries.*: 16/16; synchronization.smoke.*: 12/12; concurrent_queries.*: 2/2).
    • gpubench-vk compute.cull_mdi (objs=16384 visible=75, CRC 07f6c861 valid): render inline publications jumped from 0/5,010 (0%) to 5,005/5,006 (99.98%) and compute inline from 2,309/6,820 (33.9%) to 6,813/6,814 (99.99%), gpu_gap_us d2 = 0.375 us.
    • GTA V Enhanced (3024x1964 native, Preset 2 Very High, TAA On, 10 s 24 MHz trace): LATE_PUB(CO->TA) cut -49.1% (43.8 ms -> 22.3 ms), GPU busy 92.86% -> 94.72%, P4 54.27 -> 55.07 FPS, 0 GPU faults, 0 new kernel errors.
    • chainbench_diag: V0_ALL_BAR 960x540 321.5 us -> 266.5 us (-17.1%); V3_NO_BAR_INDEP 60x33 289.0 us -> 269.9 us (-6.6%).

Risk: Two-way door · G17 inline submission eligibility only. Consumers with any external or completed host fence wait stay on drm_sched; check_firmware_producers() guards against racing with an unpublished or errored producer.

Not yet: Isolated single-commit J714s A/B (measured combined in slot3-direct), G17P/G17C/G17D hardware rows, and CI.

…published producers

Previously Queue::enqueue() added every cross-engine firmware producer's
drm_sched scheduled fence to the consumer's dependencies, and both
try_compute_early() and try_render_early() gated on has_dependencies()
(which includes firmware completion fences). As a result, every
cross-engine command fell off the inline publication path onto drm_sched
even when its producer had already been published inline in the same ioctl
or had already signalled scheduled, leaving cross-engine workloads at 0%
inline publication and adding a scheduler wakeup plus firmware cold-start
stall on C->R and R->C transitions.

Track whether Scheduler::enqueue() published a command inline, omit
scheduled dependencies for producers that are already published (inline or
scheduled fence signalled), gate early inline publication on host
dependencies only (has_host_dependencies()), and check
check_firmware_producers() before inline publication so failed producers
propagate unpublished errors cleanly.

Add a compiled host test with mutation traps covering producer
scheduled-wait filtering, host vs firmware early-publication gating, and
failed-producer error propagation.

Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 14:04

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

Fences::inline_published currently copies try_early()'s boolean, but that boolean is also true when the early path handles a terminal failure before any firmware publication. The consumer now uses this field to omit its scheduled-fence wait. Track actual firmware visibility separately from an early attempt that handled an error, or show that the exact fence stored in firmware always exposes the terminal failure before the consumer can skip the wait. Test an early failed producer followed by a cross-engine consumer. Current-head isolated A/B, peer evidence and CI remain open.

…ished

try_early() returns true both when a command was published inline to
firmware and when it handled a terminal unpublished error before hardware
publication. Gate Fences::inline_published on inline && packet.is_published()
so an early unpublished producer failure never causes a cross-engine
consumer to omit its scheduled-fence wait.

Extend g17-inline-cross-engine-tests.py with an early-failed producer
followed by a cross-engine consumer and the copy-try-early-bool mutation.

Signed-off-by: DjDeveloperr <[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.

The inline hint now checks the packet publication state in addition to whether the early path handled the job. The acquire read pairs with the release store for actual publication, so a handled error before publication cannot omit the consumer's scheduled-fence wait. I ran the exact-head host fixture and verified that the copy-try-early-bool mutation fails on the new assertion for that case. Code approved. Keep held for hosted CI and exact isolated hardware A/B plus the affected peer.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, Apple A18 Pro T8140 / G17P B1, second generation) batched kernel verification row at exact head 513edcf43d8f67ec51e30a6dcaa5cfe7f746b5a2: PASS (no regression, 0 failures, 0 GPU faults/recoveries).

  • Combined trial tree (7.3.0-neo-g17perf2v2, commit 5fff9e2700cb):
    • Base: origin/main (ae011990411422923609ae4a41550af2ba25d1b6)
    • Combined PRs tested together in one one-shot boot:
      • #3388 (perf/g17-direct-render-stage-prefixes, head 334dbc6c7e8bfa8d9739ccf8bca45c6baabe6480)
      • #3390 (perf/g17-inline-cross-engine-pub, head 513edcf43d8f67ec51e30a6dcaa5cfe7f746b5a2)
    • All kernel/driver/Rust files merged cleanly onto origin/main with zero conflicts (only adjacent test registrations in tools/asahi/run-host-tests.py were combined).
    • Host tests on the combined tree: python3 tools/asahi/run-host-tests.py --only g17 passed 247/247.
  • Setup & identity:
    • Built with stock 7.3.0-41 config + LOCALVERSION=-neo-g17perf2v2 (0 build errors).
    • Booted via one-shot grub2-reboot only with a 16-minute fallback timer; default entry remained 7.3.0-41.fc44.aurora.aarch64. System Mesa, stock kernel command line.
    • Verified on boot (abb9483f): uname -r = 7.3.0-neo-g17perf2v2, kernel build ID 7c7992d87026bdcf84123ccad4f86d1e331f30ce (MATCH), aurora.ko build ID 36db614ebfd601ee5a14b2bfb798ee1a6656b47c (MATCH).
  • VK CTS (6 jobs, 37,886 cases in 185 s): 31,611 Pass, 6,275 NotSupported, 0 Fail, 0 recoveries (gate rc 0):
    • dEQP-VK.synchronization2.*_read_image_compute*: 5,100 Pass, 5,806 NotSupported, 0 Fail (10,906 total; NotSupported are exclusive-compute-queue / unsupported feature cases).
    • dEQP-VK.synchronization{,2}.* (basic, smoke, single-queue, timeline semaphore, implicit, none_set_reset, internally synchronized objects, plus all synchronization2.*_read_image_compute*): 31,242 Pass, 6,178 NotSupported, 0 Fail (37,420 total).
    • dEQP-VK.compute.pipeline.basic.*: 79 Pass, 2 NotSupported, 0 Fail.
    • dEQP-VK.api.command_buffers.*: 65 Pass, 66 NotSupported, 0 Fail.
    • dEQP-VK.renderpass{,2}.suballocation.subpass_dependencies.*: 73 Pass, 22 NotSupported, 0 Fail.
    • dEQP-VK.query_pool.occlusion_query.copy_*: 152 Pass, 7 NotSupported, 0 Fail.
  • gpubench-vk (fdf4dd6, system Mesa, 17/17 rows ok, CRCs matched stock 7.3.0-41 pre-boot baseline):
    • render.deferred (tile msaa=4 1080p d1/d2): 5e4130ce (match), GPU 10596.9 / 10525.5 µs (stock 10831.2 / 10653.7 µs).
    • render.postfx (msaa=4 1080p d1/d2): 668d6f0a (match), us/sub 773.2 / 572.5 µs (stock 781.2 / 625.0 µs).
    • render.pass_chain (all_bar d1/d4): 93411763 (match), us/sub 550.5 / 371.3 µs (stock 513.7 / 449.1 µs).
    • render.pass_chain (oq_bar d1/d4): 93411763 (match), us/sub 761.4 / 1200.0 µs (stock 785.3 / 857.1 µs).
    • render.light d1/d8: ok, us/sub 132.6 / 31.1 µs (stock 125.3 / 28.8 µs).
    • compute.heavy (alu d1/d4): ok, us/sub 1351.4 / 1181.1 µs (stock 1382.5 / 1181.1 µs).
    • compute.light d1/d8: ok, us/sub 107.4 / 17.0 µs (stock 102.9 / 15.9 µs).
    • compute.cull_mdi d1/d4: 57276de2 (match), us/sub 9677.4 / 1851.9 µs (stock 5357.1 / 1886.8 µs).
    • sync.signal (compute.light d1): ok, latency p5/med/p95 151.0 / 154.9 / 164.2 µs (stock 140.8 / 145.6 / 152.7 µs).
    • Note: stock 7.3.0-41 predates origin/main (ae01199041142), so this row serves as a combined correctness/CRC/stability verification rather than a merge-base perf A/B.
  • Kernel health & restore:
    • 0 GPU faults/recoveries, 0 MMU faults, 0 WARN/BUG/Oops/lockup/RCU-stall/timeout lines, 0 new kernel error lines, 0 AVC denials, 0 failed units, 0 core dumps.
    • Restored cleanly to stock 7.3.0-41.fc44.aurora.aarch64 (boot 278c2620, PMU f701/f702 = 30 00); trial /boot, /lib/modules, BLS entry, and fallback timer removed, stock.sh POST vs PRE diff = 0 bytes.

@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 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 85ecbc6d: not ready yet

Check Detail
CI at head no failing: apple-build, host-tests, pr-text / pr-text, KUnit ane-boot, KUnit ane-pm, KUnit dcp-fabric
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head no no line with the head SHA 85ecbc6d, a Mac and a result in the PR body or a comment
Conflicts no merge conflicts with main: merge it in (no force push)
PR text ok Risk: two-way · G17 inline submission eligibility only. Consumers with any external or completed host fence wait stay on drmsched; checkfirmwareproducers() guards against racing with an unpublished or errored producer.

Areas: area:gpu

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

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 27, 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: HOLD for hosted CI and final-stack hardware qualification.

Checked: The inline submission file and its fixture retain their reviewed blobs. The changes in the overlapping files are the incoming priority workqueue setup, sync-vector type and teardown rescan stop. The merged host runner keeps the inline fixture and its producer-state controls. The prior combined J700 pass covers the older heads. Please keep the isolated comparison and peer evidence on the landing stack.

Resolve against main's timestamp-free publication chaining (#3319): carry both the inline_published flag and timestamp_waits in Fences, and both firmware_published and inherited_timestamp_waits through EnqueueOrdering. Main's new firmware wait for a timestamp-free producer now records its inline_published flag too, so the two vectors stay paired in the zip in Queue::enqueue().

Signed-off-by: DjDeveloperr <[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 85ecbc6d51e6

Blockers:

  • Hosted CI at 85ecbc6d51e6 is still queued (21 jobs queued: apple-build, host-tests, pr-text, readiness, and KUnit suites including asahi_g17_cross_engine_timestamps) — wait for all checks to complete green.
  • Exact-head G17 hardware verification row at 85ecbc6d51e6 after integrating #3319's timestamp-free publication chaining (existing combined J700 pass covers pre-merge 513edcf4).

Checked:

  • Audited the full 6-file diff (+416/-7, MERGEABLE against main) and the non-trivial merge resolution against #3319 in drivers/gpu/drm/asahi/g17/queue/mod.rs:
    • Verified every firmware.push() site in EnqueueOrdering::build() (both the timestamp-free producer branch and the non-wait branch) pushes a matching entry.inline_published() into firmware_published, keeping ordering_firmware_waits and ordering_firmware_published strictly paired for the .zip() loop in Queue::enqueue().
    • Verified Fences::inline_published (inline && packet.is_published()), Packet::has_host_dependencies(), try_compute_early() / try_render_early() check_firmware_producers() error handling, and tools/asahi/run-host-tests.py (g17-inline-cross-engine-tests.py + all 6 mutations) remain intact.
Evidence
  • Head: 85ecbc6d51e6c589d2f072ad5be415494b649d95 (base main, MERGEABLE).
  • Status checks at review time: 21 queued, 3 skipped, 0 failed.

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

Reviewed the conflict-pass merge commit 85ecbc6 only: firmware-wait flag pairing checked: every firmware.push has a matching firmware_published.push in both branches, zipped with ordering_firmware_published; inline_published defaults to false on the trait. The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Dec 1, 2026
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 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 85ecbc6d51e6

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: - Audited the full 6-file diff (+416/-7, MERGEABLE against main) and the non-trivial merge resolution against #3319 in drivers/gpu/drm/asahi/g17/queue/mod.rs:

  • Verified every firmware.push() site in EnqueueOrdering::build() (both the timestamp-free producer branch and the non-wait branch) pushes a matching entry.inline_published() into firmware_published, keeping ordering_firmware_waits and ordering_firmware_published strictly paired for the .zip() loop in Queue::enqueue().
  • Verified Fences::inline_published (inline && packet.is_published()), Packet::has_host_dependencies(), try_compute_early() / try_render_early() check_firmware_producers() error handling, and tools/asahi/run-host-tests.py (g17-inline-cross-engine-tests.py + all 6 mutations) remain intact.

Follow-ups (not blocking): queued CI; exact-head G17 row after #3319 merge

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 1, 2026
@erikwb

erikwb commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

We carry this PR in our J716c (M5 Max, T6050) daily kernel.

Without inline cross-engine publication behind already-published firmware producers, cross-engine render/compute consumers were forced onto the drm_sched worker thread instead of publishing directly from the submit path, adding avoidable submission latency on mixed render/compute workloads.

Running smoothly on our J716c daily kernel with no GPU faults or regressions.

This branch has not been deployed

No deployments
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) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants