drm/i915: Pull the context->pin_count dec into the common intel_context_unpin
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 17 May 2018 21:26:33 +0000 (22:26 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 18 May 2018 08:35:28 +0000 (09:35 +0100)
As all backends implement the same pin_count mechanism and do a
dec-and-test as their first step, pull that into the common
intel_context_unpin(). This also pulls into the caller, eliminating the
indirect call in the usual steady state case. The intel_context_pin()
side is a little more complicated as it combines the lookup/alloc as
well as pinning the state, and so is left for a later date.

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

index 749a4ff566f5b6af887c6e496af083a087b57935..c3262b4dd2ee6b13f3c0def27c126bfee08b678c 100644 (file)
@@ -285,6 +285,10 @@ static inline void __intel_context_pin(struct intel_context *ce)
 
 static inline void intel_context_unpin(struct intel_context *ce)
 {
+       GEM_BUG_ON(!ce->pin_count);
+       if (--ce->pin_count)
+               return;
+
        GEM_BUG_ON(!ce->ops);
        ce->ops->unpin(ce);
 }
index b97c5d4c7877c078f0030b7030221a3be72225b3..9abd26f22b477c8344b9ab0a49234d6d5a86bf0d 100644 (file)
@@ -1343,7 +1343,7 @@ static void execlists_context_destroy(struct intel_context *ce)
        __i915_gem_object_release_unless_active(ce->state->obj);
 }
 
-static void __execlists_context_unpin(struct intel_context *ce)
+static void execlists_context_unpin(struct intel_context *ce)
 {
        intel_ring_unpin(ce->ring);
 
@@ -1354,17 +1354,6 @@ static void __execlists_context_unpin(struct intel_context *ce)
        i915_gem_context_put(ce->gem_context);
 }
 
-static void execlists_context_unpin(struct intel_context *ce)
-{
-       lockdep_assert_held(&ce->gem_context->i915->drm.struct_mutex);
-       GEM_BUG_ON(ce->pin_count == 0);
-
-       if (--ce->pin_count)
-               return;
-
-       __execlists_context_unpin(ce);
-}
-
 static int __context_pin(struct i915_gem_context *ctx, struct i915_vma *vma)
 {
        unsigned int flags;
index 0c0c9f531e4ecad3e48313e7cc9d7af6fd78b961..001cf6bcb34974817e9d437a2be2323c003eacdc 100644 (file)
@@ -1195,12 +1195,6 @@ static void intel_ring_context_destroy(struct intel_context *ce)
 
 static void intel_ring_context_unpin(struct intel_context *ce)
 {
-       lockdep_assert_held(&ce->gem_context->i915->drm.struct_mutex);
-       GEM_BUG_ON(ce->pin_count == 0);
-
-       if (--ce->pin_count)
-               return;
-
        if (ce->state) {
                ce->state->obj->pin_global--;
                i915_vma_unpin(ce->state);
index 33eddfc1f8cecc06f064c9e9785d9ae82eeb014a..f1ac7453053e40b5a8f6ad6e6a2832269c0cb8a1 100644 (file)
@@ -74,9 +74,6 @@ static void hw_delay_complete(struct timer_list *t)
 
 static void mock_context_unpin(struct intel_context *ce)
 {
-       if (--ce->pin_count)
-               return;
-
        i915_gem_context_put(ce->gem_context);
 }