@@ -291,6 +291,7 @@ void i915_gem_context_fini(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
struct i915_hw_context *dctx = dev_priv->ring[RCS].default_context;
+ int i;
if (dev_priv->hw_contexts_disabled)
return;
@@ -312,12 +313,20 @@ void i915_gem_context_fini(struct drm_device *dev)
WARN_ON(i915_gem_object_is_active(dctx->obj));
i915_gem_object_unpin(dctx->obj);
i915_gem_context_unreference(dctx);
+ dev_priv->ring[RCS].last_context = NULL;
+ }
+
+ for (i = 0; i < I915_NUM_RINGS; i++) {
+ struct intel_ring_buffer *ring = &dev_priv->ring[i];
+ if (!(INTEL_INFO(dev)->ring_mask & (1<<i)))
+ continue;
+ if (ring->last_context)
+ i915_gem_context_unreference(ring->last_context);
+ ring->default_context = NULL;
}
i915_gem_object_unpin(dctx->obj);
WARN_ON(!i915_gem_context_unreference(dctx));
- dev_priv->ring[RCS].default_context = NULL;
- dev_priv->ring[RCS].last_context = NULL;
dev_priv->gtt.aliasing_ppgtt = NULL;
}
With multiple rings having a last context, we must now unreference these contexts. This could be squashed if desired since it leaves the last patch broken. However, because it was a bit tricky to catch, I've left it separated for primarily review purposed Signed-off-by: Ben Widawsky <ben@bwidawsk.net> --- drivers/gpu/drm/i915/i915_gem_context.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)