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

Alan Previn alan.previn.teres.alexis at intel.com
Sun Sep 4 09:33:33 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 | 29 +++++++++++++++++++
 1 file changed, 29 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..49c684332afc 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)
 {
@@ -1552,6 +1553,8 @@ void intel_guc_submission_reset_prepare(struct intel_guc *guc)
 		return;
 	}
 
+	guc_flush_all_delayed_disable_sched_contexts(guc);
+
 	intel_gt_park_heartbeats(guc_to_gt(guc));
 	disable_submission(guc);
 	guc->interrupts.disable(guc);
@@ -3113,6 +3116,32 @@ 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, ceflags;
+	intel_wakeref_t wakeref;
+	u16 guc_id;
+
+	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_sync(&ce->guc_state.sched_disable_delay)) {
+			spin_lock_irqsave(&ce->guc_state.lock, ceflags);
+			guc_id = prep_context_pending_disable(ce);
+			spin_unlock_irqrestore(&ce->guc_state.lock, ceflags);
+			with_intel_runtime_pm(&guc_to_gt(guc)->i915->runtime_pm, wakeref)
+				__guc_context_sched_disable(guc, ce, guc_id);
+		}
+
+		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