if (err)
goto err;
+ i915_gem_context_get(ctx);
+ GEM_BUG_ON(ce->gem_context != ctx);
+
mutex_lock(&ctx->mutex);
list_add(&ce->active_link, &ctx->active_engines);
mutex_unlock(&ctx->mutex);
- i915_gem_context_get(ctx);
- GEM_BUG_ON(ce->gem_context != ctx);
-
smp_mb__before_atomic(); /* flush pin before it is visible */
}
/* We may be called from inside intel_context_pin() to evict another */
mutex_lock_nested(&ce->pin_mutex, SINGLE_DEPTH_NESTING);
- if (likely(atomic_dec_and_test(&ce->pin_count)))
+ if (likely(atomic_dec_and_test(&ce->pin_count))) {
ce->ops->unpin(ce);
+ mutex_lock(&ce->gem_context->mutex);
+ list_del(&ce->active_link);
+ mutex_unlock(&ce->gem_context->mutex);
+
+ i915_gem_context_put(ce->gem_context);
+ }
+
mutex_unlock(&ce->pin_mutex);
}
ce->state->obj->pin_global--;
i915_gem_object_unpin_map(ce->state->obj);
i915_vma_unpin(ce->state);
-
- list_del(&ce->active_link);
- i915_gem_context_put(ce->gem_context);
}
static int __context_pin(struct i915_vma *vma)
static void mock_context_unpin(struct intel_context *ce)
{
mock_timeline_unpin(ce->ring->timeline);
- list_del(&ce->active_link);
- i915_gem_context_put(ce->gem_context);
}
static void mock_context_destroy(struct intel_context *ce)