[PATCH] drm/i915/gt: Warn more clearly if the context state is still pinned

Chris Wilson chris at chris-wilson.co.uk
Wed Apr 22 21:54:52 UTC 2020


When recording the default context state, we submit an ordinary context
and then steal the context image for our defaults. To be able to steal
the state, we must have total ownership of the context. During CI we
want to make this error extremely obvious, as otherwise we will fail the
user's module load.

References: https://gitlab.freedesktop.org/drm/intel/-/issues/1763
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_gt.c          | 2 ++
 drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c
index 1c99cc72305a..c7dd4a6380bb 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -379,6 +379,7 @@ static int __intel_context_flush_retire(struct intel_context *ce)
 		return PTR_ERR(tl);
 
 	intel_context_timeline_unlock(tl);
+
 	return 0;
 }
 
@@ -472,6 +473,7 @@ static int __engines_record_defaults(struct intel_gt *gt)
 
 		/* We want to be able to unbind the state from the GGTT */
 		GEM_BUG_ON(intel_context_is_pinned(rq->context));
+		GEM_BUG_ON(i915_vma_is_pinned(state));
 
 		/*
 		 * As we will hold a reference to the logical state, it will
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
index dec96a731a77..22a8fa69fccd 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
@@ -39,6 +39,7 @@ static bool flush_submission(struct intel_gt *gt)
 		intel_engine_flush_submission(engine);
 		active |= flush_work(&engine->retire_work);
 		active |= flush_delayed_work(&engine->wakeref.work);
+		active |= i915_active_fence_isset(&engine->kernel_context->timeline->last_request);
 	}
 
 	return active;
@@ -173,7 +174,6 @@ out_active:	spin_lock(&timelines->lock);
 		if (atomic_dec_and_test(&tl->active_count))
 			list_del(&tl->link);
 
-
 		/* Defer the final release to after the spinlock */
 		if (refcount_dec_and_test(&tl->kref.refcount)) {
 			GEM_BUG_ON(atomic_read(&tl->active_count));
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list