Skip to content

Commit 87b04e5

Browse files
johnharr-intelrodrigovivi
authored andcommitted
drm/i915/guc: Fix locking when searching for a hung request
intel_guc_find_hung_context() was not acquiring the correct spinlock before searching the request list. So fix that up. While at it, add some extra whitespace padding for readability. Fixes: dc0dad3 ("drm/i915/guc: Fix for error capture after full GPU reset with GuC") Signed-off-by: John Harrison <[email protected]> Reviewed-by: Daniele Ceraolo Spurio <[email protected]> Acked-by: Tvrtko Ursulin <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Joonas Lahtinen <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Matt Roper <[email protected]> Cc: Umesh Nerlige Ramappa <[email protected]> Cc: Michael Cheng <[email protected]> Cc: Lucas De Marchi <[email protected]> Cc: Tejas Upadhyay <[email protected]> Cc: Chris Wilson <[email protected]> Cc: Bruce Chang <[email protected]> Cc: Alan Previn <[email protected]> Cc: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit d1c3717) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 41d4193 commit 87b04e5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4817,6 +4817,8 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
48174817

48184818
xa_lock_irqsave(&guc->context_lookup, flags);
48194819
xa_for_each(&guc->context_lookup, index, ce) {
4820+
bool found;
4821+
48204822
if (!kref_get_unless_zero(&ce->ref))
48214823
continue;
48224824

@@ -4833,17 +4835,26 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
48334835
goto next;
48344836
}
48354837

4838+
found = false;
4839+
spin_lock(&ce->guc_state.lock);
48364840
list_for_each_entry(rq, &ce->guc_state.requests, sched.link) {
48374841
if (i915_test_request_state(rq) != I915_REQUEST_ACTIVE)
48384842
continue;
48394843

4844+
found = true;
4845+
break;
4846+
}
4847+
spin_unlock(&ce->guc_state.lock);
4848+
4849+
if (found) {
48404850
intel_engine_set_hung_context(engine, ce);
48414851

48424852
/* Can only cope with one hang at a time... */
48434853
intel_context_put(ce);
48444854
xa_lock(&guc->context_lookup);
48454855
goto done;
48464856
}
4857+
48474858
next:
48484859
intel_context_put(ce);
48494860
xa_lock(&guc->context_lookup);

0 commit comments

Comments
 (0)