Repository navigation
drm/asahi: g17: let a refused submission leave its outputs untouched - #3700
jgoyvaerts wants to merge 2 commits into
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. |
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. KUnit (arm64 qemu) 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.