[Intel-gfx] [CI 4/7] drm/i915: Simplify releasing context reference
Chris Wilson
chris at chris-wilson.co.uk
Mon Dec 19 10:08:56 UTC 2016
On Mon, Dec 19, 2016 at 05:49:46PM +0800, Zhenyu Wang wrote:
> On 2016.12.18 15:37:21 +0000, Chris Wilson wrote:
> > 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 at chris-wilson.co.uk>
> > Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_drv.h | 7 +++++++
> > 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 dec4ddf132f7..6217f01d3c11 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);
> > +}
> > +
>
> For kref_put_mutex() in final release func should unlock mutex, but I haven't
> seen i915_gem_context_free() to handle that?
No, I just completely forgot the asymmetry built into kref_put_mutex().
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list