[PATCH 22/22] drm/i915: Remove i915_vma->active

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Thu Nov 25 13:50:50 UTC 2021


XXX: This breaks tests because i915_active keeps a reference to the object alive.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
 drivers/gpu/drm/i915/gt/intel_context.c | 43 ++-----------------------
 drivers/gpu/drm/i915/i915_gpu_error.c   |  9 +++---
 drivers/gpu/drm/i915/i915_vma.c         | 41 ++---------------------
 drivers/gpu/drm/i915/i915_vma_types.h   |  2 --
 4 files changed, 9 insertions(+), 86 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
index 268c51f886b0..efc96ca1bd5d 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -107,10 +107,6 @@ static int __context_pin_state(struct i915_vma *vma, struct i915_gem_ww_ctx *ww)
 	if (err)
 		return err;
 
-	err = i915_active_acquire(&vma->active);
-	if (err)
-		goto err_unpin;
-
 	/*
 	 * And mark it as a globally pinned object to let the shrinker know
 	 * it cannot reclaim the object until we release it.
@@ -119,45 +115,14 @@ static int __context_pin_state(struct i915_vma *vma, struct i915_gem_ww_ctx *ww)
 	vma->obj->mm.dirty = true;
 
 	return 0;
-
-err_unpin:
-	i915_vma_unpin(vma);
-	return err;
 }
 
 static void __context_unpin_state(struct i915_vma *vma)
 {
 	i915_vma_make_shrinkable(vma);
-	i915_active_release(&vma->active);
 	__i915_vma_unpin(vma);
 }
 
-static int __ring_active(struct intel_ring *ring,
-			 struct i915_gem_ww_ctx *ww)
-{
-	int err;
-
-	err = intel_ring_pin(ring, ww);
-	if (err)
-		return err;
-
-	err = i915_active_acquire(&ring->vma->active);
-	if (err)
-		goto err_pin;
-
-	return 0;
-
-err_pin:
-	intel_ring_unpin(ring);
-	return err;
-}
-
-static void __ring_retire(struct intel_ring *ring)
-{
-	i915_active_release(&ring->vma->active);
-	intel_ring_unpin(ring);
-}
-
 static int intel_context_pre_pin(struct intel_context *ce,
 				 struct i915_gem_ww_ctx *ww)
 {
@@ -165,7 +130,7 @@ static int intel_context_pre_pin(struct intel_context *ce,
 
 	CE_TRACE(ce, "active\n");
 
-	err = __ring_active(ce->ring, ww);
+	err = intel_ring_pin(ce->ring, ww);
 	if (err)
 		return err;
 
@@ -186,7 +151,7 @@ static int intel_context_pre_pin(struct intel_context *ce,
 err_timeline:
 	intel_timeline_unpin(ce->timeline);
 err_ring:
-	__ring_retire(ce->ring);
+	intel_ring_unpin(ce->ring);
 	return err;
 }
 
@@ -196,7 +161,7 @@ static void intel_context_post_unpin(struct intel_context *ce)
 		__context_unpin_state(ce->state);
 
 	intel_timeline_unpin(ce->timeline);
-	__ring_retire(ce->ring);
+	intel_ring_unpin(ce->ring);
 }
 
 int __intel_context_do_pin_ww(struct intel_context *ce,
@@ -350,13 +315,11 @@ static int __intel_context_active(struct i915_active *active)
 	intel_context_get(ce);
 
 	/* everything should already be activated by intel_context_pre_pin() */
-	GEM_WARN_ON(!i915_active_acquire_if_busy(&ce->ring->vma->active));
 	__intel_ring_pin(ce->ring);
 
 	__intel_timeline_pin(ce->timeline);
 
 	if (ce->state) {
-		GEM_WARN_ON(!i915_active_acquire_if_busy(&ce->state->active));
 		__i915_vma_pin(ce->state);
 		i915_vma_make_unshrinkable(ce->state);
 	}
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 2a2d7643b551..46f55ca8b77f 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1339,10 +1339,8 @@ capture_vma(struct intel_engine_capture_vma *next,
 	if (!c)
 		return next;
 
-	if (!i915_active_acquire_if_busy(&vma->active)) {
-		kfree(c);
-		return next;
-	}
+	__i915_vma_get(vma);
+	i915_vma_get(vma);
 
 	strcpy(c->name, name);
 	c->vma = vma; /* reference held while active */
@@ -1434,7 +1432,8 @@ intel_engine_coredump_add_vma(struct intel_engine_coredump *ee,
 						 vma, this->name,
 						 compress));
 
