diff options
| author | Jagmeet Randhawa <jagmeet.randhawa@intel.com> | 2026-09-02 20:12:22 +0000 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2026-11-09 19:18:00 +1000 |
| commit | a869bd4d65bc131082568743418b3876c46c3b7b (patch) | |
| tree | 368d02e9d3daaeea47cf1af0950907cd7e5600ff /rust/kernel/alloc/kvec/errors.rs | |
| parent | e2cdad51ec53dd0f48e7f767cc1390dec69d54d4 (diff) | |
drm/xe/guc: Fix race around q->guc->suspend_pending access
q->guc->suspend_pending is accessed without any common lock.
__suspend_fence_signal(), called from guc_exec_queue_kill() and the
suspend-timeout ban path, clears the flag asynchronously. Meanwhile
handle_sched_done(), guc_exec_queue_stop() and
__guc_exec_queue_process_msg_suspend() check the flag and then call
suspend_fence_signal(), which asserts that it is still set.
As the check and suspend_fence_signal() are not atomic, the clear can
land in between and trip the xe_gt_assert(q->guc->suspend_pending).
Rather than serializing those clears, drop them. Signalling the suspend
fence from kill or from the suspend-timeout ban completes a suspend while
the queue may still be executing on the hardware, so neither is a valid
place to do it. Split the wake up out of __suspend_fence_signal() into
suspend_wait_wake() and use that in guc_exec_queue_kill(), so a waiter
still observes the killed state immediately rather than waiting out the
full timeout - guc_exec_queue_wait_suspend_done() already breaks on
exec_queue_killed(). The suspend-timeout ban needs no wake at all, as the
waiter that timed out is its caller.
suspend_pending now stays set on a killed or banned queue until it is
torn down, so relax the !suspend_pending assert in
__guc_exec_queue_resume() to permit that state.
handle_sched_done() and guc_exec_queue_stop() can still race with each
other, so take the per-queue msg_lock, which already covers the set on
the suspend path, across their check-then-act. In handle_sched_done() the
flag is snapshotted under the lock and deregister_exec_queue() is kept
outside it. __guc_exec_queue_process_msg_suspend() is left unlocked: it
runs on the scheduler message worker, which guc_exec_queue_stop() parks
via xe_sched_submission_stop() before touching the flag.
v2: Document that sched->msg_lock also protects
guc->suspend_pending, which indicates a suspend message is in
flight, in addition to the sched->msgs list (Niranjana)
v3: Drop __suspend_fence_signal() from guc_exec_queue_kill() and
guc_exec_queue_suspend_timeout_ban() rather than serializing them
with msg_lock, keeping only the wake up in kill and guarding the
!suspend_pending assert in resume (Matthew, Niranjana)
Signed-off-by: Jagmeet Randhawa <jagmeet.randhawa@intel.com>
Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260902201222.30022-1-jagmeet.randhawa@intel.com
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'rust/kernel/alloc/kvec/errors.rs')
0 files changed, 0 insertions, 0 deletions
