drm/i915/gt: Hook up intel_context_fini()
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 18 Jul 2019 07:00:06 +0000 (08:00 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 22 Jul 2019 22:20:07 +0000 (23:20 +0100)
Prior to freeing the struct, call the fini function to cleanup the
common members. Currently this only calls the debug functions to mark
the structs as destroyed, but may be extended to real work in future.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190718070024.21781-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gt/intel_context.c
drivers/gpu/drm/i915/gt/intel_context.h
drivers/gpu/drm/i915/gt/intel_lrc.c
drivers/gpu/drm/i915/gt/intel_ringbuffer.c
drivers/gpu/drm/i915/gt/mock_engine.c

index b667e2b358041a032859b267f08bae3a01136d1d..9292b6ca5e9cd7e6de263c482a8fd076d80e57cf 100644 (file)
@@ -204,6 +204,12 @@ intel_context_init(struct intel_context *ce,
                         __intel_context_active, __intel_context_retire);
 }
 
+void intel_context_fini(struct intel_context *ce)
+{
+       mutex_destroy(&ce->pin_mutex);
+       i915_active_fini(&ce->active);
+}
+
 static void i915_global_context_shrink(void)
 {
        kmem_cache_shrink(global.slab_ce);
index b41c610c2ce6a1479ae1f8f77e54a8128f869a95..23c7e4c0ce7cad3a6c25d203c344ee62155a8e09 100644 (file)
@@ -16,6 +16,7 @@
 void intel_context_init(struct intel_context *ce,
                        struct i915_gem_context *ctx,
                        struct intel_engine_cs *engine);
+void intel_context_fini(struct intel_context *ce);
 
 struct intel_context *
 intel_context_create(struct i915_gem_context *ctx,
index dce36482a252eac4d57405e4a94ac03234ae9bac..884dfc1cb03385d438b57f00241f50e3dd0d55b8 100644 (file)
@@ -1566,6 +1566,7 @@ static void execlists_context_destroy(struct kref *kref)
        if (ce->state)
                __execlists_context_fini(ce);
 
+       intel_context_fini(ce);
        intel_context_free(ce);
 }
 
@@ -3199,6 +3200,7 @@ static void virtual_context_destroy(struct kref *kref)
 
        if (ve->context.state)
                __execlists_context_fini(&ve->context);
+       intel_context_fini(&ve->context);
 
        kfree(ve->bonds);
        kfree(ve);
index 213df144be15266f9c6051f3d44da61bf6cb4209..1de19dac4a14462dd467923fe19e4bb00f7a5869 100644 (file)
@@ -1388,6 +1388,7 @@ static void ring_context_destroy(struct kref *ref)
        if (ce->state)
                __ring_context_fini(ce);
 
+       intel_context_fini(ce);
        intel_context_free(ce);
 }
 
index 490ebd121f4c99878b18d324352d77344d8fbe05..10cb312462e53d887b410d5664a8cfbc5c3cf49d 100644 (file)
@@ -142,6 +142,7 @@ static void mock_context_destroy(struct kref *ref)
        if (ce->ring)
                mock_ring_free(ce->ring);
 
+       intel_context_fini(ce);
        intel_context_free(ce);
 }