Skip to content

drm/asahi: g14_v27_2: retry ring-full EBUSY and isolate packet publication errors - #3249

Open
AxxzyWasTaken wants to merge 1 commit into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g14-v27-2-ebusy-fail-packet
Open

AxxzyWasTaken wants to merge 1 commit into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g14-v27-2-ebusy-fail-packet

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: Fix g14_v27_2 ring-full EBUSY handling and isolate per-packet publication failures from device-wide VmStatus:

  • Ring-room pre-check (drivers/gpu/drm/asahi/gpu/v27_2.rs): Add RootV27_2::check_work(), check_render(), and check_compute() so Runtime::pump() checks submission-ring and per-DM queue headroom before staging, avoiding avoidable staging churn when a ring is temporarily full (buffer-op renders that require a second TA entry still unwind cleanly if stage_render() returns EBUSY).
  • Bounded EBUSY retry (drivers/gpu/drm/asahi/g14_v27_2.rs): Retry transient EBUSY on both render and compute packets regardless of state.running(), bounded by COMMAND_TIMEOUT_MS via kick_due() so a permanently stalled ring expires cleanly instead of livelocking.
  • Per-packet failure isolation: Route fail_publication() and deferred publication_error handling through fail_packet(err) so an isolated packet publication error fails only that packet's fences and does not poison unrelated contexts' VmStatus, while preserving record_if_device_loss for EIO/ETIMEDOUT/ENODEV.
  • Host tests (tools/asahi/g14-v27-2-pump-ebusy-tests.py): Registered in tools/asahi/run-host-tests.py covering render/compute EBUSY retry, timeout expiry, VmStatus isolation, and 8 negative-control mutations.

Tested: python3 tools/asahi/run-host-tests.py --only g14-v27-2-pump-ebusy: 9/9 PASS (8/8 negative-control mutations killed).

  • ARM64 cross-compile (ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/aurora.o) with CONFIG_DRM_ASAHI_G14_V27_2=y (CONFIG_APPLE_SOC_SLEEP=y and =n) and CONFIG_DRM_ASAHI_G14_V27_2=n: PASS, 0 warnings in touched files.
  • git diff --check clean; scripts/checkpatch.pl --strict: 0 errors, 0 code warnings.

Not yet: On-hardware G13G (T8103) / G14G (T8112) firmware 27.2 saturation test exercising live ring-full EBUSY retries.

Risk: two-way · G13G (T8103) and G14G (T8112) GPUs running the g14_v27_2 firmware 27.2 backend; legacy 12.x/13.5 and G15/G16/G17/G18 paths are untouched.

Closes: #3070