-		i915_active_release(&vma->active);
+		__i915_vma_put(vma);
+		i915_vma_put(vma);
 
 		capture = this->next;
 		kfree(this);
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index a62cf19a51c9..fe87f1138451 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -77,21 +77,6 @@ static void vma_print_allocator(struct i915_vma *vma, const char *reason)
 
 #endif
 
-static inline struct i915_vma *active_to_vma(struct i915_active *ref)
-{
-	return container_of(ref, typeof(struct i915_vma), active);
-}
-
-static int __i915_vma_active(struct i915_active *ref)
-{
-	return i915_vma_tryget(active_to_vma(ref)) ? 0 : -ENOENT;
-}
-
-static void __i915_vma_retire(struct i915_active *ref)
-{
-	i915_vma_put(active_to_vma(ref));
-}
-
 static struct i915_vma *
 vma_create(struct drm_i915_gem_object *obj,
 	   struct i915_address_space *vm,
@@ -115,15 +100,6 @@ vma_create(struct drm_i915_gem_object *obj,
 	vma->size = obj->base.size;
 	vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
 
-	i915_active_init(&vma->active, __i915_vma_active, __i915_vma_retire, 0);
-
-	/* Declare ourselves safe for use inside shrinkers */
-	if (IS_ENABLED(CONFIG_LOCKDEP)) {
-		fs_reclaim_acquire(GFP_KERNEL);
-		might_lock(&vma->active.mutex);
-		fs_reclaim_release(GFP_KERNEL);
-	}
-
 	INIT_LIST_HEAD(&vma->closed_link);
 
 	if (view && view->type != I915_GGTT_VIEW_NORMAL) {
@@ -1354,14 +1330,10 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 		goto err_unlock;
 	}
 
-	err = i915_active_acquire(&vma->active);
-	if (err)
-		goto err_unlock;
-
 	if (!(bound & I915_VMA_BIND_MASK)) {
 		err = i915_vma_insert(vma, ww, size, alignment, flags);
 		if (err)
-			goto err_active;
+			goto err_unlock;
 
 		if (i915_is_ggtt(vma->vm))
 			__i915_vma_set_map_and_fenceable(vma);
@@ -1391,8 +1363,6 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 		i915_vma_detach(vma);
 		drm_mm_remove_node(&vma->node);
 	}
-err_active:
-	i915_active_release(&vma->active);
 err_unlock:
 	mutex_unlock(&vma->vm->mutex);
 err_fence:
@@ -1546,7 +1516,6 @@ void i915_vma_release(struct kref *ref)
 	__i915_vma_remove_closed(vma);
 	i915_vm_put(vma->vm);
 
-	i915_active_fini(&vma->active);
 	i915_vma_free(vma);
 }
 
@@ -1646,14 +1615,8 @@ __i915_request_await_bind(struct i915_request *rq, struct i915_vma *vma)
 
 static int __i915_vma_move_to_active(struct i915_vma *vma, struct i915_request *rq)
 {
-	int err;
-
 	/* Wait for the vma to be bound before we start! */
-	err = __i915_request_await_bind(rq, vma);
-	if (err)
-		return err;
-
-	return i915_active_add_request(&vma->active, rq);
+	return __i915_request_await_bind(rq, vma);
 }
 
 int _i915_vma_move_to_active(struct i915_vma *vma,
diff --git a/drivers/gpu/drm/i915/i915_vma_types.h b/drivers/gpu/drm/i915/i915_vma_types.h
index ca575e129ced..20a0d3a6c408 100644
--- a/drivers/gpu/drm/i915/i915_vma_types.h
+++ b/drivers/gpu/drm/i915/i915_vma_types.h
@@ -265,8 +265,6 @@ struct i915_vma {
 #define I915_VMA_SCANOUT_BIT	18
 #define I915_VMA_SCANOUT	((int)BIT(I915_VMA_SCANOUT_BIT))
 
-	struct i915_active active;
-
 #define I915_VMA_PAGES_BIAS 24
 #define I915_VMA_PAGES_ACTIVE (BIT(24) | 1)
 	atomic_t pages_count; /* number of active binds to the pages */
-- 
2.34.0



More information about the Intel-gfx-trybot mailing list