Skip to content

drm/asahi: g17: let a refused submission leave its outputs untouched - #3700

Open
jgoyvaerts wants to merge 4 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-submit-errno
Open

jgoyvaerts wants to merge 4 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-submit-errno

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What: A refused G17 SUBMIT now changes nothing. ENOMEM (no memory) or ENOSPC (no GPU capacity) means no command was queued and no output sync object changed, so Borealis can return VK_ERROR_OUT_OF_HOST_MEMORY / OUT_OF_DEVICE_MEMORY instead of losing the device. Today every G17 SUBMIT failure installs a failed fence on the outputs, which Vulkan's rule for a failed vkQueueSubmit forbids. DRM_ASAHI_FEATURE_SUBMIT_REFUSAL_UNTOUCHED (bit 48) reports the contract. drm_asahi_submit::flags stays MBZ.
Tested: no Mac at this head yet. At 133672c (main 9b8e29f merged): KUnit (arm64 qemu) 1059 passed, 1 skipped, 0 failed; the full host run passes every g17 test with its mutations. The other failures of the full host run are local toolchain gaps in tests this PR does not touch (rustup 1.93.1 missing for g15-, a __stack_chk_guard link error in sep-suspend-errors and asahi-m4's test-stream-gate); they fail the same way in all three merged trees. dcp-peer-shown-tests hit a timing assert once here. Earlier, KUnit at e382bd2: 949 passed, 1 skipped, 0 failed. Host tests at e382bd2: g17-submit-refusal-untouched-tests and its 5 mutations pass, as do g17-chunk-work-guard and g17-compute-multi-channel-feature with their mutations. The 29 remaining failures also fail on main (sep-suspend-errors, g15-, apple-dcp, test-m3-uapi).
Risk: one-way door (uAPI: a new feature bit and changed refusal semantics) · M4 and M5 (G17).

  • Old userspace loses its device on any SUBMIT error either way. Borealis and Gallium already handle an output that never gets a fence (agx_batch.c agx_wait_failed_submit, hk_cmd_pool.c hk_cmd_pending_poll, bounded query waits, device destroy waiting only up to LAST_SUBMITTED).
  • The one change: a waiter already blocked on a refused submission's output point, in another thread or process, is no longer woken with an error fence. It waits until its own timeout, as on msm, panthor and xe.
    Not yet:
  • Hardware: a boot of a kernel carrying this (m4.215 has the earlier opt-in form) with Borealis keyed on bit 48 (mesa wifi: apple: centauri: serialize sibling acquisition with probing #1421), and a kernel-side injected refusal.
  • Coverage: only failures before the aggregate fence is published are refusals here. drm/asahi: g17: install a submission's outputs only once it is queued #3701 extends that to the first command's preparation. The per-queue firmware objects built at publication move to QUEUE_CREATE/SUBMIT in follow-ups.
Details

The contract (bit 48 present):

SUBMIT returns Queued Outputs
0 the submission its fence
ENOMEM, ENOSPC nothing unchanged: no allocation_failure, no fallback, no cumulative-signal chain
EIO possibly part of it a failed fence; this includes an ENOMEM/ENOSPC raised after the aggregate fence was published
any other errno (EINVAL, E2BIG, ENOENT, EFAULT, ...) nothing as today: a failed fence, except a malformed input/output split, which installs none

EAGAIN is not a capacity answer here, because libdrm's drmIoctl retries it in a loop. ERESTARTSYS restarts as before.

Earlier draft: this PR was first an opt-in submit flag plus bit 48. The flag only preserved the error wake-up of blocked waiters for old Mesa, so it was dropped in favour of the standard always-on shape.

What is a refusal at this head: everything before Outputs::publish*:

  • the fallback fence (Outputs::new);
  • command parsing, validation and VM pins (prepare_submission);
  • the frontier and publisher reservation;
  • work-state leases and chunks.

The enqueue loop runs after the aggregate fence is published, so its failures return EIO: Completion (including the compute timestamp page), the dependency vectors, Packet and the drm_sched job. #3701 moves the publish point after that loop.

Plumbing: fence::untouched_refusal(published, result) decides; fence::submit_result(published, result) maps a late ENOMEM/ENOSPC to EIO. They are used in Outputs::new, Outputs' drop and G17's submit.

Evidence
  • KUnit asahi_g17_aggregate_promise: a_refusal_before_publication_leaves_the_outputs_untouched, enomem_and_enospc_after_publication_become_eio.
  • tools/asahi/g17-submit-refusal-untouched-tests.py fails on main (the code is absent) and passes at head. Its mutations new-installs, drop-installs, no-errno-map, flags-accepted and not-reported are each caught.
  • The userspace review behind the bit-only shape (Mesa m4/next b54448cf7, aurora-wip 89ddabbf7, virglrenderer ca50e00) found no path that depends on a failed SUBMIT fencing its outputs. virglrenderer's asahi native context destroys its out syncobj on a SUBMIT error without waiting on it (asahi_renderer.c:758-800). Upstream Mesa knows only G13/G14.

A G17 SUBMIT that fails installs a failed fence on every output sync
object: the queue's allocation_failure fence if the ioctl fails before it
publishes its aggregate fence, the aggregate fence carrying the error
after that. So when userspace gets ENOMEM, the outputs have already
signalled, and the timeline points it asked for exist, failed.
- **Vulkan:** a failed vkQueueSubmit must leave every semaphore and
  resource unaffected. Borealis can therefore only treat any SUBMIT
  failure as a lost device, even a plain lack of memory.
- **The DRM convention:** an ioctl that fails changes nothing (msm,
  panthor, xe).

Make a refusal change nothing:
- **The contract:** ENOMEM (no memory) and ENOSPC (no GPU capacity) from
  SUBMIT mean the ioctl queued no command and changed no output: no
  allocation_failure, no fallback fence, no cumulative-signal chain.
  Userspace may report the error (VK_ERROR_OUT_OF_HOST_MEMORY,
  VK_ERROR_OUT_OF_DEVICE_MEMORY) and submit again.
- **Late failures:** after the aggregate fence is published to the
  outputs, the same failures are returned as EIO, and the outputs carry
  them, so ENOMEM and ENOSPC never mean "something changed".
- **Other errnos:** they leave a failed fence on the outputs as before,
  except a malformed input/output split, which still installs none.
- **Discovery:** `DRM_ASAHI_FEATURE_SUBMIT_REFUSAL_UNTOUCHED` (bit 48)
  reports the contract. drm_asahi_submit::flags stays MBZ.

What old userspace sees: it loses its device on any SUBMIT errno either
way, and its own waits already handle an output without a fence. The one
difference is a waiter blocked on a refused submission's output point,
in another thread or process. It is no longer woken with an error fence;
it waits until its own timeout, as on msm, panthor and xe.

What is a refusal today is everything before the aggregate fence is
published: the fallback fence, command parsing and validation, VM pins,
the frontier reservation, work-state leases and chunks. The per-command
allocations of the enqueue loop still follow publication, so they fail
as EIO. Moving them before it, and building per-queue firmware objects
at QUEUE_CREATE or SUBMIT instead of at publication, comes next.

Tests:
- **KUnit:** the refusal decision and the errno mapping.
- **Host test** (g17-submit-refusal-untouched-tests.py) checks the wiring:
  - Outputs::new, Outputs' drop and submit consult the decision;
  - flags stays MBZ;
  - only G17 reports the feature.

  Five injected faults are caught.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@jgoyvaerts
jgoyvaerts force-pushed the m4pro/g17-submit-errno branch from 6bcc79e to e382bd2 Compare November 30, 2026 18:59
Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J700 (Neo, G17P) boot row at head b6ead1c5

Kernel: one trial boot (boot b98d2a22). Stock Fedora -41 was restored and verified afterwards.

Results

  • GET_PARAMS: bit 48 (SUBMIT_REFUSAL_UNTOUCHED) is set; features 0x0001397a6001fc07.
  • Normal submits all completed with correct output:
    • q4 render triangle, checked by per-queue CRC
    • compute.light d1/d16, checked by per-slot CRC
    • 4-queue render; 4-queue and 4-process compute
    • concurrent render + compute
    • cross-queue timeline and binary semaphores; host signal
    • queue create/use/close/reuse (CRC ok); mem.buffer
  • Multi-queue CTS, compared case for case with the same Image running the drm/asahi: g17: keep G17P render queue records firmware-cached #3705 module:
    • sync2 op.multi_queue: 16,680 Pass / 7,080 NotSupported / 0 Fail
    • sync op.multi_queue: 12,798 Pass / 9 NotSupported / 0 Fail
    • identical results, 0 recoveries
  • Health: 0 WARN, 0 GPU faults, 0 AVC, 0 failed units. The only flagged boot line is "aurora: loading out-of-tree module taints kernel". It comes from building the module with M=, not from the driver.

Not run: the refusal contract itself. This kernel has no way to make SUBMIT genuinely refuse with ENOMEM or ENOSPC before publication. The J700 config has no fault injection (no FAILSLAB, FAIL_FUNCTION or BPF override), and before #3704, G17P submit allocations are not charged to the memory cgroup. The sentinel-output, same-recording retry and refusal-after-accepted-batch rows still need a test kernel with an injection point, plus Mesa #1421 on it.

DjDeveloperr
DjDeveloperr previously approved these changes Dec 1, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed b6ead1c. A cumulative-scope allocation refusal preserves ENOMEM and the output syncobjs. The ioctl return trace carries no private fence. The 297 driver checks passed. The always-on bit-48 refusal and same-queue retry still need a hardware row.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Fixed the errno and trace for an unpublished cumulative-scope allocation refusal in b6ead1c.

Main's b01dc0e replaces Outputs::finish() with
Outputs::set_result() and leaves the outputs untouched for an
-ERESTARTSYS before publication. Conflict in g17/queue/mod.rs, resolved
as the union: the submission's result is first mapped by
submit_result() (a refusal after publication becomes EIO), then stored
with main's set_result(), so Outputs::drop() sees the result the ioctl
returns; the traced output fence stays None for an untouched refusal,
and main's output_fence() keeps it None for -ERESTARTSYS.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
jgoyvaerts added a commit to jgoyvaerts/linux that referenced this pull request Dec 4, 2026
…ueue

Brings in aurora-silicon#3700's merge of main (133672c) and with it main's
b01dc0e: Outputs::set_result() replaces Outputs::finish(), and an
-ERESTARTSYS before publication leaves the outputs untouched. No
conflicts. On this branch that -ERESTARTSYS comes before
Outputs::publish(), so no submission exists, Outputs::install() does
nothing and Outputs::drop() returns before the fallback is installed:
the outputs stay untouched as main requires.

Main's KUnit test full_window_signal_leaves_timeline_untouched_for_restart
publishes the restarted submission and expects its timeline point
installed. On this branch Outputs::publish_with() only prepares the
outputs and Queue::submit() installs them once a command is queued, so
the test now calls Outputs::install() after publishing, as submit does.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@jgoyvaerts
jgoyvaerts marked this pull request as ready for review December 4, 2026 05:20
@jgoyvaerts
jgoyvaerts requested review from a team as code owners December 4, 2026 05:20
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:one-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 Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Merge readiness at 133672ca: not ready yet

Check Detail
CI at head ok 10 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 133672ca, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: one-way · (uAPI: a new feature bit and changed refusal semantics) · M4 and M5 (G17). - Old userspace loses its device on any SUBMIT error either way. Borealis and Gallium already handle an output that never gets a fence (agx_batch.c agx_wait_failed_submit, hk_cmd_pool.c hk_cmd_pending_poll, bounded query waits, device destroy waiting only up to LAST_SUBMITTED). - The one change: a waiter already blocked on a refused submission's output point, in another thread or process, is no longer woken with an error fence. It waits until its own timeout, as on msm, panthor and xe.

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 commented Dec 4, 2026 •

Copy link
Copy Markdown

Merge readiness at 0e8f2101: not ready yet

Check Detail
CI at head ok 9 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 0e8f2101, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: one-way · (uAPI: a new feature bit and changed refusal semantics) · M4 and M5 (G17). - Old userspace loses its device on any SUBMIT error either way. Borealis and Gallium already handle an output that never gets a fence (agx_batch.c agx_wait_failed_submit, hk_cmd_pool.c hk_cmd_pending_poll, bounded query waits, device destroy waiting only up to LAST_SUBMITTED). - The one change: a waiter already blocked on a refused submission's output point, in another thread or process, is no longer woken with an error fence. It waits until its own timeout, as on msm, panthor and xe.

Areas: area:gpu

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

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Dec 4, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Forward-merged main cf66a34212f5 at 0e8f2101ca94. The conflicts were adjacent additions. G17 still reports idle VM reclaim at bit 49 and now reports the untouched-refusal contract at bit 48. The host runner keeps both sets of fixtures.

git diff --check passed. g17-submit-refusal-untouched-tests.py passed on the merged sources, and all five injected faults were detected.

Still needed are an independent review of this head and an enabled bit-48 hardware run showing that a refused submit leaves the output syncobjs untouched and that a retry completes on the same queue.

@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 0e8f210

Checked: Followed the exact ioctl through sync parsing, private aggregate allocation, and output publication. A cumulative scope allocation failure returns ENOMEM before the first syncobj store. The private aggregate and signal bundle then clean up without publishing a fallback. Errors after output publication stop using the retryable ENOMEM and ENOSPC codes and retain error completion on the installed fence. Bit 48 is distinct from idle VM reclaim at bit 49, and submit flags remain MBZ. The shipped host test passed and detected all five supplied mutations. Exact-head Apple build, host tests and Asahi KUnit passed. Hardware retry remains unverified locally.

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:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:one-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.

2 participants