Skip to content

drm/asahi: keep work-queue firmware structures until the context is invalidated - #601

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
conv/asahi-wq-lifetime
Oct 30, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
conv/asahi-wq-lifetime

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

This carries d5ee0bd from aurora-wip onto integration/aurora, as part of converging the two kernel lines.

A queue destroyed with jobs still on the GPU dropped its work queues' firmware structures (queue info, ring, notifier list) and its notifier as soon as the last stamp was seen. The GPU context those structures belong to is only invalidated at the next alloc(), so until then the firmware could still refer to memory that had been handed out again. A GpuContext now keeps these objects until DestroyContext has completed. This is the same thing the context data already does for the tile vertex buffer.

The original commit says so too: this closes the window for those two objects, but on its own it does not stop the sustained-teardown firmware crash on the M1 Pro (G13X). At least one other object on that path is still read after it is freed.

Testing

  • Picks cleanly onto 695d974. The build of the convergence stack (this and the other four convergence PRs on 695d974, shipping recipe: Fedora Asahi base + asahi.config + olddefconfig) is queued on the buildbox. I will add the result here as a comment.
  • Not yet booted on integration/aurora. Before it merges here it needs a boot plus a GPU workload with repeated queue teardown on the M1 Pro (G13X), and a no-regression check on the M2 (G14). G17 (Neo, J616s) does not use this path.

🤖 Generated with Claude Code

…nvalidated

When a queue is destroyed while it still has jobs on the GPU,
drm_sched_fini() cancels the scheduler jobs, but the firmware keeps
running the commands it already holds. Each work queue then stays alive
only through its event slot and is dropped from the completion path as
soon as its last stamp is seen. Dropping it frees its queue info (ring
state, ring and notifier list), and the last command frees the queue's
notifier and threshold. Those come from the shared and private kernel
allocators, so the memory can be reused right away. The GPU context that
the firmware still associates those structures with is only invalidated
at the next alloc(), so until then the firmware can still refer to a
work queue whose memory has already been handed out.

The context data already keeps the tile vertex buffer alive until it is
invalidated. Do the same for the queue structures. A GpuContext now
keeps a list of retained objects. A work queue moves its queue info
there when it is dropped, and the queue adds its notifier when it is
created. The list travels with the context data to the garbage list and
is freed once DestroyContext has completed. The queue info points to the
context weakly now, since the context owns it from then on.

This closes the lifetime window for those two objects. On its own it
does not stop the sustained-teardown firmware crash on the M1 Pro
(G13X): that crash still reproduces with this change, so at least one
other kernel object on the teardown path is read by the firmware after
it is freed and reused. Investigation continues.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit d5ee0bd)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The convergence stack build is still waiting for a buildbox slot, because every slot is busy with other builds. It is buildbox /srv/aurora/fast/o/conv-20261030/conv-build-stack.sh on branch conv/stack (all five convergence commits on 695d974). The result goes to stack-run.log in that directory, ending with BUILD-RC <n>. Do not merge this before that shows 0 and the boot test in the description has passed.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The stack build passed: BUILD-RC 0. It built branch conv/stack at 1ab07a86a030, which is all five convergence commits (#600 to #604) on integration/aurora 695d974. The config is the shipping recipe (Fedora Asahi base + asahi.config + olddefconfig) plus CONFIG_DRM_ASAHI_G15=y, so the G15 adapter in #602 was compiled too. It built Image, modules and dtbs as 7.3.0-aurora-conv, with clang/LLVM and the corrected bindgen 0.73.2. None of the touched files (apple-sio, hci_bcm4377, drm/asahi workqueue/g15) gave a warning. The only warning in the whole build is the existing unused MM static in drivers/gpu/drm/asahi/memacct.rs, which none of these commits touch. The SIO KUnit cases were not run, because they need APPLE_SIO=y and the shipping recipe builds SIO as a module. What is still needed before merging is the boot test in the description.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Boot-tested in fleet10 (7.3.0-aurora-fleet10): integration/aurora 1173b79 plus 587, 588, 589, 590, 596, 599, 600, 601, 603, 604, 605, 607 and 608, built with the shipping recipe (Fedora Asahi base + asahi.config, 0 mismatches, all distro gates). apple-dcp host selftests 80/80, and the other host tests match integration/aurora exactly (62 pass, the same 26 pre-existing failures). One-shot boots on the Neo (J700), the M2 and the M1 Pro, compared with each machine's fleet9 boot; fleet10 is now the default on all three. Full dmesg and journals are in aurora-ctl reports/fleet10-20261030.

Result for this PR: pass.

  • M1 Pro (G13X): glmark2 under Zink and native (5269 / 8164), vkcube 300 frames, then 40 back-to-back vkcube runs that each create and destroy their queues. 40/40 clean, 0 asahi kernel errors.
  • M2 (G14): the same smoke, 30/30 vkcube runs, 0 errors.
  • Neo (G17) does not use this path; Vulkan (Borealis) up there.

@RyanTheTide
RyanTheTide merged commit fa4dc76 into integration/aurora Oct 30, 2026
@RyanTheTide
RyanTheTide deleted the conv/asahi-wq-lifetime branch October 30, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant