diff mbox

[44/66] drm/i915: Catch missed context unref earlier

Message ID 1372375867-1003-45-git-send-email-ben@bwidawsk.net (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Widawsky June 27, 2013, 11:30 p.m. UTC
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_drv.h         | 4 ++--
 drivers/gpu/drm/i915/i915_gem_context.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f17d825..bead414 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1900,9 +1900,9 @@  static inline void i915_gem_context_reference(struct i915_hw_context *ctx)
 	kref_get(&ctx->ref);
 }
 
-static inline void i915_gem_context_unreference(struct i915_hw_context *ctx)
+static inline int i915_gem_context_unreference(struct i915_hw_context *ctx)
 {
-	kref_put(&ctx->ref, i915_gem_context_free);
+	return kref_put(&ctx->ref, i915_gem_context_free);
 }
 
 struct i915_ctx_hang_stats * __must_check
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index c45cd5c..9176559 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -299,7 +299,7 @@  void i915_gem_context_fini(struct drm_device *dev)
 	}
 
 	i915_gem_object_unpin(dctx->obj);
-	i915_gem_context_unreference(dctx);
+	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;