drm/i915/gt: Decouple obj<->fence reference cycles on freeing the GT pool
diff mbox series

Message ID 20200731141245.11483-1-chris@chris-wilson.co.uk
State New
Headers show
Series
  • drm/i915/gt: Decouple obj<->fence reference cycles on freeing the GT pool
Related show

Commit Message

Chris Wilson July 31, 2020, 2:12 p.m. UTC
Make sure that the obj->base.resv does not hold a reference to a fence
that itself has an active reference on the object. There is no automatic
pruning, so we must decouple such reference cycles (just in case they
exist) before discarding the pool->obj.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Chris Wilson July 31, 2020, 2:18 p.m. UTC | #1
Quoting Chris Wilson (2020-07-31 15:12:45)
> Make sure that the obj->base.resv does not hold a reference to a fence
> that itself has an active reference on the object. There is no automatic

The active reference is pruned. I was thinking of other reference cycles
that may exist, but I do not think apply to the users of the buffer
pool. There is still an advantage here in that the pruning of that
reference may be delayed, so a kick here could release the memory
faster.
-Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c b/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c
index 4b7671ac5dca..6411ebdf9468 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c
@@ -31,9 +31,18 @@  bucket_for_size(struct intel_gt_buffer_pool *pool, size_t sz)
 	return &pool->cache_list[n];
 }
 
+static void dma_resv_prune(struct dma_resv *resv)
+{
+	dma_resv_lock(resv, NULL);
+	dma_resv_add_excl_fence(resv, NULL);
+	dma_resv_unlock(resv);
+}
+
 static void node_free(struct intel_gt_buffer_pool_node *node)
 {
+	dma_resv_prune(node->obj->base.resv);
 	i915_gem_object_put(node->obj);
+
 	i915_active_fini(&node->active);
 	kfree_rcu(node, rcu);
 }