[PATCH 66/76] drm/i915/gt: Update engine->breadcrumbs after virtual engine transfer

Chris Wilson chris at chris-wilson.co.uk
Tue Feb 2 09:17:05 UTC 2021


Maintain ce->engine->breadcrumbs to pointer to the physical engine after
we transfer the virtual engine to a sibling. This ensures that we always
have a stable backpointer when enabling/cancelling the breadcrumb.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_breadcrumbs.c       |  4 ++--
 .../gpu/drm/i915/gt/intel_execlists_submission.c  | 15 +++++++--------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
index 2527182b642e..d81fb7bd3eb7 100644
--- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
+++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
@@ -415,8 +415,8 @@ static void irq_signal_request(struct i915_request *rq,
 
 static void insert_breadcrumb(struct i915_request *rq)
 {
-	struct intel_breadcrumbs *b = READ_ONCE(rq->engine)->breadcrumbs;
 	struct intel_context *ce = rq->context;
+	struct intel_breadcrumbs *b = ce->engine->breadcrumbs;
 	struct list_head *pos;
 
 	if (test_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags))
@@ -501,8 +501,8 @@ bool i915_request_enable_breadcrumb(struct i915_request *rq)
 
 void i915_request_cancel_breadcrumb(struct i915_request *rq)
 {
-	struct intel_breadcrumbs *b = READ_ONCE(rq->engine)->breadcrumbs;
 	struct intel_context *ce = rq->context;
+	struct intel_breadcrumbs *b = ce->engine->breadcrumbs;
 	bool release;
 
 	spin_lock(&ce->signal_lock);
diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
index 2c02fc702ff2..d785c0aae51a 100644
--- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
+++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
@@ -996,6 +996,7 @@ static void virtual_xfer_context(struct virtual_engine *ve,
 	if (!list_empty(&ve->context.signals))
 		intel_context_remove_breadcrumbs(&ve->context,
 						 ve->siblings[0]->breadcrumbs);
+	ve->base.breadcrumbs = engine->breadcrumbs;
 
 	GEM_BUG_ON(READ_ONCE(ve->context.inflight));
 	if (!intel_engine_has_relative_mmio(engine))
@@ -3146,7 +3147,6 @@ static void rcu_virtual_context_destroy(struct work_struct *wrk)
 	lrc_fini(&ve->context);
 	intel_context_fini(&ve->context);
 
-	intel_breadcrumbs_free(ve->base.breadcrumbs);
 	intel_engine_free_request_pool(&ve->base);
 
 	kfree(ve->bonds);
@@ -3174,7 +3174,8 @@ static void virtual_context_destroy(struct kref *kref)
 	queue_rcu_work(system_wq, &ve->rcu);
 }
 
-static void virtual_engine_initial_hint(struct virtual_engine *ve)
+static struct intel_engine_cs *
+virtual_engine_initial_hint(struct virtual_engine *ve)
 {
 	int swp;
 
@@ -3194,6 +3195,8 @@ static void virtual_engine_initial_hint(struct virtual_engine *ve)
 	swp = prandom_u32_max(ve->num_siblings);
 	if (swp)
 		swap(ve->siblings[swp], ve->siblings[0]);
+
+	return ve->siblings[0];
 }
 
 static int virtual_context_alloc(struct intel_context *ce)
@@ -3445,11 +3448,6 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings,
 
 	intel_context_init(&ve->context, &ve->base);
 
-	ve->base.breadcrumbs = intel_breadcrumbs_create(NULL);
-	if (!ve->base.breadcrumbs) {
-		err = -ENOMEM;
-		goto err_put;
-	}
 
 	sched = ~0U;
 	for (n = 0; n < count; n++) {
@@ -3528,7 +3526,8 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings,
 	ve->base.sched.submit_request = i915_request_enqueue;
 	tasklet_setup(&ve->base.sched.tasklet, virtual_submission_tasklet);
 
-	virtual_engine_initial_hint(ve);
+	ve->base.breadcrumbs = virtual_engine_initial_hint(ve)->breadcrumbs;
+
 	return &ve->context;
 
 err_put:
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list