@AxxzyWasTaken
AxxzyWasTaken requested review from a team and DjDeveloperr as code owners November 26, 2026 12:52
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 15c502a5: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 15c502a5, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · G13G (T8103) and G14G (T8112) GPUs running the g14v272 firmware 27.2 backend; legacy 12.x/13.5 and G15/G16/G17/G18 paths are untouched. Closes: #3070

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 ci-failing A check failed at the PR head (bot) label Nov 26, 2026
@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g14-v27-2-ebusy-fail-packet branch from 6cf0457 to a247885 Compare November 27, 2026 01:18
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (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: MERGE at a247885573aaabc43d87594295a2c01a8a0f5689 once hardware evidence is complete.

Blockers: No code blocker found. Keep the PR unarmed until exact-head firmware 27.2 ring-pressure tests on the affected G13G/G14G paths demonstrate progress and confirm another VM keeps running after the rejected packet.

Checked: Read the staging and publication changes. The precheck does not advance producer state, repeat staging revalidates the ring, the retry deadline is cleared when the blocked front advances or is withdrawn, and partially published packets retain their guard through retirement. The exact-head extracted host harness passed all 13 cases and the head CI is green. No DT, per-board gating, private material, or attribution added.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Heads-up from a batch row: this PR and #3238 both rework the same pump error paths in drivers/gpu/drm/asahi/g14_v27_2.rs (waiting_bind in #3238 vs waiting_ring here, 16 conflict hunks), so they can't be stacked as they are. #3238 now has a J473 row at its head (#3238 (comment)) and is next in the merge train. Once it lands, this needs a rebase that keeps both wait states. After that, a J473 ring-saturation row at the new head can go in the next batch boot.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 28, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

#3238 is merged now (8ebb0f75). This PR needs the rebase onto main that keeps both waiting_bind and waiting_ring. Once a new head is up, a J473 + J316s row at it can go in the next batch boot.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Rebased onto main (d71f3b2101e15, past #3238) at a5be6ed180c0b, keeping both waiting_bind and waiting_ring in drivers/gpu/drm/asahi/g14_v27_2.rs and updating both test harnesses in tools/asahi/. Verified run-host-tests.py --only g14-v27-2-try-bind (10/10 PASS) and --only g14-v27-2-pump-ebusy (9/9 PASS, all mutations killed). Ready for the J473 + J316s batch boot.

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g14-v27-2-ebusy-fail-packet branch from a247885 to a5be6ed Compare November 30, 2026 22:06
@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 30, 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 at a5be6ed1

Blockers:

  • Queued hosted CI at a5be6ed1 (0P/0F/1Q): Wait for hosted apple-build, host-tests, and KUnit checks to complete green on the rebased head.
  • Exact-head firmware-27.2 hardware rows (a5be6ed1): Ready for the planned J473 + J316s batch/one-shot hardware run at a5be6ed1 verifying ring-pressure progress and isolated per-packet failure recovery (confirming unrelated VMs keep running after a rejected packet).

Checked:

  • Audited full Rust production diff (drivers/gpu/drm/asahi/g14_v27_2.rs, drivers/gpu/drm/asahi/gpu/v27_2.rs) after rebasing past #3238 (main d71f3b2101e15):
    • waiting_bind (#3238) and waiting_ring (this PR) compose cleanly with no interference: both are reset on front removal, empty queue, fail_all, VM failure, free_slots empty, Ok(()), non-EBUSY publication error, cancel, recovery restart, and sleep/wake/restart, and each clears the other when switching between BindBusy and EBUSY.
    • RootV27_2::check_compute() and check_render() run before try_bind_vm() without advancing producer state, avoiding unnecessary VM-bind churn while a ring is full.
    • fail_publication() and deferred publication_error route through packet.fail_packet(err) with g14_v27_2_abi::guard_releasable() checks so isolated packet publication failures do not poison unrelated VMs.
    • Author verified both g14-v27-2-try-bind (10/10 PASS) and g14-v27-2-pump-ebusy (9/9 PASS, all 8 negative-control mutations killed) locally at a5be6ed1.
Evidence
  • Head commit: a5be6ed180c0ba755497fbac49d6fa35617604e3 (MERGEABLE into main).
  • Diff summary: +1898/-22 across g14_v27_2.rs, gpu/v27_2.rs, g14-v27-2-pump-ebusy-tests.py, g14-v27-2-try-bind-tests.py, run-host-tests.py.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

I checked a5be6ed with an independent host fixture that switches the same front packet from a VM-bind wait to a ring wait and back before it publishes. The previous deadline cleared on both transitions. All 14 ring cases and 10 bind cases passed against the four verified source blobs from this head. The J473 and J316s hardware rows remain.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (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 a5be6ed180c0

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 full Rust production diff (drivers/gpu/drm/asahi/g14_v27_2.rs, drivers/gpu/drm/asahi/gpu/v27_2.rs) after rebasing past #3238 (main d71f3b2101e15):

  • waiting_bind (#3238) and waiting_ring (this PR) compose cleanly with no interference: both are reset on front removal, empty queue, fail_all, VM failure, free_slots empty, Ok(()), non-EBUSY publication error, cancel, recovery restart, and sleep/wake/restart, and each clears the other when switching between BindBusy and EBUSY.
  • RootV27_2::check_compute() and check_render() run before try_bind_vm() without advancing producer state, avoiding unnecessary VM-bind churn while a ring is full.
  • fail_publication() and deferred publication_error route through packet.fail_packet(err) with g14_v27_2_abi::guard_releasable() checks so isolated packet publication failures do not poison unrelated VMs.
  • Author verified both g14-v27-2-try-bind (10/10 PASS) and g14-v27-2-pump-ebusy (9/9 PASS, all 8 negative-control mutations killed) locally at a5be6ed1.

Follow-ups (not blocking): queued CI; J473/J316s ring-pressure rows

…ication errors

Runtime::pump() on the G14 firmware 27.2 backend has two error-handling
bugs:

1. publish_render() is only entered when !state.running(), so the
   `Err(EBUSY) if state.running() => return` arm in Runtime::pump() is
   unreachable for renders. When firmware retires a prior render or
   compute command slightly before advancing the submission-ring
   consumer cursor `r`, stage_render() or stage_compute() returns
   EBUSY while !state.running() and pump() immediately fails a healthy
   packet. Even when state.running() is true on the compute path,
   returning without arming a delayed retry can stall if consumer lag
   outlives the final completion IRQ.

2. State::fail_publication() (and the deferred publication_error
   retirement path in Runtime::service_locked()) called
   packet.finish(Err(err)) (fail_vm = true), which permanently poisons
   the client's VmStatus even when the failing command was never
   published to firmware and any earlier commands of the same packet
   retired cleanly.

Fix both defects:

- Factor submission-ring and queue-head validation in RootV27_2 into
  check_work() and expose check_render() / check_compute(), calling them
  before QueueRender::prepare(), UAT binding, and pool encoding so
  transient ring consumer lag does not churn scene allocations or pool
  buffers on retry. Even if stage_render() still returns EBUSY after
  QueueRender::prepare() succeeds, Prep/Scene unwinds cleanly without
  calling queue.published() or advancing CommandPool spare buffers.
- Track submission-ring EBUSY waits in State::waiting_ring using
  FirmwareWait::kick_due(), kicking the relevant doorbell(s) at most
  once per RESOURCE_RETRY_MS and arming Notify::retry() regardless of
  state.running(). Clear waiting_ring on publication, non-EBUSY errors,
  slot-unlink waits, render-boundary waits, front withdraw() (waking
  service for a successor or notifying idle when empty), fail_all(),
  sleep_prepare(), and sleep_complete(). After COMMAND_TIMEOUT_MS, fail
  the blocked packet via State::fail_publication(packet, EBUSY) so
  VmStatus and the healthy runtime remain intact.
- Switch both State::fail_publication() (when no command of the packet
  is in flight) and Runtime::service_locked()'s deferred
  done.publication_error completion (once the published prefix retires
  cleanly) from packet.finish(Err(err)) to packet.fail_packet(err),
  matching the M3 runtime's VM isolation semantics while keeping real
  device-loss errors (EIO/ETIMEDOUT/ENODEV) and firmware hangs fatal to
  VmStatus.

Add a standalone host test harness under tools/asahi/ extracting and
compiling the production G14 27.2 runtime state machine across 13
positive scenarios and 8 negative-control mutations, and register it in
tools/asahi/run-host-tests.py.

Closes: aurora-silicon#3070
Signed-off-by: AxxzyWasTaken <[email protected]>
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Rebased onto main (f06827ce52f8e) at 15c502a53c0f7, preserving the new EAGAIN sleep-retry arm alongside handle_ring_busy() in drivers/gpu/drm/asahi/g14_v27_2.rs and adding the new EAGAIN / pmgr_gpu_* / gpu_busy_held stubs to g14-v27-2-pump-ebusy-tests.py. Verified both host suites (10/10 g14-v27-2-try-bind-tests + 9/9 g14-v27-2-pump-ebusy-tests, all mutations PASS).

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g14-v27-2-ebusy-fail-packet branch from a5be6ed to 15c502a Compare December 1, 2026 07:07
@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 Dec 1, 2026

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) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drm/asahi: g14_v27_2: pump() fails render on transient EBUSY and poisons VmStatus on pre-publication errors

3 participants