Skip to content

drm/asahi: g17: enable M5 direct render submission and reduce direct submit/event lock overhead - #2955

Merged
RyanTheTide merged 9 commits into
mainfrom
perf/asahi-g17-m5-direct-render-and-locks
Nov 25, 2026
Merged

RyanTheTide merged 9 commits into
mainfrom
perf/asahi-g17-m5-direct-render-and-locks

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What: Stacked on #2947. Enables steady-state direct TA/3D render submission on M5 (G17S/G17C/G17D): render pairs reserve two slots on M5's shared outer ring under the existing lock order and publish without holding shared.state. It also removes remaining lock, MMIO and workqueue overhead from M5's direct submit and completion paths.

Tested: J714s M5 Pro (G17S B1), Aurora 7.3.0 M5 integration test kernel (build 2) with the 16-plane SLC devicetree, Borealis test build: direct_submissions 5 → 1,014,639, 0 oops, 0 GPU faults, all CRC checks valid; light compute (d=4) 38.02 → 30.63 us (−19.4 % vs #2947), heavy ALU (d=1) 412.54 → 367.65 us (−10.9 %). asahi* KUnit 337/338 pass, 1 skipped, 0 failed.

Risk: two-way · M5 family; the scan_compute_summary() bitmasks, worker_deferred on Shared and the single-hold pure-compute event pass are in shared G17 code and also run on Neo (G17P).

Not yet: Neo (G17P) at this head (its last row predates the main merge), M5 (J813), M5 Max (J716C) and M5 Ultra (J775D) not run.

After the main merge (11-25, main a73023bc5f1f): main's cluster-aware event placement (#2217) keeps M5's event queue unbound, so this PR no longer switches M5 to the per-CPU queue; main's idle-off power-read skip (#2909) replaces this PR's identical one. The unused unlocked Port::note_m5_submission_history() is removed.

Details

Two commits on top of #2947:

  1. drm/asahi: g17: enable direct render submission on M5 (867f16696ba6 at the time of the measurements)

    • Extends Port and OuterCredits (consume_direct_count, reserve_m5_render_locked, write_m5_render_pair, expose_m5_render_pair) so steady-state M5 render pairs reserve two slots on M5's shared outer ring under the existing lock order (render -> m5_outer -> admission/QoS/mailbox), issue HardwareSubmission::advance_pair, expose both slots atomically, and record submission history and the pipe-2 doorbell (pipe 0 on J813) without holding shared.state across preparation or publication.
    • Binds M5 parameter-buffer tokens via acquire_owner_bound() in lend_render(), records the submitting CPU in render_direct(), and extends the asahi_g17_outer_credit KUnit test for two-slot direct render credit consumption.
  2. drm/asahi: g17: reduce M5 direct submit and event lock overhead (d5ab57b48d8a at the time of the measurements; 8a1ec9312034 now)

    • Coalesces M5 compute_direct() outer-ring publication, host-port submission, and submission-history update under one held Port::m5_outer guard (released before ringing the mailbox doorbell).
    • Skips the uncached G17_CORE_POWER MMIO read in Port::note_gpu_activity() when back-to-back work falls within FIRMWARE_IDLE_OFF_MS (while preserving report_busy()).
    • Exposes Port::outer_domain() and Port::reserve_m5_outer() so steady-state prepare_compute() acquires M5 outer-ring availability and credits without locking shared.state.
    • Tracks active, retiring, terminal, witness, replay, and polling slots with bitmasks in scan_compute_summary(), filters retain_render_completions() to matched render QIDs, moves worker_deferred onto Shared, and completes steady-state pure-compute event passes in a single shared.state lock hold (preserving idle_check() timer scheduling).
    • Uses a per-CPU high-priority reclaim-safe workqueue (new_percpu_reclaim) for aurora_g17_events on M5 so enqueue_on(submitter) dispatches directly to the submitting CPU. Dropped in the main merge (see below).

Stacking: builds directly on #2947 (002aeb472e66, e07a4facfb7a at the time). Targets integration/aurora so host-tests CI runs on the full stack; once #2947 merges, only the two commits above remain in this PR with zero conflicts (git merge-tree origin/integration/aurora HEAD verified clean).

Evidence
  • Build and link: kernel build check d5ab57b48d8a06fae13cc23c13fbe8e7b9c84e60 OK (vmlinux, Image, aurora.ko, 1774 modules rebuilt, tree 1592dfe9adb352c53a300310f48907f986fcfbf2).
  • KUnit (asahi*): 337/338 passed, 1 skipped (j713_accepts_all_loaded_images), 0 failed (including extended asahi_g17_outer_credit).
  • checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks across both commits.
  • Live M5 Pro (Apple M5 Pro / J714s / G17S B1, Aurora 7.3.0 M5 integration test kernel build 2 + 16-plane SLC j714s-slc.dtb, Borealis test build, MESA_SHADER_CACHE_DISABLE=1):
    • direct_submissions: 5 -> 1,014,639 (render_direct, compute_direct, scan_compute_summary live in /proc/kallsyms)
    • Stability: 0 kernel oops, 0 GPU faults (FAULTS DELTA=0), all CRC checks valid: true
    • compute.light (queue d=4): 38.02 us (drm/asahi: g17: enable direct compute submission on M5 and coalesce event locks #2947) -> 30.63 us (timed 24.76 us, -19.4%)
    • compute.light (queues d=4): 44.48 us (drm/asahi: g17: enable direct compute submission on M5 and coalesce event locks #2947) -> 33.92 us (-23.7%)
    • compute.heavy kind=alu (queue d=1 / d=4): 367.65 us (-10.9% vs drm/asahi: g17: enable direct compute submission on M5 and coalesce event locks #2947 412.54 us, -15.7% faster than macOS 27.0 Metal 436.30 us) / 263.16 us
    • compute.heavy kind=bw (queue d=1 / d=4): 217.43 GB/s (617.28 us) / 318.36 GB/s (421.59 us)
    • render.light kind=clear (queue d=1 / d=4): 106.47 us / 33.49 us (submit_cpu_us: 9.67 us)
    • render.light kind=tri (queue d=1 / d=4): 129.47 us / 27.42 us
    • render.light (queues d=4 / d=8): 34.06 us / 33.32 us
    • render.postfx (queue d=1 / d=4): 391.24 us / 198.73 us (crc_valid=True)
    • render.bindless_ubo (queue d=1 / d=4): 781.25 us / 554.32 us (crc_valid=True)
    • transfer.ops kind=mipchain (queue d=1 / d=4): 67.73 GB/s (362.84 us) / 128.88 GB/s (190.69 us, crc_valid=True)
    • query (occlusion d=16): 27.27 us (overhead_us: 0.05 us); timestamp d=1 / d=4: 111.56 us / 31.81 us

@RyanTheTide

Copy link
Copy Markdown
Contributor

A note on render_direct(), which this PR touches but does not change: after a successful Pair::publish, port.recovery_state()? != 0 returns EIO. finish_publication treats that as device loss and fails the whole VM. In the same interleaving, the device-mutex render path (check before publish only) and the direct compute path (no check after) return Ok. Could you keep the generation half of that check and either drop the recovery_state half, or treat a group published into a starting recovery the way the other paths do (replayed or cancelled), so that a recovery the client did not cause does not fail its VM? Happy to send it as a separate PR if you'd rather not fold it in here.

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

Changes Requested at d5ab57b48d8a.

The new M5 direct-render path inherits the post-publication recovery behavior raised above. It makes that path reachable on another firmware family. Please keep the generation check and settle a published render pair through the existing recovery path when recovery starts during publication. The two-slot credit test only checks accounting. Add a lifecycle case for recovery crossing publication and show that the pair settles once and an unrelated client keeps its VM. The new direct doorbell also consumes J813_FORMS. Please document the firmware queue contract behind the pipe choice and use that contract for both publishers.

Source review. I used the test evidence attached to this PR.

@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17-m5-direct-render-and-locks branch from d5ab57b to 12fa477 Compare November 23, 2026 10:17
@DjDeveloperr

DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

R2 pushed at 12fa47758d9b (rebased cleanly onto origin/integration/aurora a4b51cdff0a7 + #2947 R2 344d6a96141a, resolving the merge conflict), addressing @RyanTheTide's requested changes:

  1. Mid-publication recovery in render_direct(): Kept the port.generation() != generation epoch check (EIO), and removed EIO on port.recovery_state()? != 0 after a successful pair.publish(). When recovery starts while the pair is lent in the same generation, return_render() returns the published pair before lease drops, and self.shared.queue_events() runs after drop(lease) so the existing recovery pass settles or replays the pair once without calling fail_vm() on an unrelated client.
  2. Lifecycle test for recovery crossing publication: Added registered host test tools/asahi/g17-render-direct-recovery-tests.py exercising production finish_publication() and the extracted render_direct() post-publication path, proving that recovery crossing publication returns the pair before lease drops, preserves an unrelated client's VM, and settles the pair exactly once, while a generation mismatch still fails with EIO (with mutation negative controls).
  3. Shared & documented J813_FORMS doorbell contract: Added render_doorbell_message() in drivers/gpu/drm/asahi/g17/runtime/render.rs documenting the pipe contract (non-M5 pipe 0; M5 Pro/Max/Ultra !J813_FORMS shared compute work ring pipe 2; J813 J813_FORMS mailbox-only common 26A428 pipe 0) and shared it across both locked and direct render publishers.

Verification: python3 -I tools/asahi/run-host-tests.py --only g17 (98/98 pass, including 4/4 for g17-render-direct-recovery-tests) and checkpatch.pl --strict (0 errors). Live G17S B1 hardware re-qualification will follow once the current M5 hardware session finishes.

@DjDeveloperr

DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Hardware qualification update on Apple M5 Pro (G17S B1, aurora-j714s) against head 12fa47758d9bf17042aed2a0b76695971d0d2ad2 (tested in the 7.3.0-m5-cdirect3 integration kernel, aurora.ko build-id e3349bdbf2d1cf365fbb71c10fb9490c8dee8e20, with Mesa origin/aurora-wip efabab3850, MESA_SHADER_CACHE_DISABLE=1):

  • Boot & Stability: Clean boot to desktop (Wi-Fi, Bluetooth, Wayland compositor active); 0 kernel oops, 0 GPU faults across all test runs.
  • Vulkan CTS 1.4.7.1 (sync / barrier / compute / renderpass): 745/831 PASS, 0 failed, 86 NotSupported, 0 GPU faults:
    • dEQP-VK.synchronization.smoke.*: 12/12 PASS
    • dEQP-VK.synchronization.op.single_queue.barrier.* (400-case deterministic stride sample of 1,423): 400/400 PASS
    • dEQP-VK.synchronization.op.multi_queue.* (160-case deterministic stride sample of 12,807): 160/160 PASS
    • dEQP-VK.compute.pipeline.basic.*: 80/81 PASS, 0 failed, 1 NS
    • dEQP-VK.renderpasses.renderpass2.suballocation.attachment.* (80 cases): 66/80 PASS, 0 failed, 14 NS
    • dEQP-VK.renderpasses.renderpass{1,2}.suballocation.simple.* (18 cases): 10/18 PASS, 0 failed, 8 NS
    • dEQP-VK.renderpasses.*.simple.* (80 cases): 17/80 PASS, 0 failed, 63 NS
  • Direct Render / Multi-Queue Observation & Kit Note: Direct render and concurrent compute+render submission loops ran cleanly with 0 faults and GPU reaching P13 (1620 MHz). Note that in the 7.3.0-m5-cdirect3 kit specifically, /sys/bus/platform/devices/2220000000.memory-controller is unbound (j714s.dtb carries only compatible = "apple,t6050-mcc" while the built-in apple-mcc driver only matches apple,t8132-mcc / apple,t8140-mcc / apple,t8142-mcc), and low-depth render/compute round-trip latencies regressed relative to 7.3.0-m5-cdirect2 (+35% at depth 1 render, +16% short-kick GPU duration); latency should be re-measured once apple-mcc binds cleanly on t6050.

DjDeveloperr added a commit that referenced this pull request Nov 24, 2026
Since the event queue became per-CPU on every G17 part, M5's
queue_event_records() aims the event work at the CPU that last published
work with queue_work_on() on a bound pool, so the worker runs on that
very CPU. A thread that publishes directly from its submit ioctl is then
preempted by every completion: the event worker has the higher priority,
and the completion interrupt is either taken on the submitter's CPU (the
AIC cannot be steered) or reaches it by an IPI.

The preemption often lands in the middle of a direct compute
publication, which holds the compute cell's mutex across
Queue::publish(), and the event pass takes that cell next. Its owner is
not running, so the worker cannot spin on it: it sleeps, the submitter
resumes, and its mutex_unlock() wakes the worker, which preempts it
again. Each completion costs the submitter two context switches.

Profiled on M5 Pro, one thread keeping 16 light compute submissions in
flight took 18.0 us per submission, 11.8 us of it in the submit ioctl,
with 93,000 function-call IPIs per second (1.7 per submission), 0.82
context switches of the submitting thread per submission and an IPC of
1.12. __schedule took 8.9% of the cycles, preempt_schedule_irq 7.0% and
mutex_unlock 4.4%, all in the submitter's ioctl after an interrupt. Two
queues signalling each other showed the same profile. With 64 in flight
the scheduler's worker publishes instead, so the event work lands on its
CPU, beside the submitting thread rather than on it: 0.26 context
switches per submission, an IPC of 2.39, 3.5 us in the submit ioctl and
11.4 us per submission.

Make the queue unbound again where the event work follows the submitter,
as it was on M5 before. Aimed at a CPU, an unbound queue takes only that
CPU's affinity pod, the CPUs sharing its L2, and the scheduler wakes the
worker on an idle CPU of the pod. Completion processing stays in the
submitter's cluster and on its die, which is why it follows the
submitter, and a running submitter is left alone: a worker that meets
the cell lock spins on its running owner. Other G17 parts keep the
per-CPU queue, where the event work runs on the CPU that queues it, as
on system_highpri_wq. The queue stays reclaim-safe and high priority.

Shared::new_events_queue() derives the queue's kind from the same
follows_submitter value that Shared keeps, so the two cannot disagree.

The per-CPU queue reached M5 with "drm/asahi: g17: reduce M5 direct
submit and event lock overhead", which this series builds on and which is
still under review (#2955). This change takes back that
part of it on M5 only, and is not tagged as a fix since that commit is not
in any merged tree yet.

Add a host test that compiles the queue choice, the event work's
queuing and the submitter tracking against a model of where the kernel
runs the woken worker: on M5, a completion taken on the submitter's CPU,
on another cluster or on the other die runs in the submitter's pod
without preempting it, and elsewhere it runs on the queuing CPU. Its
mutations include the previous per-CPU queue.

Signed-off-by: Diljit Singh <[email protected]>
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (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) labels Nov 24, 2026
On M5 (G17S/G17C/G17D), compute_direct() returned None unconditionally
because M5 compute shares the per-priority outer work ring with render
and issues host-port gating and submission-history updates. As a result,
every steady-state M5 compute submission fell back to the global device
mutex (shared.state), serializing concurrent compute queues against each
other and against the event worker.

Add a dedicated port-level M5 outer-ring mutex (Port::m5_outer) ordered
after the compute queue cell and render publication lock (device mutex
-> compute cell -> port.render -> port.m5_outer -> port.qos/mailbox),
and expose non-interfering direct credit consumption on OuterCredits
(is_scoped() / consume_direct()) plus direct port views for M5's shared
outer ring and submission-history table.

Guard device-mutex M5 compute and render outer-ring publications with
m5_outer_lock(), reset the cached history geometry on recovery restart,
and allow steady-state M5 compute submissions to publish through
compute_direct() without taking shared.state. Add a KUnit test covering
direct credit consumption alongside OuterScope.

Signed-off-by: Diljit Singh <[email protected]>
Each completion pass in run_runtime_events() / runtime_event_turn()
previously took the global device mutex (shared.state) up to five times
and ran M5 firmware.drain_reports() (trace/statistics rings plus GPU
power register reads) on every completion interrupt, even during tight
compute loops where no render mask was pending.

Coalesce the worker_deferred take and empty-batch restore into the
existing device-mutex holds, avoid dropping and immediately re-acquiring
shared.state around a no-op observe_renders() when render masks are
zero, and throttle M5 post-signal report draining
(drain_post_signal_reports()) to the HOUSEKEEPING_NS (1 ms) cadence
while work remains in flight.

On recovery passes, drain post-signal reports before
service_runtime_recovery() resets firmware rings (matching the
unthrottled post-signal ordering and #2909) without double-draining in
housekeeping. Add host tests (g17-m5-direct-compute-tests.py) covering
mixed render/compute ring wrap, generation-change queued-claim handling,
concurrent direct/scoped credit safety, and post-signal/pre-recovery
report ordering.

Signed-off-by: Diljit Singh <[email protected]>
On M5 (G17S/G17C/G17D), render_direct() returned None unconditionally,
forcing every steady-state TA/3D render pass through the global device
mutex (shared.state) across prepare_render() and publish_render(),
serializing multi-pass graphics and multi-queue render submissions
against each other and the event worker.

Extend Port and OuterCredits so steady-state M5 render pairs can reserve
two slots on M5's shared outer ring under the existing lock order
(render publication lock -> m5_outer -> admission, QoS, mailbox), write
both Compute-master WorkSlots, issue the HardwareSubmission::advance_pair
host-port write, expose the retained pair while consuming two direct
credits, and record submission history and the pipe-2 doorbell (pipe 0
on J813) without holding shared.state across preparation or publication.

Bind M5 PB tokens via acquire_owner_bound() in lend_render(), track the
submitting CPU in render_direct(), and extend the asahi_g17_outer_credit
KUnit test to cover two-slot direct render credit consumption.

Signed-off-by: Diljit Singh <[email protected]>
Eliminate remaining mutex and MMIO overhead on the M5 direct submission
and completion paths:

- Coalesce M5 compute_direct() outer-ring publication, host-port
  submission, and submission-history update under one held Port::m5_outer
  guard (released before ringing the mailbox doorbell), avoiding repeated
  mutex round-trips and keeping m5_outer free during descriptor writes.
- Skip the uncached G17_CORE_POWER MMIO read in Port::note_gpu_activity()
  when back-to-back work falls within FIRMWARE_IDLE_OFF_MS.
- Expose Port::outer_domain() and Port::reserve_m5_outer() so steady-state
  prepare_compute() acquires M5 outer-ring availability and credits
  without locking shared.state.
- Track active, retiring, terminal, witness, replay and polling slots
  with bitmasks in scan_compute_summary() so steady-state completions
  avoid redundant full-registry ComputeCell locks, filter
  retain_render_completions() to matched render QIDs, move
  worker_deferred onto Shared, and complete steady-state pure-compute
  event passes in a single shared.state lock hold while preserving
  idle_check() timer scheduling.
- Use a per-CPU high-priority reclaim-safe workqueue for aurora_g17_events
  on M5 as on other G17 parts so enqueue_on(submitter) dispatches directly
  to the submitting CPU.

Signed-off-by: Diljit Singh <[email protected]>
DjDeveloperr added a commit that referenced this pull request Nov 24, 2026
Since the event queue became per-CPU on every G17 part, M5's
queue_event_records() aims the event work at the CPU that last published
work with queue_work_on() on a bound pool, so the worker runs on that
very CPU. A thread that publishes directly from its submit ioctl is then
preempted by every completion: the event worker has the higher priority,
and the completion interrupt is either taken on the submitter's CPU (the
AIC cannot be steered) or reaches it by an IPI.

The preemption often lands in the middle of a direct compute
publication, which holds the compute cell's mutex across
Queue::publish(), and the event pass takes that cell next. Its owner is
not running, so the worker cannot spin on it: it sleeps, the submitter
resumes, and its mutex_unlock() wakes the worker, which preempts it
again. Each completion costs the submitter two context switches.

Profiled on M5 Pro, one thread keeping 16 light compute submissions in
flight took 18.0 us per submission, 11.8 us of it in the submit ioctl,
with 93,000 function-call IPIs per second (1.7 per submission), 0.82
context switches of the submitting thread per submission and an IPC of
1.12. __schedule took 8.9% of the cycles, preempt_schedule_irq 7.0% and
mutex_unlock 4.4%, all in the submitter's ioctl after an interrupt. Two
queues signalling each other showed the same profile. With 64 in flight
the scheduler's worker publishes instead, so the event work lands on its
CPU, beside the submitting thread rather than on it: 0.26 context
switches per submission, an IPC of 2.39, 3.5 us in the submit ioctl and
11.4 us per submission.

Make the queue unbound again where the event work follows the submitter,
as it was on M5 before. Aimed at a CPU, an unbound queue takes only that
CPU's affinity pod, the CPUs sharing its L2, and the scheduler wakes the
worker on an idle CPU of the pod. Completion processing stays in the
submitter's cluster and on its die, which is why it follows the
submitter, and a running submitter is left alone: a worker that meets
the cell lock spins on its running owner. Other G17 parts keep the
per-CPU queue, where the event work runs on the CPU that queues it, as
on system_highpri_wq. The queue stays reclaim-safe and high priority.

Shared::new_events_queue() derives the queue's kind from the same
follows_submitter value that Shared keeps, so the two cannot disagree.

The per-CPU queue reached M5 with "drm/asahi: g17: reduce M5 direct
submit and event lock overhead", which this series builds on and which is
still under review (#2955). This change takes back that
part of it on M5 only, and is not tagged as a fix since that commit is not
in any merged tree yet.

Add a host test that compiles the queue choice, the event work's
queuing and the submitter tracking against a model of where the kernel
runs the woken worker: on M5, a completion taken on the submitter's CPU,
on another cluster or on the other die runs in the submitter's pod
without preempting it, and elsewhere it runs on the queuing CPU. Its
mutations include the previous per-CPU queue.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17-m5-direct-render-and-locks branch from 12fa477 to 8a1ec93 Compare November 24, 2026 16:52
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 16:52
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 61af6c41: not ready yet

Check Detail
CI at head running running: pr-text / pr-text
Review ok approved by satchlj
Requested changes ok none
Hardware row at head ok comment at 61af6c41
Conflicts ok not computed yet
PR text ok Risk: two-way · M5 family; the scancomputesummary() bitmasks, workerdeferred on Shared and the single-hold pure-compute event pass are in shared G17 code and also run on Neo (G17P).

Areas: area:gpu

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

…5-direct-render-and-locks

Bring in the base PR's merge of main up to 6ec49ac, including its
m5_history_view() update for the relocated M5 submission-history
fields.

Conflict in drivers/gpu/drm/asahi/g17/runtime.rs outer_domain(): main
added the same off-M5 early return this branch has, and kept reading
the domain under the device mutex; this branch's lock-free read
through Port is kept.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merged the updated base (with main at 6ec49ac74755) in, now at 27441635db6f: the conflict in outer_domain() keeps this branch's read through Port (main added the same early return). tools/asahi/run-host-tests.py --only g17: 101/101 pass; kernel build and hardware row at this head still to do.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code blockers.

This PR also carries the fix for the render-observation gap in #2947: render_observation_needed() in the observe_renders() gate. So merge #2947 through this PR rather than on its own (details on #2947).

What I checked
  • The outer_domain() merge resolution against main: it keeps main's non-M5 early return and reads the same Credits availability through the port instead of the device mutex.
  • The direct M5 render path: m5_outer is held from reserve_m5_render_locked through expose_m5_render_pair, the producer is re-checked before exposure, and the unspent claim drops after both locks. submit_m5_work cannot return EAGAIN after accounting (it fails only with ENODEV).
  • The DirectHost guard handling: it re-takes the lock lazily, drops it before the doorbell, and never re-locks while held.
  • scan_compute_summary(): the 128-bit masks fit the 128-entry registry, and the retire filter equals retire()'s own early return. complete_compute() runs last in event::service, so the fast-path summary is current.
  • The worker_deferred move to Shared, and the per-CPU event queue on M5 (#3036 puts it back to unbound).

To merge:

  • a T6050 / J714s (M5 Pro) row built from this head (a batched fleet candidate that contains this head unchanged counts).
  • a T8140 / J700 (Neo, G17P) regression row at this head, because this PR changes shared G17 code that also runs on Neo.
  • CI: the only red check is host-tests, and its three failures (m3-recovery-tests, m3-recovery-tests --mutate, m3-runtime-tests) fail the same way on main itself (0c4e19df, run 45466941208). They are not from this PR. Every G17 host test passes.
  • Base: main has moved past 6ec49ac7 (now 77561654). The new commits touch none of this PR's files and the head merges cleanly, so a branch update needs no new row.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 24, 2026
@DjDeveloperr

DjDeveloperr commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Hardware row at 61af6c41476a (in fleet candidate b7b130a75bab): Apple M5 Pro (T6050 / J714s / G17S B1), pass

Build: fleet candidate wip/m5-wavec-fleet-candidate-20261125 at b7b130a75bab: all eight Wave C PR heads, unchanged, each with main merged in up to a73023bc5f1f. Kernel 7.3.0-m5-wavec2, built natively on the M5 (clang 22.1.8, rustc 1.98.1) with the running default's own config: make -j18 Image modules dtbs exit 0, 0 errors. Default command line (MTE on, SEP writes on). Mesa: the default Borealis 26.3.0-devel (aac82bea8e). Headless only.

Since the 11-24 row (at 27441635db6f): main merged in. main's cluster-aware event placement (#2217) keeps M5's event queue unbound, so this PR no longer makes it per-CPU; main's idle-off power-read skip (#2909) replaces this PR's identical one. New commit 61af6c41476a removes Port::note_m5_submission_history(), unused since this PR (it was yesterday's non-blocking note).

Result:

  • Boot: 7.3.0-m5-wavec2 booted with the default command line in 29 s. Failed units: only tailscaled.service, which also fails on the default boot. 0 SELinux denials (LSMs capability,landlock). dmesg: 0 new kernel errors, and 0 GPU or DART faults, timeouts or recoveries across all runs below. Kernel lines at priority err or worse: 10, none from the GPU, all of kinds the default boot also logs (HID listeners, DCP clock index).
  • gpubench-vk (µs per submit, all ok):
    • compute.light: d1 108.0, d2 60.7, d4 28.2.
    • compute.heavy: d1 373.1 (5,755 GFLOP/s), d4 262.5 (8,182 GFLOP/s).
    • render.light: d1 128.2, d2 71.8, d4 25.8.
    • render.heavy: d1 261.4, d4 125.3.
    • sync.signal: d1 91.0 µs latency.
    • concurrent.cr: d4 overlap 1.02.
  • Vulkan CTS (deqp-runner, --deqp-surface-type=fbo), 0 fail, crash or timeout:
    • synchronization.smoke.*: 12/12.
    • synchronization2.smoke.*: 10/10.
    • compute.pipeline.basic.*: 80 pass, 1 not supported.
    • draw.renderpass.linear_interpolation.*: 12 pass, 9 not supported.
    • synchronization2.op.multi_queue.*, every 8th mustpass case (2,970 cases): 2,147 pass, 823 not supported, the same as the default kernel (7.3.0-m5-cdirect15) in the same slot.
  • GL (zink on Borealis, surfaceless; µs per submit): gpubench-gl render.light d1 143.5, d2 86.0; compute.light d1 109.5, d2 62.7; all ok.
  • Deep sleep: one RTC wake (mem_sleep deep, +28 s, Wi-Fi parked across it): entered and returned in 33.6 s, suspend_stats success 0 → 1, fail 0, same boot. After the wake the GPU is live (vulkaninfo and a dispatch). gpubench-vk compute.light d1 108.5, d4 26.9; render.light d1 128.5, d4 27.4; sync.signal d1 90.2 µs, all ok. 0 new GPU errors. The wake's err-level lines are display (DCP service matching), USB, PCIe and SD-card lines, none from the GPU.
  • GPU capacity after all runs: crashed=0, online=1; firmware_linked_render_graphs leaked=0; drained_render_pairs failures=0 out_of_service=0; 0 quarantined or awaiting-witness compute queues; 0 refusals; sync inputs converted/published 1,525/1,525. Compute channels went from 4 to 8 across compute.light and compute.heavy.
  • Restore: afterwards the M5 runs its slot-start default 7.3.0-m5-cdirect15 again: all 253 boot-partition files are byte-identical, and the kernel, Mesa and packages are unchanged. The trial modules are removed and the GPU is live.

Not run: GLES CTS (the surfaceless glcts harness problem from the 11-24 row; the GL smoke above ran). Neo (G17P) at this head. No other Mac.

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

Copy link
Copy Markdown
Contributor

Neo (J700, T8140 / G17P B1) Wave C non-regression PASS at 9ab6f78 (REQ 46078bfa, covers #2947 d10e12a, #2955 2744163, #2969, #3024, #3036, #3023, #3025, #3035 unchanged; aurora.ko sha 004e299ee9668db4, default cmdline, Stage 2 b17): exercises shared G17 runtime/fence/port/sync_input paths (M5-only direct-submit paths gated off on T8140); gpubench-vk 8/8 OK (render.heavy 720p fill d1 407us/d4 260us, compute.heavy alu d1 1493us/d4 1282us, bw d1 3030us/d4 2804us), gl-smoke 32/32 + gpubench-gl 2/2 OK, dEQP-VK short CTS 30/30 PASS (api.smoke 8/8, sync.smoke 12/12, compute.pipeline.basic 10/10), s2idle 1/1 (10 s) + post-sleep GPU PASS, 0 GPU faults/timeouts/recoveries, 0 failed units, Enforcing + 0 AVC, 0 new GPU kernel errors; restored to saved fleet89.

Bring in main up to a73023b (among others the G17 submit-latency,
compute completion fast path, completion cluster and page-fault blame
work).

Conflict:
- drivers/gpu/drm/asahi/g17/runtime/events.rs: main now drains the
  trace and statistics reports after the pass's completions are
  signalled on every G17 (c56132f, from #2909), where it was M5
  only. This branch throttles that post-signal drain to the
  housekeeping cadence while work is in flight and drains first on a
  recovery pass, through drain_post_signal_reports(), which drained on
  M5 only because only M5 deferred the reports. As every G17 defers
  them now, the helper and its is_m5() check go away and the throttled
  sites call drain_reports() directly, as planned when this branch was
  reconciled with #2909. g17-m5-direct-compute-tests.py checks the
  same order under the new name.

Signed-off-by: Diljit Singh <[email protected]>
…5-direct-render-and-locks

Bring in the base branch, which now carries main up to a73023b.

Conflicts:
- drivers/gpu/drm/asahi/g17/runtime/events.rs: as on the base branch,
  every G17 now drains its reports after signalling, so the M5-only
  drain_post_signal_reports() goes away and the recovery and
  housekeeping sites call drain_reports(). This branch's single-lock
  fast path for pure-compute passes is kept as it was; it skips the
  drain only while housekeeping is not yet due, as the slow path does.
  g17-m5-direct-compute-tests.py follows the new name.
- drivers/gpu/drm/asahi/g17/port.rs: main skips the core power register
  read in note_gpu_activity() within the firmware's idle-off delay
  (99b0b4c), as this branch did; main's version is kept.
- drivers/gpu/drm/asahi/g17/mod.rs: main places the event work in the
  last submitter's cluster on every G17 and drops follows_submitter
  (6ff7967), keeping M5's event queue unbound so the worker runs
  in the submitter's affinity pod. That replaces this branch's switch
  of M5 to the per-CPU queue, so main's queue choice is kept, without
  follows_submitter. The worker's preallocated deferred batch stays on
  Shared, as this branch moved it.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr requested a review from a team as a code owner November 25, 2026 10:27
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
"drm/asahi: g17: reduce M5 direct submit and event lock overhead" moved
every caller of Port::note_m5_submission_history() to the variant that
runs under a held m5_outer, which left the unlocked wrapper unused and
the build warning that it is never used. Remove it and describe the
locked variant on its own. No functional change.

Signed-off-by: Diljit Singh <[email protected]>
DjDeveloperr added a commit that referenced this pull request Nov 25, 2026
…asahi-g17-m5-sibling-compute' into wip/m5-wavec-fleet-candidate-20261125

Bring in the removal of the unused unlocked M5 history update (#2955). No conflicts.

Signed-off-by: Diljit Singh <[email protected]>
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 61af6c41476a

Blockers: none

Checked: Full diff audit of drivers/gpu/drm/asahi/g17/ (M5 direct compute & render submission, Port::m5_outer serialization, reserve_m5_render_locked/write_m5_render_pair/expose_m5_render_pair, DirectHost render & compute direct paths, render_observation_needed() single-lock fast path, and J813_FORMS gating) plus paginated CI and J714s hardware row verification.

Evidence
  • Lock ordering & direct M5 render/compute: Verified device mutex -> compute queue cell -> render -> m5_outer -> admission/QoS/mailbox across port.rs, runtime.rs, runtime/render/direct.rs, and runtime/render/submit.rs. Unspent OuterClaim drops happen outside m5_outer, render, and compute cell locks. render_direct() handles mid-publication recovery via recovery_started + return_render() + queue_events() rather than spuriously failing an unrelated VM.
  • Event coalescing & J813 safety: scan_compute_summary() computes in_flight/replay/polling masks in one pass so pure-compute passes can skip dropping/re-acquiring the device mutex when render_observation_needed() is false; regs.rs short-circuits submit_m5_work/submit_m5_work_held under J813_FORMS and render_doorbell_message() keeps pipe 0 on J813.
  • CI & hardware evidence: Paginated numeric-ID check-runs 19/19 passed (0 active / 0 bad), commit statuses clean, exact-head J714s Apple M5 Pro pass row posted (wip/m5-wavec-fleet-candidate-20261125 at b7b130a75bab); unrun boards are explicitly noted in Not yet:.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 25, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Tested (J700 MacBook Neo, Apple A18 Pro / G17P B1, combined Wave C g17 kernel): PASS (correctness, boot, stability) at exact PR head 61af6c41476ac007883e92b8d42f6a2b8165ca30 in combined tree 7bb607c48427f67f8c3cadb31aad26e017804e0d (origin/main 7c9d9adcda5a + #2947, #2955, #2969, #3024, #3036, #3023, #3025, #3035; kernel 7.3.0-neo-wavec, vmlinuz SHA-256 be56c16aa298..., aurora.ko SHA-256 bef28f236557...).

  • Host tests & boot: 215/215 g17 host tests passed on the combined tree (python3 -I tools/asahi/run-host-tests.py --only g17). Booted cleanly via one-shot grub2-reboot with default 7.3.0-41 kernel cmdline verbatim (wld0 Wi-Fi + eDP-1 display up, SELinux Enforcing, 0 failed units).
  • Vulkan CTS & correctness (7.3.0-neo-wavec, system Mesa git-d4ad4a4dce):
    • Full dEQP-VK.synchronization.timeline_semaphore.*: 2,880/2,880 Pass, 0 failures, 0 recoveries.
    • Focused compute/sync CTS (compute.pipeline.basic.*, synchronization*.smoke.*, synchronization.basic.*, timeline_semaphore subsets): 373 Pass, 7 NotSupported, 0 failures, 0 recoveries (380/380 recorded).
    • Vulkan compute CRCs: 5/5 matched (conv2d gaussian 2d55a14d / bilateral 6cdc0716, edge sobel 27c79e6d / harris 4cebadfc, stereo c62aadf9).
    • Offline Geekbench 6.7.1 Vulkan: 8/8 workloads completed, 0 validation errors.
  • Health & restore: 0 GPU faults, 0 kernel WARNs/BUGs/Oops, 0 AVC denials across boot and the full test window, 0 failed units. Restored cleanly back to 7.3.0-41.fc44.aurora.aarch64 with byte-exact /boot, ESP, /lib/modules, BLS, and grubenv verification.
  • Performance vs shipped 7.3.0-41 (note: compares origin/main + Wave C vs Nov 16 -41, not a main-only control): rt.scene raster d2 improved +19.1% (148.9 → 177.4 fps), copy.bw buf2img d1 -3.7% (1612.9 → 1552.8 µs), compute.heavy alu queues/d2 -2.0%. compute.light queue/d2 was slower vs -41 (35.1 → 47.6 µs, submit CPU 9.1 → 12.0 µs, d1 +3.3%, d4 +5.4%), and a single offline GB6 pass showed Edge +4.7% / Particle +6.2% (unconfirmed single pass); a main-only (7c9d9adc) arm is needed to separate main drift from the 8-PR stack.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 25, 2026
@RyanTheTide
RyanTheTide merged commit 73a6600 into main Nov 25, 2026
22 of 24 checks passed
DjDeveloperr pushed a commit to techmore/linux that referenced this pull request Nov 26, 2026
…is lent

Two physical render pairs bound to one logical context share a single
free-list Lease. With direct render submission enabled on M5 (PR aurora-silicon#2955)
alongside two render pairs per owner, lend_render() prepares the shared
pool lease and releases the device mutex while the lent pair builds and
publishes off-lock.

Previously Lease encoded preparation as a single scalar phase
(LeasePhase::Preparing), so when the event worker retired a completed
render on the sibling pair while the other pair was lent,
Lease::complete_render() saw LeasePhase::Preparing, returned EINVAL, and
stopped the GPU runtime (reproduced immediately by gpubench-vk
render.light depth=8 on J716c).

Track active preparations with a counter (preparing) and whether at
least one render of the generation has published (published):
- Lease::complete_render() admits completions while sibling
  preparations are lent, while still rejecting completions with EINVAL
  if no published render holds references above the reserved
  preparations.
- Add Lease::cancel_prepare() and update Pools::rollback() to undo only
  the rolled-back preparation instead of restoring a pre-prepare
  snapshot, preserving any sibling completions or observed control-ring
  release witnesses that occurred while lent.
- Add Firmware::rollback_render_pool() so a rollback that drops the
  last reference on an already-published generation immediately flushes
  its pending FreeListRelease (or queues events on EAGAIN).
- Add KUnit coverage in freelist.rs and a host mutation test in
  tools/asahi/g17-freelist-lease-direct-tests.py.

Signed-off-by: Erik Bourget <[email protected]>
@RyanTheTide
RyanTheTide deleted the perf/asahi-g17-m5-direct-render-and-locks 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

area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants