@@ -341,10 +341,14 @@ void i915_gem_context_reset(struct drm_device *dev)
struct intel_context *lctx = ring->last_context;
if (lctx) {
- if (lctx->legacy_hw_ctx.rcs_state && i == RCS)
- i915_gem_object_ggtt_unpin(lctx->legacy_hw_ctx.rcs_state);
+ if (!i915.enable_execlists) {
+ if (lctx->legacy_hw_ctx.rcs_state && i == RCS)
+ i915_gem_object_ggtt_unpin(lctx->legacy_hw_ctx.rcs_state);
- i915_gem_context_unreference(lctx);
+ i915_gem_context_unreference(lctx);
+ } else {
+ intel_lr_context_unpin(lctx, ring);
+ }
ring->last_context = NULL;
}
}
@@ -432,7 +436,10 @@ void i915_gem_context_fini(struct drm_device *dev)
struct intel_engine_cs *ring = &dev_priv->ring[i];
if (ring->last_context) {
- i915_gem_context_unreference(ring->last_context);
+ if (i915.enable_execlists)
+ intel_lr_context_unpin(ring->last_context, ring);
+ else
+ i915_gem_context_unreference(ring->last_context);
ring->last_context = NULL;
}
}
@@ -1118,7 +1118,7 @@ void intel_lr_context_unpin(struct intel_context *ctx,
{
struct drm_i915_gem_object *ctx_obj = ctx->engine[engine->id].state;
- WARN_ON(!mutex_is_locked(&engine->dev->struct_mutex));
+ WARN_ON(!mutex_is_locked(&ctx->i915->dev->struct_mutex));
if (WARN_ON_ONCE(!ctx_obj))
return;
@@ -1857,6 +1857,17 @@ static int gen8_emit_request(struct drm_i915_gem_request *request)
u32 cmd;
int ret;
+ if (ring->last_context != request->ctx) {
+ if (ring->last_context)
+ intel_lr_context_unpin(ring->last_context, ring);
+ if (request->ctx != request->i915->kernel_context) {
+ intel_lr_context_pin(request->ctx, ring);
+ ring->last_context = request->ctx;
+ } else {
+ ring->last_context = NULL;
+ }
+ }
+
/*
* Reserve space for 2 NOOPs at the end of each request to be
* used as a workaround for not being allowed to do lite