From 111672f1a30b5be1da783ef78930998e68ad486f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Wed, 18 Jun 2014 22:04:48 +0300 Subject: [PATCH] drm/i915: Unpin last_context at reset MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We're forgetting to unpin the last_context from the ggtt at GPU reset time. This leads to the vma pin_count leaking at every reset if the last context wasn't the ring default context. Further use of the same context will trigger the pin_count check in i915_gem_object_pin() and userspace will be faced with EBUSY as a result. This plaques kms_flip rather badly since it performs lots of resets, and every fd has its own default context these days. Fix the problem by properly unpinning the last context at reset. This regression seems to back to commit 7727eaf9a70b86f64f68ccb97517b375b4b42155 Author: Ben Widawsky Date: Fri Dec 6 14:11:03 2013 -0800 drm/i915: Better reset handling for contexts Testcase: igt/gem_ctx_exec/reset-pin-leak Signed-off-by: Ville Syrjälä Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem_context.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 0d2c75bde96ec..06561213cf295 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -382,6 +382,9 @@ void i915_gem_context_reset(struct drm_device *dev) dctx->obj->active = 0; } + if (ring->last_context->obj && i == RCS) + i915_gem_object_ggtt_unpin(ring->last_context->obj); + i915_gem_context_unreference(ring->last_context); i915_gem_context_reference(dctx); ring->last_context = dctx; -- 2.39.5