Repository navigation
drm/asahi: g17: let a refused submission leave its outputs untouched - #3700
Conversation
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>
6bcc79e to
e382bd2
Compare
Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J700 (Neo, G17P) boot row at head Kernel: one trial boot (boot
Results
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
left a comment
There was a problem hiding this comment.
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.
|
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>
…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>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Merge readiness at
Areas: 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>
|
Forward-merged main
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. |
There was a problem hiding this comment.
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.
|
Bare-metal M4/M5 hardware validation row at exact head Tested in disjoint 12-PR batch kernel
Trace: |
|
Merging with |
Main's 6b5d926 skips retaining a prior scope that already succeeded, so a cumulative scope's children[0] can be NULL and its pending count starts at 2. This branch's ffcbd94 installs the callbacks in asahi_g17_scope_arm() at commit instead of in asahi_g17_scope_create(). Conflict in g17/sync_scope.c, resolved as the union: create keeps main's optional parent and pending count, and arm skips a NULL children[0]. include/uapi/drm/asahi_drm.h now matches main: bit 48, DRM_ASAHI_FEATURE_SUBMIT_REFUSAL_UNTOUCHED, came with aurora-silicon#3700. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
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_guardlink 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).
agx_wait_failed_submit, hk_cmd_pool.chk_cmd_pending_poll, bounded query waits, device destroy waiting only up to LAST_SUBMITTED).Not yet:
Details
The contract (bit 48 present):
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*:Outputs::new);prepare_submission);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 inOutputs::new,Outputs' drop and G17'ssubmit.Evidence
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.pyfails on main (the code is absent) and passes at head. Its mutationsnew-installs,drop-installs,no-errno-map,flags-acceptedandnot-reportedare each caught.