Skip to content

drm/asahi: g17: reduce M5 multi-queue cluster pinning and outer-lock trips - #2969

Merged
DjDeveloperr merged 13 commits into
mainfrom
perf/asahi-g17-m5-multiqueue-contention
Nov 25, 2026
Merged

DjDeveloperr merged 13 commits into
mainfrom
perf/asahi-g17-m5-multiqueue-contention

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What: Stacked on #2947 and #2955. On single-die M5, every drm_sched submit workqueue was pinned to the creating CPU's cluster, so queues created on one thread contended when submitted from worker threads across clusters; cluster pinning now applies only when num_dies > 1. compute_direct() also reuses the M5 OuterClaim already held in self.outer_compute instead of taking a second m5_outer reservation, which double-booked outer-ring slots and caused an unused-claim wakeup on every direct compute submission.

Tested: J714s M5 Pro (G17S B1) in the combined M5 integration kernel: 0 oops, 0 GPU faults, Vulkan CTS 1.4.7.1 sync/barrier/compute/renderpass subset 745/831 pass, 0 fail (86 not supported); multi-queue light render 35.3 → 31.0 us (1.139x), high-draw submission 1428.6 → 1262.6 us (1.131x). Host tests --only g17 104/104 pass.

Risk: two-way · M5 family (single-die M5 leaves its scheduler queues unrestricted; multi-die M5 Ultra and the other G17 parts keep main's creator-cluster restriction).

Not yet: Neo (G17P) at this head (the main merge changed shared G17 code under it), the multi-die path on M5 Ultra (J775D), and M5 Max (J716C) and M5 (J813), not run.

After the main merge (11-25, main a73023bc5f1f): main restricts every G17's scheduler queues to their creator's cluster (#2217); pin_scheduler_cluster is now !m5 || id.num_dies > 1, so only a single-die M5 leaves them unrestricted.

Details

Stacking: stacked cleanly on #2947 (972395780ba7) and #2955 (8a1ec9312034). The sole new commit on top of #2955 is drm/asahi: g17: reduce M5 multi-queue cluster pinning and outer-lock trips.

  1. Restrict scheduler cluster pinning to multi-die M5 (num_dies > 1): creator_cluster_scheduling() previously pinned every drm_sched ordered submit workqueue on M5 to Cpumask::cluster_of(CpuId::current()) at queue creation time. That pinning avoids cross-die migration on multi-die M5 Ultra (num_dies > 1), but on single-die M5 parts (num_dies == 1) queues created on one thread all get pinned to a single CPU cluster and contend when submitted concurrently from worker threads across clusters. Keep event-work submitter tracking (follows_submitter) on all M5 parts and restrict scheduler clusters only when id.num_dies > 1.
  2. Reuse the held self.outer_compute claim in compute_direct(): compute_direct() previously ignored the M5 OuterClaim already reserved in self.outer_compute during prepare_compute() and called port.reserve_m5_compute(), causing a redundant Port::m5_outer lock round-trip, double-booked outer-ring slots, and an unused-claim availability wakeup on every direct compute submission. Reuse self.outer_compute when its remaining count and priority match before falling back to port.reserve_m5_compute().
Evidence
  • Host tests: full python3 -I tools/asahi/run-host-tests.py --only g17 suite passed (104/104 on the combined integration tree).
  • Style: scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks on the new commit.
  • Hardware (Apple M5 Pro, J714s, G17S B1): booted and verified in the combined M5 integration kernel (0 kernel oops, 0 GPU faults); Vulkan CTS 1.4.7.1 sync/barrier/compute/renderpass subset passed 745/831 (0 failed, 86 NotSupported); improved multi-queue light render latency (35.3 -> 31.0 us, 1.139x) and high-draw submission latency (1428.6 -> 1262.6 us, 1.131x).

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

Formal Adversarial Pre-PR Review (§1–§6) — COMMENT (Changes Needed)

Reviewed head: 55b13a32e1f229270a749bdc2c5ceade9fc84c19
Live CI: host-tests — COMPLETED / SUCCESS

Stack & Merge-Train Dependency Check

  • This PR contains 5 commits against integration/aurora: commits 1–2 (ad1880978a1e, 344d6a96141a) belong to still-open #2947, commits 3–4 (f84c1d2939a9, 12fa47758d9b) belong to still-open #2955 (which still awaits re-review after R1 Changes Requested), and only commit 5 (55b13a32e1f2) is new. It cannot land in MERGETRAIN-LINUX4 ahead of #2947 and #2955 without pulling in unapproved commits.
  • Pairwise git merge-tree shows initdata.rs and queue/compute.rs auto-merge cleanly with #2967 and #2968, while tools/asahi/run-host-tests.py conflicts with both #2967 and #2968.

Technical Audit & Blockers

  1. Blocker — Locking / ring-credit overcommit race in the stacked M5 outer-credit path (claim_outer / OuterScope vs Port::m5_outer):

    • Credits::reserve() (drivers/gpu/drm/asahi/g17/initdata/outer_credit.rs:66-80) documents "Reserve under the outer-ring lock" and performs a non-atomic check-then-add (if self.capacity(priority, cursors)? < count { return Err(EBUSY); } counter.fetch_add(count, Ordering::AcqRel);).
    • However, Backend::claim_outer() (drivers/gpu/drm/asahi/g17/runtime.rs:2340) calls firmware.init.reserve_outer() while holding shared.state + self.outer_{compute,render} without holding firmware.port.m5_outer_lock(), while direct submitters (claim_compute_outer_direct() -> port.reserve_m5_outer(), compute_direct() -> port.reserve_m5_compute(), and render_direct() -> port.reserve_m5_render_locked()) call Credits::reserve() under port.m5_outer without holding shared.state.
    • Race 1 (concurrent reserve() overcommit): Under multi-queue load, claim_outer() and port.reserve_m5_outer() / port.reserve_m5_render_locked() can both read cursors, both observe free(cursors) - reserved >= count, and both fetch_add(count), overcommitting the physical ring. Worse, if claim_outer() samples cursors before a direct publish advances producer and decrements reserved via consume_direct(), claim_outer() sees stale free(cursors) minus the already-decremented reserved and reserves a slot when 0 physical slots remain — causing publish_m5_compute_locked() to return Err(EIO) (next == first || next == second) and finish_publication() to kill the client VM (fail_vm(EIO)).
    • Race 2 (OuterScope slot theft): Credits::scope() (outer_credit.rs:102-108) sets scoped = true and decrements reserved[prio] by claim.remaining under shared.state without port.m5_outer. A direct submitter in Credits::reserve() that passed if self.scoped.load(Ordering::Acquire) (line 72) just before scope() swaps scoped = true will then run self.capacity() (line 77) against the reduced reserved[prio] before the scoped publisher advances producer, stealing the OuterScope's lent slots.
    • Fix: Hold firmware.port.m5_outer_lock() around firmware.init.reserve_outer() in claim_outer() (valid lock order: shared.state -> outer_{compute,render} -> port.m5_outer, matching claim_compute_outer_direct() and publish_claimed()), and serialize Credits::scope() entry / OuterScope::drop() transitions with port.m5_outer (or move Credits::reserve / scope under one shared lock).
  2. Issue in commit 55b13a32e1f2 (compute_direct() drops pre-reserved self.outer_compute on None fallback):

    • In Backend::compute_direct() (drivers/gpu/drm/asahi/g17/runtime.rs:2200-2244), self.outer_compute is moved out via held.take() before acquiring cell.lock() and checking queue.installed(), queue.spared_pending(), queue.pool_fits(), queue.pending_switch_from(), queue.matches(), and lease.is_current().
    • If any of those checks fail and compute_direct() returns None (falling back to compute_packet()'s device-mutex loop), drop(m5_outer) immediately returns the credit and fires available.notify(), forcing compute_packet() to re-contend from scratch in claim_outer() under outer-ring saturation (extra wakeup + fairness/starvation loss). Restoring an unspent m5_outer back into self.outer_compute on None fallback (or checking readiness before discarding it) avoids dropping the reservation while Backend::publish() still guarantees release_outer() on exit.
    • Note on lock order / drop safety: m5_outer drops after cell lock (good — no deadlock with cell), and OuterClaim::drop notifies Availability fences outside m5_outer / outer_compute / shared.state. Note also that render_direct() (runtime/render/direct.rs:406) still reserves directly without reusing self.outer_render (non-blocking follow-up).
  3. Zero test coverage for the new commit (55b13a32e1f2):

    • Neither OuterClaim::priority() / self.outer_compute reuse-and-fallback behavior nor pin_scheduler_cluster (m5 && id.num_dies > 1 across single-die vs multi-die parts) has a unit or host test. Add host/KUnit tests covering both changes (plus a concurrent claim_outer vs reserve_m5_outer / OuterScope contention test once the race above is fixed).
  4. Cluster pinning audit (pin_scheduler_cluster: m5 && id.num_dies > 1):

    • Correctly uses probed hardware topology (id.num_dies, read from ID_COUNTS_1[19:16]): unpins drm_sched on single-die M5 base (J813), M5 Pro (J714), and M5 Max (J716C) while preserving creator-cluster pinning on dual-die M5 Ultra (J775D, num_dies == 2) and leaving non-M5 G17 (M4 Pro/Max, A18 Pro) unchanged. Keeps follows_submitter: m5 intact for aurora_g17_events.
    • Minor §1 note: since all current non-M5 G17 parts have num_dies == 1, id.num_dies > 1 alone (without m5 &&) would be purely topology-driven and automatically cover any future multi-die G17 part.

Checklist Audit (§1–§6)

  • §1 No model gating: Pass (uses probed id.num_dies > 1 topology; minor note above on dropping redundant m5 &&). Note multi-die J775D and single-die J716C/J813 hardware validation status.
  • §2 Production-ready, no hacks: Changes Needed (outer-credit locking race + fallback claim drop).
  • §3 Safety: Changes Needed (outer-credit race can trigger spurious EIO / fail_vm under multi-queue saturation).
  • §4 Clean-room & attribution: Pass. All 5 commits carry human author/committer (Diljit Singh <[email protected]>) and human Signed-off-by: only, zero AI trailers in commits.
  • §5 Evidence (Changes Needed):
    • Missing exact kernel version / build-id, Mesa build/commit, and baseline vs candidate SHAs for the cited multi-queue A/B (35.3 -> 31.0 us, 1428.6 -> 1262.6 us).
    • Missing single-queue latency A/B on J714 (confirming unpinning drm_sched on single-die M5 Pro does not regress single-queue depth-1/depth-4 latency across P/E clusters).
    • Missing the §5 regression run tuple (0 SELinux denials, 0 failed units, 0 new kernel errors).
    • Note: in #2955's own latest HW qualification comment, the 7.3.0-m5-cdirect3 kit had apple-mcc unbound (+35% depth-1 render latency vs cdirect2); clarify which kernel/DTB kit produced #2969's A/B numbers.
  • §6 Naming: Pass.

Verdict

Changes Needed — do not include in MERGETRAIN-LINUX4. Blockers: (1) depends on unmerged #2947 + #2955, (2) fix the claim_outer() / OuterScope vs Port::m5_outer credit-reservation race, (3) avoid discarding a pre-reserved self.outer_compute claim on compute_direct() None fallback, (4) add host/KUnit tests for 55b13a32e1f2 and the fixed race, and (5) complete §5 A/B + regression evidence.

@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17-m5-multiqueue-contention branch from 55b13a3 to 9275bf8 Compare November 23, 2026 17:02
@DjDeveloperr

DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated to R2 (9275bf84e314952fda11413f93c90044b33a7f41) addressing both review blockers and adding host test coverage:

Code fixes

  1. Serialize all M5 Credits mutations under Port::m5_outer:
    • Backend::claim_outer() (drivers/gpu/drm/asahi/g17/runtime.rs) now holds firmware.port.m5_outer_lock() around firmware.init.reserve_outer(), matching Port::reserve_m5_outer() and Port::reserve_m5_render_locked() so Credits::reserved[] capacity checks and updates cannot interleave.
    • Added Port::outer_scope() / PortOuterScope<'a> (drivers/gpu/drm/asahi/g17/port.rs, holding Arc<Port>) and wired both Backend::publish_claimed() (runtime.rs) and runtime/render/prepare.rs through it so both Credits::scope() entry and OuterScope::drop() execute under Port::m5_outer (preserving lock order device mutex -> outer_{compute,render} -> compute queue cell -> port.render -> port.m5_outer without borrowing firmware across publish_compute / publish_render).
  2. Preserve pre-reserved self.outer_compute on compute_direct() fallback:
    • Backend::compute_direct() (runtime.rs) now tracks whether m5_outer came from self.outer_compute (from_held). Whenever compute_direct() returns None (early bailout on cell.lock() / readiness checks or EAGAIN/EBUSY with !packet.is_published()), it restores the unspent claim back into self.outer_compute after cell.lock() drops (preserving lock order and avoiding spurious availability wakeups or lost pre-reserved capacity on the device-mutex fallback path).
  3. Host test coverage (tools/asahi/g17-m5-multiqueue-contention-tests.py, registered in tools/asahi/run-host-tests.py after g17-m5-direct-compute-tests.py to avoid conflicts with #2967):
    • Compiles the real Credits / OuterClaim / OuterScope implementation on host and runs a tight-ring (4-free-slot) multi-threaded contention stress test across direct compute publishers and device-mutex claim_outer / PortOuterScope publishers (verifying 0 overcommits, 0 EIO, and exact credit accounting), plus fallback preservation and 6 mutation negative controls (unlocked-claim-outer, raw-compute-scope, raw-render-scope, unlocked-scope-drop, drop-direct-claim-on-fallback, pin-single-die).

Stack & verification

  • Stack dependency: This PR remains stacked cleanly on #2947 (344d6a96141a0) + #2955 (12fa47758d9bf), since both the direct compute OuterClaim path and Port::m5_outer are introduced there.
  • CI (9275bf84e314952fda11413f93c90044b33a7f41): Host tests run 45223162972 (SUCCESS, CLEAN / MERGEABLE).
  • J714s (M5 Pro, T6050) baseline regression tuple (7.3.0-m5-cdirect5-safe): 14,892 / 14,910 VK+GL CTS PASS (0 regressions), 0 GPU faults, 0 kernel warnings, 0 failed systemd units.

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]>
…trips

Two sources of unnecessary host contention on single-die M5 multi-queue
workloads, plus M5 outer-credit locking fixes exposed by concurrent direct
compute and device-mutex publishers:

1. creator_cluster_scheduling() restricted every drm_sched ordered
   submit workqueue on M5 to Cpumask::cluster_of(CpuId::current()) at
   queue creation time. That pinning prevents cross-die migration on
   multi-die M5 Ultra (num_dies > 1), but on single-die M5 parts
   (num_dies == 1) queues created on one main thread all get pinned to
   a single CPU cluster and contend when submitted from worker threads
   across clusters. Keep event-work submitter tracking on all M5 parts
   and restrict scheduler clusters only when num_dies > 1.
2. compute_direct() previously ignored the M5 OuterClaim already
   reserved in self.outer_compute during prepare_compute() and called
   port.reserve_m5_compute(), causing a redundant Port::m5_outer lock
   round-trip, double-booked outer-ring slots, and an unused-claim
   availability wakeup on every direct compute submission. Reuse the
   held self.outer_compute claim when its remaining count and priority
   match before falling back to port.reserve_m5_compute(), and restore
   any unspent held claim back into self.outer_compute outside
   cell.lock() when compute_direct() falls back to the device-mutex
   path so pre-reserved credits are preserved without spurious wakeups.
3. Serialize device-mutex OuterClaim reservations (Backend::claim_outer)
   and OuterScope entry/Drop transitions (Port::outer_scope /
   PortOuterScope) under Port::m5_outer so Credits::reserved[] and
   Credits::scoped never race against concurrent direct M5 reservations
   (Port::reserve_m5_outer / Port::reserve_m5_render_locked).

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17-m5-multiqueue-contention branch from 9275bf8 to d13f235 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 removed the merge-conflict Conflicts with the base branch (bot) label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 8926e891: ready to merge

Check Detail
CI at head ok 19 checks passed
Review ok review verdict MERGE at 8926e891; no GitHub approval yet, so approve it or merge through the bypass (--admin)
Requested changes ok none
Hardware row at head ok comment at 8926e891
Conflicts ok none
PR text ok Risk: two-way · M5 family (single-die M5 leaves its scheduler queues unrestricted; multi-die M5 Ultra and the other G17 parts keep main's creator-cluster restriction).

Areas: area:gpu
Merge: gh pr merge 2969 --merge (Owners and Core through the bypass: add --admin).

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

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Rebased onto main (2ba145b5e335, previously a4b51cdff0a7): 9275bf84e314 → d13f2358d742.

Conflicts were all in drm/asahi: g17: enable direct compute submission on M5, from the dead-code removal merged in #2433:

  • g17/initdata/m5.rs: main removed the unused m5_policy_telemetry_word(). That removal is kept, and only this commit's new m5_history_view() is added.
  • g17/runtime.rs publish_compute_raw(): main reworded the comment on the M5 outer-ring reservation (InitData::publish_work_at). This commit moves that block below the queue checks, so the old copy is dropped as before.

The stack is unchanged: on #2955 (8a1ec9312034). Every other commit is unchanged (git range-diff: patch-identical).

Host tests: tools/asahi/run-host-tests.py --only g17 105/105 pass. scripts/checkpatch.pl --strict: 0 errors, and the same warnings as before the rebase. The full suite runs in the Host tests check.

@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
Bring in main up to 6ec49ac (the T6050 GPU, fan and display work
and the later G17 effort, command-port and lock changes).

Conflicts:
- drivers/gpu/drm/asahi/g17/initdata/m5.rs: main added
  set_m5_policy_layouts() where this branch adds m5_history_view();
  both are kept. main also reads the M5 submission-history fields
  through the loaded firmware build's status-config relocation instead
  of fixed 26A428 offsets, so m5_history_view() now takes its
  generation, geometry and slot addresses from the same relocation as
  note_m5_submission_history().
- tools/asahi/run-host-tests.py: both sides register a new g17 test;
  both are kept.

Signed-off-by: Diljit Singh <[email protected]>
…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]>
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]>
…ahi-g17-m5-multiqueue-contention

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

Conflicts:
- drivers/gpu/drm/asahi/g17/mod.rs, runtime/backend.rs: main restricts
  every G17's scheduler queues to their creator's cluster and drops
  follows_submitter (6ff7967). This branch restricts them on M5
  only where it has more than one die, so the queues of a single-die M5
  are not all tied to the cluster of the thread that created them.
  Both are kept: pin_scheduler_cluster is now !m5 || id.num_dies > 1,
  so every other G17 keeps main's restriction and a single-die M5
  keeps this branch's unrestricted queues. Without a cpu-map a queue
  stays unrestricted anyway, as on main.
  g17-m5-multiqueue-contention-tests.py checks the new expression, and
  its pin-single-die mutation now pins every queue.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr requested a review from a team as a code owner November 25, 2026 10:28
@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]>
…ahi-g17-m5-multiqueue-contention

Bring in the removal of the unused unlocked M5 history update from the base branch. 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 previously approved these changes 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 8926e891cfb1

Blockers: none

Checked: Full diff audit of drivers/gpu/drm/asahi/g17/ (shared #2947/#2955 M5 direct compute/render base plus #2969 incremental changes: pin_scheduler_cluster gating for single-die M5, PortOuterScope serialization under Port::m5_outer, Backend::compute_direct() outer_compute claim reuse and off-lock drop, and prepare_compute()/render/prepare.rs outer-scope lock ordering) plus paginated CI and J714s hardware row verification.

Evidence
  • Lock order & concurrency: Verified device mutex -> outer_{compute,render} -> compute queue cell -> render -> m5_outer -> admission/QoS/mailbox across port.rs, runtime.rs, runtime/render/direct.rs, runtime/render/prepare.rs, and runtime/render/submit.rs. PortOuterScope serializes OuterScope entry and drop under Port::m5_outer, closing any race with direct M5 outer-ring publishers. Unspent OuterClaim drops occur outside cell, render, and m5_outer locks so availability-fence wakeups never nest inside those locks.
  • Claim reuse & J813 safety: Backend::compute_direct() reuses held outer_compute claims only when remaining() != 0 && priority() == priority and restores unspent from_held claims on fallback while dropping excess outside locks. regs.rs submit_m5_work/submit_m5_work_held short-circuit cleanly under J813_FORMS, and render_doorbell_message() preserves pipe 0 for J813 vs pipe 2 for M5 Pro/Max/Ultra.
  • 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 (Neo G17P, M5 Max, M5 Ultra, M5 J813) 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 8926e891cfb1ebffe6f7eb0f0f49a03cf25c6be3 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 added ready-to-merge Meets the merge policy: merge it (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 25, 2026
@DjDeveloperr
DjDeveloperr dismissed satchlj’s stale review November 25, 2026 19:04

The merge-base changed after approval.

RyanTheTide
RyanTheTide previously approved these changes Nov 25, 2026

@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: MERGE at 8926e891cfb1.

Blockers: None.

Checked: All nine incremental files above the now-merged #2955, the current merge preview, lock and reservation lifetimes, the topology-based scheduler selection, the exact hosted checks, and the two hardware rows.

Evidence
  • The submit affinity decision uses the existing shared M5 work-ring profile and the number of dies reported by the hardware. The alternate submission protocol keeps its current placement. No new model identifier or run-time option is introduced.
  • The outer-ring scope takes the port lock at entry and release. The direct submit path checks priority and remaining credit before taking a prepared claim. A retry restores remaining credit only after the queue-cell lock is released. An unused competing claim is dropped after releasing the reservation lock.
  • The nine-file merge delta applies without a conflict and each changed file matches the reviewed head. The earlier duplicate workflow cancellations have been replaced by successful runs.
  • The exact J714s target row records GPU work and a wake with no new GPU errors. The exact combined J700 check recorded 2,880 timeline-semaphore passes, 373 supported compute/sync passes, five matching CRCs and zero GPU faults. The older-kernel performance comparison still needs its separate current-main control before attributing a timing change.

@RyanTheTide
RyanTheTide requested a review from satchlj November 25, 2026 19:07
@DjDeveloperr
DjDeveloperr dismissed RyanTheTide’s stale review November 25, 2026 19:10

The merge-base changed after approval.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Nov 25, 2026
RyanTheTide
RyanTheTide previously approved these changes Nov 25, 2026

@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: MERGE at 8926e891cfb1.

Blockers: None.

Checked: Reconfirmed the nine incremental GPU and host-test files after the earlier render PR merged. The preview on current main 9e77a6ca856b has the exact reviewed contents for all nine. The subsequent release, SMP and storage changes touch other files. The J714s and J700 rows cover the same unmodified head. All 25 current checks pass.

Evidence

The merge base is now 61af6c41476a and the preview tree is 91467385f0a246a92fd24ddbf68460c3366e3ba1. The earlier full review traces the queue, credit, and ring lifetime checks. J714s M5 Pro and J700 Neo both passed with no GPU errors.

@DjDeveloperr
DjDeveloperr dismissed RyanTheTide’s stale review November 25, 2026 19:39

The merge-base changed after approval.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Could you merge current main into this branch and push normally? GitHub dismissed the exact-head approval again as the merge base changed. The local merge onto 9e77a6ca856b needs no conflict resolution and preserves all nine files in this change byte for byte. That gives us a way to carry the J714s and J700 rows on unchanged runtime code. Please call out any changed file if your base has moved further.

satchlj
satchlj previously approved these changes 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 8926e891cfb1

Blockers: none

Checked:

  • Clean-room diff with no Apple copyrighted material, decompiled listings, or copied firmware/tuning data.
  • No hardcoded model, board, or firmware gates and no new module or command-line parameters; scheduler cluster pinning uses the existing M5 profile and hardware die count (!m5 || id.num_dies > 1).
  • No hardcoded hardware safety limits; safety and hardware values come from machine descriptors and runtime state.
  • Clean human Signed-off-by: DCO on every commit and zero AI attribution across commits and PR text.
  • Exact-head hardware rows pass on both J714s (M5 Pro) and J700 (Neo) with clean merge preview on main, and all paginated CI checks are green.
Evidence
  • Incremental diff audit above merged #2955 (9 files):
    • drivers/gpu/drm/asahi/g17/port.rs, initdata.rs, initdata/outer_credit.rs, runtime.rs, runtime/render/prepare.rs: PortOuterScope serializes OuterScope entry and drop under Port::m5_outer, prepare_compute() takes m5_outer_lock() around reserve_outer(), and lock order remains device mutex -> outer_{compute,render} -> compute queue cell -> render -> m5_outer -> admission/QoS/mailbox.
    • Backend::compute_direct() reuses a held outer_compute claim only when remaining() != 0 && priority() == priority, restores unspent from_held claims on fallback, and drops excess claims outside cell and reservation locks.
    • drivers/gpu/drm/asahi/g17/mod.rs and runtime/backend.rs: pin_scheduler_cluster leaves single-die M5 schedulers unrestricted while keeping cluster pinning elsewhere.
  • Hardware rows & CI:
    • Exact-head Apple M5 Pro (T6050 / J714s / G17S B1) pass row in fleet candidate b7b130a75bab (gpubench-vk ok, Vulkan CTS 0 fail, 0 GPU/DART faults).
    • Exact-head MacBook Neo (J700 / G17P B1) combined Wave C pass row (7bb607c48427): 215/215 g17 host tests, 2,880/2,880 timeline semaphore CTS pass, 373 focused compute/sync CTS pass / 0 fail, 5/5 compute CRCs, 0 GPU faults / 0 AVCs.
    • Paginated CI check-runs at 8926e891cfb1: 19/19 green (0 active, 0 failed), clean merge preview onto main.

@DjDeveloperr
DjDeveloperr dismissed satchlj’s stale review November 25, 2026 21:35

The merge-base changed after approval.

@DjDeveloperr
DjDeveloperr merged commit b0c2cd4 into main Nov 25, 2026
29 of 31 checks passed
@RyanTheTide
RyanTheTide deleted the perf/asahi-g17-m5-multiqueue-contention 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) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants