[PATCH 5/5] haxup

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Tue Jul 6 10:28:16 UTC 2021


Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
 drivers/gpu/drm/i915/gt/intel_context.c | 15 +--------------
 drivers/gpu/drm/i915/gt/intel_context.h | 21 ++++++++++++++-------
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
index b5f7c4a80c3e..7842f97bddb9 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -92,13 +92,6 @@ static int intel_context_active_acquire(struct intel_context *ce)
 	return err;
 }
 
-static void intel_context_active_release(struct intel_context *ce)
-{
-	/* Nodes preallocated in intel_context_active() */
-	i915_active_acquire_barrier(&ce->active);
-	i915_active_release(&ce->active);
-}
-
 static int __context_pin_state(struct i915_vma *vma, struct i915_gem_ww_ctx *ww)
 {
 	unsigned int bias = i915_ggtt_pin_bias(vma) | PIN_OFFSET_BIAS;
@@ -285,13 +278,7 @@ void intel_context_unpin(struct intel_context *ce)
 {
 	CE_TRACE(ce, "unpin\n");
 
-	/*
-	 * Once released, we may asynchronously drop the active reference.
-	 * As that may be the only reference keeping the context alive,
-	 * take an extra now so that it is not freed before we finish
-	 * dereferencing it.
-	 */
-	intel_context_active_release(ce);
+	i915_active_release(&ce->active);
 }
 
 static void __intel_context_retire(struct i915_active *active)
diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h
index 9bed8cd387d5..ab2c22815280 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -90,10 +90,20 @@ static inline bool intel_context_pin_if_active(struct intel_context *ce)
 	return i915_active_acquire_if_busy(&ce->active);
 }
 
+static inline bool intel_context_is_barrier(const struct intel_context *ce)
+{
+	return test_bit(CONTEXT_BARRIER_BIT, &ce->flags);
+}
+
 static inline int intel_context_pin(struct intel_context *ce)
 {
 	if (likely(intel_context_pin_if_active(ce))) {
-		int err = i915_active_acquire_preallocate_barrier(&ce->active,
+		int err;
+
+		if (intel_context_is_barrier(ce))
+			return 0;
+
+		err = i915_active_acquire_preallocate_barrier(&ce->active,
 								  ce->engine);
 
 		if (err)
@@ -141,8 +151,10 @@ static inline void intel_context_exit(struct intel_context *ce)
 {
 	lockdep_assert_held(&ce->timeline->mutex);
 	GEM_BUG_ON(!ce->active_count);
-	if (!--ce->active_count)
+	if (!--ce->active_count) {
 		ce->ops->exit(ce);
+		i915_active_acquire_barrier(&ce->active);
+	}
 }
 
 static inline struct intel_context *intel_context_get(struct intel_context *ce)
@@ -186,11 +198,6 @@ static inline struct intel_ring *__intel_context_ring_size(u64 sz)
 	return u64_to_ptr(struct intel_ring, sz);
 }
 
-static inline bool intel_context_is_barrier(const struct intel_context *ce)
-{
-	return test_bit(CONTEXT_BARRIER_BIT, &ce->flags);
-}
-
 static inline bool intel_context_is_closed(const struct intel_context *ce)
 {
 	return test_bit(CONTEXT_CLOSED_BIT, &ce->flags);
-- 
2.31.0



More information about the Intel-gfx-trybot mailing list