From: jsg Date: Fri, 10 Feb 2023 14:27:01 +0000 (+0000) Subject: drm/i915/guc: Fix locking when searching for a hung request X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5d4146b4b020d3b4ac8fbbbd00d4d63ccf41610e;p=openbsd drm/i915/guc: Fix locking when searching for a hung request From John Harrison de997938a7a5da3cb3bd3b914456656963ca1d1c in linux-6.1.y/6.1.11 87b04e53daf806945c415e94de9f90943d434aed in mainline linux --- diff --git a/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c b/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c index 8874cb32a70..418fe6f8f98 100644 --- a/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c +++ b/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c @@ -4597,6 +4597,8 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine) xa_lock_irqsave(&guc->context_lookup, flags); xa_for_each(&guc->context_lookup, index, ce) { + bool found; + if (!kref_get_unless_zero(&ce->ref)) continue; @@ -4613,10 +4615,18 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine) goto next; } + found = false; + spin_lock(&ce->guc_state.lock); list_for_each_entry(rq, &ce->guc_state.requests, sched.link) { if (i915_test_request_state(rq) != I915_REQUEST_ACTIVE) continue; + found = true; + break; + } + spin_unlock(&ce->guc_state.lock); + + if (found) { intel_engine_set_hung_context(engine, ce); /* Can only cope with one hang at a time... */ @@ -4624,6 +4634,7 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine) xa_lock(&guc->context_lookup); goto done; } + next: intel_context_put(ce); xa_lock(&guc->context_lookup);