diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-12-18 15:37:21 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-12-18 16:18:53 +0000 |
commit | 69df05e11ab8c10e57bb5aaaa3e6d3d1b251b333 (patch) | |
tree | 3379ae73970f6d9f492db95994179a8f3e6b356f | |
parent | e8a9c58fcd9a5081f71f57f370af1347ed6a310b (diff) | |
download | lwn-69df05e11ab8c10e57bb5aaaa3e6d3d1b251b333.tar.gz lwn-69df05e11ab8c10e57bb5aaaa3e6d3d1b251b333.zip |
drm/i915: Simplify releasing context reference
A few users only take the struct_mutex in order to release a reference
to a context. We can expose a kref_put_mutex() wrapper in order to
simplify these users, and optimise taking of the mutex to the final
unref.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161218153724.8439-4-chris@chris-wilson.co.uk
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_perf.c | 16 |
2 files changed, 11 insertions, 12 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c89b012af914..202a6ac51c05 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -3518,6 +3518,13 @@ static inline void i915_gem_context_put(struct i915_gem_context *ctx) kref_put(&ctx->ref, i915_gem_context_free); } +static inline void i915_gem_context_put_unlocked(struct i915_gem_context *ctx) +{ + kref_put_mutex(&ctx->ref, + i915_gem_context_free, + &ctx->i915->drm.struct_mutex); +} + static inline struct intel_timeline * i915_gem_context_lookup_timeline(struct i915_gem_context *ctx, struct intel_engine_cs *engine) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index da8537cb8136..a1b7eec58be2 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -1555,8 +1555,6 @@ static long i915_perf_ioctl(struct file *file, */ static void i915_perf_destroy_locked(struct i915_perf_stream *stream) { - struct drm_i915_private *dev_priv = stream->dev_priv; - if (stream->enabled) i915_perf_disable_locked(stream); @@ -1565,11 +1563,8 @@ static void i915_perf_destroy_locked(struct i915_perf_stream *stream) list_del(&stream->link); - if (stream->ctx) { - mutex_lock(&dev_priv->drm.struct_mutex); - i915_gem_context_put(stream->ctx); - mutex_unlock(&dev_priv->drm.struct_mutex); - } + if (stream->ctx) + i915_gem_context_put_unlocked(stream->ctx); kfree(stream); } @@ -1738,11 +1733,8 @@ err_open: err_alloc: kfree(stream); err_ctx: - if (specific_ctx) { - mutex_lock(&dev_priv->drm.struct_mutex); - i915_gem_context_put(specific_ctx); - mutex_unlock(&dev_priv->drm.struct_mutex); - } + if (specific_ctx) + i915_gem_context_put_unlocked(specific_ctx); err: return ret; } |