Repository navigation
drm/asahi: g17: wait interruptibly when submission order window is full - #3306
Conversation
When a context submits more than ORDER_WINDOW (1024) ioctls ahead of its oldest waiting ioctl (for example during a compositor atomic-commit retry burst), WorkStateLease::deferred() previously failed immediately with -EBUSY. Userspace Vulkan drivers treat a submit ioctl error as device loss, triggering GL_GUILTY_CONTEXT_RESET and aborting the compositor. Track full-window submitter waits separately in identity::Order and pair context.order with a CondVar so WorkStateLease::deferred() waits interruptibly without heap allocations for up to 1 s (re-checking VM status on each slice and returning -ERESTARTSYS on signals) before falling back to -EBUSY. Signed-off-by: Erik Bourget <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at 4d5fcb73: code OK. Merge after the J700 row: this is shared G17 code, so it needs a regression row on the other G17 generation (A18 Pro).
Checked
- A full order window now waits interruptibly on
order_waitin up to 50 ms slices, bounded by a 1 s deadline. It returns EIO if the context has failed, ERESTARTSYS on a signal, and EBUSY only if the turn doesn't move in time. - The order lock is held across the condvar wait.
notify_turnwakes submitters only when a refusal was recorded, throughOrderWake. - Both paths that advance the turn (
admitandleave) notify, so I found no lost wakeup. - KUnit 459/4 skip, with the ordering test updated. J716c desktop plus two 4K240 outputs and DPMS ×2 show 0 submission errors.
Before merge: a J700 (G17P) row at this head with a normal GPU workload (we can run it on our Neo if you'd like). The over-1024-submit stress reproducer can follow.
Conflicts: drivers/gpu/drm/asahi/g17/context.rs Keep both main's AtomicU64 import and this branch's OrderWake import. Signed-off-by: Erik Bourget <[email protected]>
When WorkStateLease::deferred() is interrupted by a signal while waiting on a full ORDER_WINDOW, it returns -ERESTARTSYS so the kernel can restart the submit ioctl. Previously WorkStateLease::deferred() ran inside Outputs::publish(), and Outputs::drop() installed and signalled a fallback error fence on the resolved output syncobjs. For timeline syncobjs, a waiter could observe -ERESTARTSYS before the restarted ioctl attempted to publish the same timeline point again. Move WorkStateLease::deferred() before Outputs::publish() in Queue::submit(), and skip fallback error-fence publication in Outputs::output_fence() and Outputs::drop() when returning -ERESTARTSYS before publication. Add a KUnit test covering full-window signal interruption with timeline and cumulative syncobjs and subsequent ioctl restart. Signed-off-by: Erik Bourget <[email protected]>
|
Merged
Verified at
@RyanTheTide: please go ahead with the J700 (A18 Pro / Neo) normal GPU workload row at |
…backpressure Signed-off-by: Erik Bourget <[email protected]>
Commit fad5d04 ("drm/asahi: keep a submission's syncs and command copy off contiguous pages") changed Outputs::new() to accept KVVec<SyncItem> instead of KVec<SyncItem>. Update the sync vectors in full_window_signal_leaves_timeline_untouched_for_restart() to match so KUnit builds cleanly after merging main. Signed-off-by: Erik Bourget <[email protected]>
|
Merged
Verified at
@RyanTheTide: the J700 (A18 Pro / Neo) normal GPU workload row at |
There was a problem hiding this comment.
Verdict: MERGE at 5d9bcf09
Blockers: none in code (re-run the cancelled pr-text and readiness checks and run a second-generation G17P/J700 lab regression row before landing).
Checked:
drivers/gpu/drm/asahi/g17/queue/mod.rs,context.rs,fence.rs: bounded interruptibleCondVarwait (50 ms slices up to 1 s deadline) whenORDER_WINDOWfills;b01dc0e4leaves resolved output syncobjs untouched on-ERESTARTSYSbefore publication;5d9bcf09updatesOutputs::new()KUnit tests toKVVec<SyncItem>cleanly after#3021.- Tests & rows: arm64 QEMU Asahi Rust KUnit 491/491 pass (4 skipped, 0 failed), 26/26 build/host/KUnit CI checks green, and live J716c M5 Max deferred-submit stress & desktop rows PASS at exact head
5d9bcf09. - Checked for Apple material, tool attribution, private serials, and gating: clean;
MERGEABLEonmain.
Evidence
- Head:
5d9bcf092530(base: main,mergeable: MERGEABLE,+326/-47across 7 files).
|
Both Re-verified at
Updated the PR body with |
Main (#3330, granular work-state retire) added a multi-command path that splits an ioctl into chunked work-state leases and publishes them with Outputs::publish_with_status(), next to the single-command Outputs::publish(). This branch makes publish() take a lease created by the caller, so the interruptible order-window wait happens before any output is published. Kept both: the multi-command path is main's unchanged (its first WorkStateLease::deferred() now waits interruptibly too, before publication); the single-command path creates its lease before publish() as this branch does. note_render() runs just before either publication, after any wait. Outputs keeps main's publish_source() split with this branch's publish_with(Option<lease>) on top. tools/asahi/g17-output-fence-tests.py (main, #3311/#3648) extracts impl Submission and expected one Arc::new() there, the one in Submission::new(), which this branch removes; it now expects none. Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged main into this branch (merge commit only, no rebase), new head 8133872. Thanks @erikwb. Conflict: main's #3330 (granular work-state retire) added a multi-command submit path that splits an ioctl into chunked work-state leases and publishes them with Tests at the merge: The merge changed the submit path under test (queue/mod.rs, fence.rs), so the J716c rows at 5d9bcf0 no longer cover this head. Still needed: the J700 row (now at this head), App review at head. |
There was a problem hiding this comment.
Verdict: HOLD at 81338726 for current-head hosted checks and the outstanding J700 peer row.
Checked: Both submit paths take their initial work-state lease before publishing any output. The multi-command path retains main’s chunk splits and status-backed publication. If an initial lease wait is interrupted, neither path exposes a fallback output fence, and render accounting is still after the wait. The host fixture change matches the removed constructor allocation.
The prior J716c stress covers the earlier tree. Exercise single- and multi-command submissions on the integrated tree and keep J700 as the second-family row.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approved. A full order window now waits interruptibly in 50 ms slices up to 1 s and returns ERESTARTSYS on a signal without touching output syncobjs, and on this merged head both submit paths take the work-state lease before any output is published. The A18 Pro (J700) row Ryan asked for is in: a candidate carrying this head unchanged ran a normal GPU workload (4-queue render with CRC check, compute, concurrent render+compute, vkcube) and one deep sleep, with 0 GPU faults, timeouts or submission errors.
|
J700 (Neo, G17P) row at combined SHA Kernel: one-shot trial boot
Results
This PR: interruptible wait when the submission order window is full. All submits completed and the multi-queue gpubench readbacks were correct, with 0 submission errors. |
There was a problem hiding this comment.
Verdict: MERGE at 81338726dc3f
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: Both submit paths take their initial work-state lease before publishing any output. The multi-command path retains main’s chunk splits and status-backed publication. If an initial lease wait is interrupted, neither path exposes a fallback output fence, and render accounting is still after the wait. The host fixture change matches the removed constructor allocation.
The prior J716c stress covers the earlier tree. Exercise single- and multi-command submissions on the integrated tree and keep J700 as the second-family row.
Follow-ups (not blocking): hosted checks; single/multi-command submit run on integrated tree (J700 peer not required)
What: Wait interruptibly on a
CondVarfor up to 1 s when a G17 context'sORDER_WINDOW(1024) fills instead of failing the submit ioctl immediately with-EBUSY, and leave output syncobjs untouched on-ERESTARTSYSbefore publication so compositor retry bursts and restarted ioctls avoid BorealisGL_GUILTY_CONTEXT_RESETaborts and duplicate timeline publication.Tested: At
5d9bcf092530: arm64 QEMU Asahi Rust KUnit (drivers/gpu/drm/asahi/.kunitconfig)491 passed, 4 skipped, 0 failed(includingno_ioctl_is_ordered_past_the_windowandfull_window_signal_leaves_timeline_untouched_for_restart); G17 host tests (tools/asahi/run-host-tests.py --only g17)238/238 passed;asahi-m4host selftests (test-submit-restart.py,test-fence-signalling.py) pass (1/1,2/2,2/2,7/7, andsync_input C coalescing tests passed);checkpatch.pl --strictclean (0 errors, 0 warnings, 0 checks). Live J716c (16-inch M5 Max, T6050) hardware row at5d9bcf092530in batched candidatec3da8eed6f72(overmain9af21b007425, default command line, Stage 21.0.0b17-g00976384, Linux7.3.0, AC 100%, all 7 PR files byte-identical): single boot ID,0panics/Oops/BUG/SErrors/DART faults/GPU faults/LSM denials, only the pre-existingaurora-peripheralsandsystemd-networkd-wait-onlineunits failed, BorealisApple M5 Max (G17C B1),eDP-13456x2234@120;dEQP-VK.ssbo.layout.single_basic_type.*909/909Pass,vk_burn~50kdispatches,vkcube(FIFO and immediate present modes),glmark2-wayland(zink), and a GPU burst after apm_test=devicessuspend/resume all completed with0GPU faults,0timeouts and0newdmesglines. A dedicated deferred-submit stress run in a second four-PR batched candidatef59b93fb961f(overmain9af21b007425, default command line, Stage 21.0.0b17-g00976384, Linux7.3.0, AC 100%, all 7 PR files byte-identical) then drove one Vulkan context past the window: a ~0.7 scompute dispatch signals timeline value1, and1,300(and in a repeat1,500) further tiny dispatches each wait on that value and signal a later point, so each is its own submit ioctl held behind the dispatch (traced withasahi_g17_submit). OnevkQueueSubmitblocked666.1 msin the kernel (the full-window wait, not-EBUSY) and returnedVK_SUCCESS; all1,339(and1,541) traced submit ioctls returned0(0-EBUSY,0VK_ERROR_DEVICE_LOST), the final timeline value was reached~710 msafter the first submit, a900-submit control run inside the window blocked no ioctl (slowest0.2 ms), and the boot showed0GPU faults/timeouts, no error-level kernel lines beyond the pre-existingsystemd-gpt-auto-generatorpair, and0panics/Oops/BUG/SErrors/DART faults/LSM denials. Earlier-head J716c (T6050) hardware row atb01dc0e46139in candidate3e4078f656d5(mainfcb124279183plus unchangedb01dc0e46139and sibling PRs, default command line,eDP-13456x2234@120, no external display attached): boots cleanly to SDDM/Hyprland desktop (Apple M5 Max (G17C B1)), passes 2xdpms off/oncycles under GPU load (4 x 1,985-casedEQP-VK.ssbo.*CTS probes,7,940/7,940Pass),0GPU submission errors,0newdmesglines across the DPMS+CTS window,0new failed units (aurora-peripherals.serviceat settle andsystemd-networkd-wait-online.servicelater are pre-existing on the default boot),0LSM denials (0avc/apparmor/landlock/yamalines),3booterrlines (2xpre-existingsystemd-gpt-auto-generatorplusaurora 2302600000.gpu: M5 bare-metal bootstrap failed at session: EPROBE_DEFERat0.65 sbefore GPU came up; dual3840x2160@240external display DPMS was verified at prior commit4d5fcb73db27). Commit5d9bcf092530itself is a KUnit-onlyKVec->KVVecfix; however, the preceding merge3bf1d8bd9e5f(mainaa3351bc8e6f) brought in#3021(KVVecsubmission syncs) and#3380(G17 retirement hrtimer), so the3e4078f656d5row predates those changes and is kept only as an earlier-head row.Risk: two-way door · G17 GPUs (
T6050M5 Pro/Max/Ultra,T8142M5,T8140A18 Pro,T6040/T6041M4 Pro/Max); no impact on G13/G14/G15/G16 drivers.Revert:
git revert -m 1 <merge-commit>restores immediate-EBUSYonORDER_WINDOWoverflow and the priorOutputs::drop()fallback fence path; no persistent on-disk, DT, or firmware state is written.Not yet: A18 Pro (
J700,T8140) normal GPU workload row at5d9bcf092530(0 GPU submission errors, 0 failed units, 0 new kernel errors, and 0 SELinux/LSM denials; external hardware, second G17 family requested before merge);T6040/T6041(M4 Pro/Max) andT8142(M5) G17 hardware rows (external hardware); and the-ERESTARTSYSrestart and1 s-EBUSYtimeout fallback on hardware (the J716c stress released the window after~0.67 s, so neither path ran on hardware; KUnit exercises signal interruption and injectsEBUSYto check error-fence publication, without waiting out the1 sdeadline).Details
Root cause
When a context submits more than
ORDER_WINDOW(1024) ioctls ahead of its oldest waiting ioctl (observed during an Aquamarine atomic-commit retry burst when an external display errored with-EINVAL),WorkStateLease::deferred()immediately returned-EBUSY. Userspace Vulkan drivers (Borealis / zink) treat a submit ioctl error asVK_ERROR_DEVICE_LOST, raisingGL_GUILTY_CONTEXT_RESETand aborting Hyprland.In addition, if
WorkStateLease::deferred()was interrupted by a signal after output syncobjs were resolved and returned-ERESTARTSYSinsideOutputs::publish(),Outputs::drop()installed and signalled a fallback-ERESTARTSYSfence on the resolved output syncobjs before the kernel restarted the ioctl, exposing-ERESTARTSYSto timeline waiters and causing the restarted ioctl to publish the same timeline point twice.Changes
identity::Orderwake tracking intoOrderWake { publishers, submitters }(drivers/gpu/drm/asahi/g17/context/identity.rs) so full-window submitters are woken whenever the oldest ordinal advances or is abandoned without altering publisher admission ordering.context.orderwithorder_wait: Arc<CondVar>(drivers/gpu/drm/asahi/g17/context.rs) soWorkStateLease::deferred()(viaassign_order()) holds a singlecontext.orderguard and waits interruptibly in <=50 ms slices (up to 1 s) using stack-allocatedCondVar::wait_interruptible_timeout()with zero per-wait heap allocations.context.status().get() != 0on each slice (returning-EIOon VM loss), return-ERESTARTSYSon signals, and fall back to-EBUSYonly if the window stays full for 1 s.WorkStateLease::deferred()beforeOutputs::publish()andcontext.note_render()inQueue::submit()(drivers/gpu/drm/asahi/g17/queue/mod.rs), and skip fallback error-fence publication/exposure inOutputs::output_fence()andOutputs::drop()(drivers/gpu/drm/asahi/g17/fence.rs) when returning-ERESTARTSYSbefore publication so restarted ioctls leave timeline and cumulative syncobjs untouched.no_ioctl_is_ordered_past_the_windowto verify the submitter wake flag on admission, and addfull_window_signal_leaves_timeline_untouched_for_restartinasahi_g17_aggregate_promise(using KUnit-onlySyncObj::new_kunit()andasahi_g17_kunit_{raise,clear}_sigterm()helpers) covering full-window signal interruption with timeline and cumulativeSignalBundlesyncobjs, clean ioctl restart publication, and error-fence publication with injectedEBUSY(without waiting out the1 sdeadline).main(fcb124279183) ate56d52102205(keeping bothAtomicU64andOrderWakeindrivers/gpu/drm/asahi/g17/context.rs) andmain(aa3351bc8e6f) cleanly at3bf1d8bd9e5f, and update the#[cfg(CONFIG_KUNIT = "y")]test vectors infull_window_signal_leaves_timeline_untouched_for_restart()fromKVectoKVVecat5d9bcf092530to matchOutputs::new()after#3021(fad5d04a1fa8).Overlapping PRs
aurora-silicon/linux#3429also modifiesdrivers/gpu/drm/asahi/g17/context.rs, and#3443/#3411also modifydrivers/gpu/drm/asahi/g17/queue/mod.rs;#3306is independent of those series and merges cleanly onto currentmain(ee36fbdcd1c8,git merge-tree --write-tree->349e622db4a4).Evidence
fix/g17-order-window-backpressure(merge-baseaa3351bc8e6f):4d5fcb73db27drm/asahi: g17: wait interruptibly when submission order window is fulle56d52102205Merge branch 'main' into fix/g17-order-window-backpressureb01dc0e46139drm/asahi: g17: leave output syncobjs untouched on -ERESTARTSYS3bf1d8bd9e5fMerge remote-tracking branch 'origin/main' into fix/g17-order-window-backpressure5d9bcf092530drm/asahi: g17: use KVVec in signal interruption KUnit test5d9bcf092530:./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/asahi/.kunitconfig --jobs=32 --timeout=900):Ran 495 tests: passed: 491, skipped: 4(0failed, includingno_ioctl_is_ordered_past_the_windowandfull_window_signal_leaves_timeline_untouched_for_restart).python3 tools/asahi/run-host-tests.py --only g17):238/238 passed.python3 tools/testing/selftests/drivers/gpu/asahi-m4/test-submit-restart.pyandtest-fence-signalling.py): pass (1/1,2/2,2/2,7/7, andsync_input C coalescing tests passed (256-hop chain -> 2 leaves, error preserved))../scripts/checkpatch.pl --strict --git aa3351bc8e6f..5d9bcf092530andgit diff aa3351bc8e6f..5d9bcf092530 | ./scripts/checkpatch.pl --strict --no-signoff -):0 errors, 0 warnings, 0 checks.5d9bcf092530in batched candidatec3da8eed6f72(overmain9af21b007425, default cmdline, Stage 21.0.0b17-g00976384, Linux7.3.0, AC 100%; all 7 changed filesdrivers/gpu/drm/asahi/g17/{context.rs,context/identity.rs,fence.rs,queue/mod.rs,sync_output.c,sync_output.h}andrust/kernel/drm/syncobj.rsverified byte-identical to5d9bcf092530):0panics/Oops/BUG/SErrors/DART faults/GPU faults/LSM denials; only the pre-existingaurora-peripheralsandsystemd-networkd-wait-onlineunits failed.dEQP-VK.ssbo.layout.single_basic_type.*:909/909Pass;vk_burn: ~50kdispatches;vkcube(FIFO and immediate);glmark2-wayland(zink); GPU burst afterpm_test=devicesresume:0GPU faults,0timeouts,0newdmesglines.1.0.0b17-g00976384, default cmdline):5d9bcf092530(four-PR batched candidatef59b93fb961fovermain9af21b007425, default command line, Stage 21.0.0b17-g00976384, Linux7.3.0, AC 100%; all 7 PR files verified byte-identical to5d9bcf092530):Apple M5 Max (G17C B1), Vulkan1.4); a~0.7 scompute dispatch (7,400,000loop iterations) signals timeline semaphore value1;Nfurther tiny dispatches each wait for value>= 1and signal1 + i, so each is one submit ioctl kept behind the first;asahi_g17_submittracepoint enabled around each run.N = 1,300:vkQueueSubmit#1,057took666.1 ms(all others<= 0.1 ms) and returnedVK_SUCCESS; all1,339traced submit ioctls (1,302of the test context,37of the desktop) returned0; the wait for value1,301returnedVK_SUCCESS710.6 msafter the first submit.N = 1,500: the same call index blocked666.1 ms, all1,541traced submit ioctls returned0, final value1,501reached after714.9 ms.N = 900(inside the window):0ioctls over10 ms(slowest0.2 ms), all939returned0.1,059th of its context, consistent with1,024ioctls queued behind the oldest waiting one plus the first34that had already taken their turn; it waited666.1 ms(> 100 ms,< 1 s) until the first dispatch retired and the window drained, instead of failing with-EBUSY.0panics/Oops/BUG/SErrors/DART faults/GPU faults/GPU timeouts/WARNINGlines/LSM denials; error-level kernel lines only the2xpre-existingsystemd-gpt-auto-generator(pluswatchdog0: watchdog did not stop!at reboot).3bf1d8bd9e5f, which mergedmainaa3351bc8e6fincluding#3021'sKVVecand#3380's G17 retirement hrtimer, and KUnit-only5d9bcf092530):T6050 / J716cat4d5fcb73db27(default cmdline): booted cleanly to Hyprland desktop (eDP-13456x2234@120 +DP-13840x2160@240 +DP-43840x2160@240), passed 2 full DPMS off/on cycles, 0 GPUIOCTL: submit failedor-EBUSYerrors.T6050 / J716catb01dc0e46139in candidate3e4078f656d5(default cmdline,eDP-13456x2234@120, no external display attached): boots to SDDM/Hyprland (Apple M5 Max (G17C B1)), 2xdpms off/oncycles viahyprctlwhile running4 x 1,985-casedEQP-VK.ssbo.*CTS (7,940Pass,0Fail),0GPU submission errors,0newdmesglines across the DPMS+CTS window,0new failed units (aurora-peripherals.serviceandsystemd-networkd-wait-online.servicealso fail on default),0LSM denials (0avc/apparmor/landlock/yamalines),3booterrlines (2xsystemd-gpt-auto-generatorplusauroraGPUEPROBE_DEFERat0.65 sbefore GPU came up).