[PATCH 3/4] drm/i915/guc: Before a reset, cancel any delayed-disable-scheds

Alan Previn alan.previn.teres.alexis at intel.com
Fri Sep 9 17:07:23 UTC 2022


If a reset is required, as preparation prerequisite, ensure all
contexts that have a pending delay of disable-schedule task be
flushed of it. Irrespective of whether the GuC is still operational
or not, this lets the context fall into the "context_pending_disable"
state when scrub_guc_desc_for_outstanding_g2h is called later which
will handle the proper cleanup or re-init.

Signed-off-by: Alan Previn <alan.previn.teres.alexis at intel.com>
---
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index a3724b7238d5..bef984c585ff 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -1544,6 +1544,7 @@ static void guc_flush_submissions(struct intel_guc *guc)
 }
 
 static void guc_flush_destroyed_contexts(struct intel_guc *guc);
+static void guc_flush_all_delayed_disable_sched_contexts(struct intel_guc *guc);
 
 void intel_guc_submission_reset_prepare(struct intel_guc *guc)
 {
@@ -1561,6 +1562,7 @@ void intel_guc_submission_reset_prepare(struct intel_guc *guc)
 	spin_lock_irq(&guc_to_gt(guc)->irq_lock);
 	spin_unlock_irq(&guc_to_gt(guc)->irq_lock);
 
+	guc_flush_all_delayed_disable_sched_contexts(guc);
 	guc_flush_submissions(guc);
 	guc_flush_destroyed_contexts(guc);
 	flush_work(&guc->ct.requests.worker);
@@ -3113,6 +3115,29 @@ static void guc_context_sched_disable(struct intel_context *ce)
 	}
 }
 
+static void guc_flush_all_delayed_disable_sched_contexts(struct intel_guc *guc)
+{
+	struct intel_context *ce;
+	unsigned long index;
+	unsigned long flags;
+	unsigned long ceflags;
+
+	xa_lock_irqsave(&guc->context_lookup, flags);
+	xa_for_each(&guc->context_lookup, index, ce) {
+		if (!kref_get_unless_zero(&ce->ref))
+			continue;
+		xa_unlock(&guc->context_lookup);
+		if (cancel_delayed_work(&ce->guc_state.sched_disable_delay)) {
+			spin_lock_irqsave(&ce->guc_state.lock, ceflags);
+			spin_unlock_irqrestore(&ce->guc_state.lock, ceflags);
+			intel_context_sched_disable_unpin(ce);
+		}
+		intel_context_put(ce);
+		xa_lock(&guc->context_lookup);
+	}
+	xa_unlock_irqrestore(&guc->context_lookup, flags);
+}
+
 static void guc_context_close(struct intel_context *ce)
 {
 	unsigned long flags;
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list