Skip to content

Fix the G17 late-completion Oops in drm_sched_job_done() - #381

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
gpu/g17-late-completion-fix
Oct 22, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
gpu/g17-late-completion-fix

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

This fixes the Oops the Neo hit on 73h during the CTS rerun, a NULL dereference in drm_sched_job_done() called from the G17 completion path (completion::Output::publish) in the events_highpri worker. After it the worker died holding a fence lock and GPU completions stopped until a reboot.

It wasn't the new timeout code itself. The Rust scheduler binding allocated its drm_gpu_scheduler with UniqueArc::new_uninit() and only cleared sched_rq before calling drm_sched_init(). drm_sched_init() never writes free_guilty, so that byte kept whatever the recycled kmalloc object had in it. clang tests it against 1 and a stale 1 is pretty common. When it hit, the first timeout on that scheduler freed the job it had just timed out, even though G17 returned NO_HANG and the job was still running. Its callback was still on the hardware fence, so when the job really finished drm_sched_job_done() ran on the freed job and hit the cleared s_fence. That matches the dump exactly, fault at s_fence->sched with the job's credits still readable.

Only jobs that outlive the 2 s watchdog ever reach that code. The ray_query.stress and position_fetch cases on stock Mesa 0.6 do, and with the bounded allowance the timeout worker runs on every poll, so every new queue got plenty of chances to land on a bad byte.

The fix zeroes the whole scheduler struct before drm_sched_init(), which also clears out the old TODO there. drm_sched_init() now sets free_guilty itself as well, so C users with recycled storage can't trip over the same thing. No G17 driver changes were needed, its completion paths were already idempotent. The scheduler just shouldn't have been freeing a running job.

Tests

  • New rust_drm_sched KUnit suite that builds schedulers in deliberately dirty storage. It covers a late completion after repeated NO_HANG timeouts, and eight jobs completing out of order under repeated timeouts with the last two cancelled by teardown before their late results land. All three fail on the old init and pass with this.
  • Isolated Asahi KUnit with lockdep and panic_on_warn, 65/65 plus the new 3/3, no lockdep or WARN output.
  • drm_sched C KUnit with panic_on_warn, 42/42.
  • Full GPU KUnit profiles u210-gpu, topup2-g and u210-gpu-pass2 at 760/760/762, which is 73h's 757/757/759 plus the new suite. Same 18 generic DRM warning sites as 73h.
  • J700 build with the 73h recipe has the same 3 inherited Kconfig warnings and nothing else, and W=1 over the scheduler, asahi and the 73h directory set is clean.
  • Neo kernel 73i (this branch on the 73h recipe) booted clean with GPU, display, Wi-Fi, Bluetooth and Touch ID all up. On stock Mesa 0.6 the ray_query stress and position_fetch group from the chunk that crashed 73h ran with no Oops and no asahi lines, tess_control triangles included at 3.5 s per case, and so did the whole 5000 case chunk. A vkp5 RT smoke went 324/326 with only the known geometry_shader.aabbs fail. 73i is now the Neo daily!

🤖 Generated with Claude Code

drm_sched_init() resets every other piece of scheduler state but leaves
free_guilty to whatever the caller's allocation held. The timeout worker
frees the job it just handled whenever free_guilty is set, so a stale
value makes the first timeout of a new scheduler free a job that is still
running, with its callback still on the hardware fence.

C drivers embed the scheduler in zeroed memory and never see this. Set it
explicitly so recycled or reinitialised storage cannot carry it over.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
drm_sched_init() expects zeroed storage. It takes a non-NULL sched_rq to
mean the scheduler is already set up, and it never writes free_guilty.
Scheduler::new() allocated SchedulerInner with UniqueArc::new_uninit()
and cleared only sched_rq, so free_guilty kept whatever the recycled
kmalloc object held there. clang tests that bool against 1, and a stale 1
byte is common in freed kernel objects.

drm_sched_job_timedout() checks free_guilty right after the timedout_job
callback. When it is set, the first timeout of the scheduler frees the job
it just timed out, even though the backend returned
DRM_GPU_SCHED_STAT_NO_HANG and the job is still on the GPU. The job's
callback stays on its hardware fence, and the late completion then runs
drm_sched_job_done() on the freed job and faults on its cleared s_fence.

That is the Neo Oops seen with stock Mesa running
dEQP-VK.ray_query.stress.tess_control_shader.triangles, a NULL dereference
at drm_sched_job_done+0x24 called from the G17 completion::Output::publish
in the events_highpri worker, after which GPU completions stopped. Those
jobs outlive the two second watchdog, and the bounded execution allowance
runs the timeout worker on every poll, so every new queue gets a chance to
hit a stale byte. Jobs that finish inside one poll never reach the timeout
worker, so only workloads that really time out can trip it.

Zero the whole drm_gpu_scheduler before drm_sched_init(), which also
retires the old TODO. Split the initialisation from the allocation so
KUnit can hand it dirty storage, and add rust_drm_sched tests for a late
completion after repeated NO_HANG timeouts and for eight jobs completing
out of order under repeated timeouts, with the last two cancelled by
teardown before their late results arrive. All three fail without this
change.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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