Repository navigation
drm/asahi: g17: set an output fence's error and signal it under its lock - #3311
Conversation
Submission::member_done() sets the submit's output fence error with dma_fence_set_error() and then signals the fence in a separate call. That assumes the last member is the only thing that ever signals the fence. When something else signals it first, the error lands on a fence whose waiters already saw a result, and dma_fence_set_error() WARNs at include/linux/dma-fence.h:695. That is the WARN in linux#3278. The M5 perf kernels that hit it (7.3.0-m5-cdirect14 to cdirect16) add an early completion path in a bottom half. Once the stamp of a submit's only remaining command lands, it signals the output fence before that command retires. If the queue is destroyed in that window, drm_sched_fini() cancels the unretired job and fail_while_owned(ECANCELED) completes the last member, so member_done() sets an error on the signalled fence. The early signal also checks the submission state and then signals without a lock, so it can race a member that fails at the same time. On main, member_done() is the only signaller. Every copy of this WARN in the lab logs comes from those three kernels. Do both steps in one pass under the fence lock, in a new asahi_g17_finish_fence() helper. If the fence is still unsignalled, it sets the error and signals. If it already signalled, it leaves the result alone. The fence lock is the lock dma_fence_signal() itself takes, so the error can no longer follow or race any signal. A scoped output still drains its ready queue scopes. asahi_g17_signal_fence() now calls the same helper with no error, so it behaves as before. Add tools/asahi/g17-output-fence-tests.py. It compiles the real Submission, Aggregate and Member code and the new helper against a host dma_fence model that keeps the WARN. It replays the linux#3278 sequence: one command left, an early signal, then a cancel. It also lands the early signal just before the member takes the lock, and runs the two on separate threads. Three mutations must fail it: the old member_done(), setting the error on a signalled fence, and testing the signalled bit outside the lock. Closes: #3278 Signed-off-by: DjDeveloperr <[email protected]>
|
Non-author review at Checked
Not blocking: Before merge:
Merging is left to the PR Merge Lane. |
|
J714s (MacBook Pro 14" M5 Pro, G17S B1) second-generation row at exact head
1. Kill stress: 180 s with 12 workers.
2. CTS mix at 16 jobs (
3. Whole boot: 0 WARN/BUG/Oops, 0 GPU MMU faults and 0 G17 recoveries. There is one distinct error-level line ( Not run here: a |
|
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 <[email protected]>
There was a problem hiding this comment.
Code approved at the reviewed head. The shared helper checks signal state, sets the error and signals under the same DMA-fence lock. Scoped completion callbacks still drain after that lock is released. The reported J700 cancellation stress supports the change. Keep current-head CI and the J714s cdirect cancellation row as merge gates.
|
code-owner ping @DjDeveloperr: closeout merge of your PR at |
Forward-merge main. Only the run-host-tests.py registry conflicted: main extended the g17-object-fence-tests mutation list, this branch registers g17-output-fence-tests after it. Keep main's list and add the new entry. Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged main into this branch (merge commit 07b335c, no force push). Only the tools/asahi/run-host-tests.py registry conflicted: main extended the g17-object-fence-tests mutation list, and this branch adds the g17-output-fence-tests entry after it. The merge keeps main's list and adds your entry. Driver files (fence.rs, sync_scope.c/.h) merged cleanly and are unchanged. |
There was a problem hiding this comment.
Verdict: MERGE at 07b335c
Checked: The registry resolution keeps the object-fence mutation cases and adds the separate output-fence entry. Fence error and signaling still share the lock, with callbacks drained outside it. Keep exact CI and J714s cdirect cancellation.
|
code-owner ping @DjDeveloperr: closeout merge at |
|
J716c (16-inch M5 Max, G17C) at EvidenceBatched kernel Vulkan CTS with Borealis 0 DART faults. Kernel errors are the same set as the default boot; failed units: |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
|
I reproduced this locally on a merge of main; main's own |
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]>
What: Set a submit's output fence error and signal the fence in one step, under the fence lock. If the fence has already signalled, keep that result. This fixes the
dma_fence_set_error()WARN atinclude/linux/dma-fence.h:695that fires when a queue with cancelled jobs is destroyed. Fixes #3278Tested: Neo J700 at
27a5185, two one-shot boots of7.3.0-neo-fix3278, both returned to stock -41. Results: 2,580 deqp-vk processes killed mid-run with live queues (51 outputs cancelled throughmember_done()), then a CTS smoke over the #3278 groups: 3,777 Pass, 1,060 NotSupported, 0 fail. 0 WARN/BUG, 0 GPU faults, 0 AVC. Host: the g17 host tests pass 224/224, the new test passes, and its three mutations all fail as they should.Risk: two-way · G17P / M5 (shared g17 fence/completion path): Neo J700 and M5 J714s. The output-fence path is shared by every G17 submit. On main the result is the same as before, because
member_done()is still the only thing that signals the fence. A revert restores the two-call version.Not yet: the J714s row. It is the second-generation row for shared g17 code, and it is the only Mac that hits #3278. It needs a cdirect kernel rebased onto this change (see Evidence), then the #3278 CTS mix with 16 jobs, checking for no WARN.
Details
Who signals the fence first.
Submission::member_done()used to calldma_fence_set_error()and then signal in a separate call. That only works if the last member is the only thing that ever signals the output fence. On main it is. The kernels that hit the WARN are7.3.0-m5-cdirect14,cdirect15andcdirect16, built from the localperf/m5-cdirect*branches. They carryg17/fast_signal.rs(947f9742a168, "bottom-half early completion signalling for M5 compute"). When the stamp of a submit's only remaining command lands, that bottom half signals the output fence. It checksremaining == 1,error == 0and not signalled, and it neither completes the member nor claims theCompletion. The command then waits for the event worker to retire it. If userspace destroys the queue in that window (deqp-vk does after each wait),drm_sched_fini()cancels the unretired job.Backend::cancel()then runsfail_while_owned(ECANCELED), which completes the last member, andmember_done()sets an error on the signalled fence. That is the trace in #3278. The bottom half also checks the submission state under its own table lock but signals after dropping it. So a member failing at the same moment could also set the error after the signal.Every copy of this WARN in the lab logs (43 log files, J714s rows from 11-24 to 11-26) is on
cdirect14,cdirect15orcdirect16. None is on a Neo, M4, M3 or pre-cdirect M5 kernel.The ComputeReserve refusals before the WARN are capacity pressure from 16 parallel deqp-vk jobs. A refused compute command waits in admission unpublished, and a cancel completes it through
fail_unpublished(). The WARN in #3278 comes throughfail_while_owned(), which means a published command.The change. The new helper
asahi_g17_finish_fence(fence, error, scoped)ing17/sync_scope.ctakes the fence lock and checks the signalled bit. If the fence is still unsignalled, it sets the error and callsdma_fence_signal_locked().dma_fence_signal()takes that same lock to set the bit, so no signal can come between the check and the error. A fence that already signalled keeps the result its waiters saw. Here that is the success the bottom half witnessed, so the lateECANCELEDof a completed command is dropped. Scoped outputs still drain their ready queue scopes.asahi_g17_signal_fence(), also used by g16, is now the same helper with no error.member_done()keeps its trace point, and it still releases the submission state on success and through the last owner on failure.With this change the cdirect bottom half needs no extra claim. Its signal and
member_done()now both decide under the fence lock.Evidence
7.3.0-neo-fix3278, kit built from27a5185with the Neo-41config, one-shotgrub2-reboot,saved_entryleft at -41). Each boot returned to -41 with the kit removed;/boot, ESP,/lib/modules, BLS, rpm list and grubenv are identical to before;stock.shis the same at start and end; PMU boot-error count 00 throughout. Holds: 18:18–18:24 and 18:39–18:46 EST.deqp-vkon random cases from the drm/asahi: g17: dma_fence_set_error() on an already-signalled fence when a queue with cancelled jobs is destroyed (WARN dma-fence.h:695, J714s) #3278 groups and sent it SIGKILL 0.25–2 s in, so its queues were destroyed while they still held queued, waiting or running jobs. Failed outputs were counted with theasahi_g17_outputtracepoint, filtered toresult != 0. Fix kernel: 981 kills with 51-ECANCELEDoutputs, then 1,599 kills. Stock -41: 503 kills with 21-ECANCELED, then 615 kills. A triangle health check passes after every pass.gate.py --jobs 6: up to 250 cases per subgroup from the drm/asahi: g17: dma_fence_set_error() on an already-signalled fence when a queue with cancelled jobs is destroyed (WARN dma-fence.h:695, J714s) #3278 groups (api.smoke,binding_model.*push_descriptor,compute,fragment_operations.early_fragment,glsl.atomic_operations,glsl.loops,pipeline.*push_constant,ssbo.layout,ubo,synchronization.timeline_semaphore), withoutcooperative_matrix. 4,837 of 4,837 recorded: 3,777 Pass, 1,060 NotSupported, 0 other.WARNING:/BUG:/Oops/Call tracelines;kfaults.shhas fault pattern 0 and GPU-side 0; AVC 0 over the whole boot. The only flagged line isworkqueue: Failed to create a rescuer kthread for wq "aurora_g17_compute": -EINTR(listed as excluded), followed bysubmit failed … ENOMEM. It comes from SIGKILL landing while a queue is being created. Stock -41 logged it 14 times in the row 1 stock stress (the fix kernel: 2, then 3), so it is not new. No capacity refusals on the Neo.python3 -I tools/asahi/run-host-tests.py --jobs 6 --only g17: 224/224 passed (CIhost-tests, which runs every host test, passes too), includingg17-output-fence-tests(1.4 s) and its--mutation unlocked-member-done,set-error-when-signalledandcheck-outside-lockruns. Each of those three panics (exit 101) on a counteddma_fence_set_error()WARN. The oldmember_done()andset-error-when-signalledfail on the drm/asahi: g17: dma_fence_set_error() on an already-signalled fence when a queue with cancelled jobs is destroyed (WARN dma-fence.h:695, J714s) #3278 sequence.check-outside-lockfails when the early signal lands just before the member takes the lock. In the two-thread race (9,409 rounds), the early signal wins about 7,400 times and the cancel about 2,000 times, with 0 WARNs. In every round the error waiters read equals the error at signal time.scripts/checkpatch.pl -g HEAD: 0 errors. The one warning is the usual MAINTAINERS note for a newtools/asahifile.rustfmt --checkong17/fence.rsshows the same four older diffs asmain, none on changed lines.rg "WARNING: include/linux/dma-fence.h:695"over the lab logs (work/) finds 43 files. Every one that names its kernel is7.3.0-m5-cdirect14,cdirect15orcdirect16, all J714s.b130c950a65c(perf/m5-cdirect15) with a 3-way merge. That branch'sfence::signal_exported_raw()also callsasahi_g17_signal_fence, so keep that function'sexterndeclaration there, or switch the call toasahi_g17_finish_fence(fence, 0, true).