Re: [PATCH 09/36] drm/gem: fold drm_gem_object_put_unlocked and __drm_gem_object_put()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 8 May 2020 at 07:43, Daniel Vetter <daniel@xxxxxxxx> wrote:
>
> On Thu, May 07, 2020 at 04:07:55PM +0100, Emil Velikov wrote:
> > From: Emil Velikov <emil.velikov@xxxxxxxxxxxxx>
> >
> > With earlier patch we removed the normal overhead so now we can lift
> > the helper to the header, folding it __drm_object_put.
> >
> > Signed-off-by: Emil Velikov <emil.velikov@xxxxxxxxxxxxx>
> > ---
> >  drivers/gpu/drm/drm_gem.c                  | 19 -------------------
> >  drivers/gpu/drm/i915/gem/i915_gem_object.h |  2 +-
> >  include/drm/drm_gem.h                      | 17 ++++-------------
> >  3 files changed, 5 insertions(+), 33 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> > index dab8763b2e73..599d5ff53b73 100644
> > --- a/drivers/gpu/drm/drm_gem.c
> > +++ b/drivers/gpu/drm/drm_gem.c
> > @@ -982,25 +982,6 @@ drm_gem_object_free(struct kref *kref)
> >  }
> >  EXPORT_SYMBOL(drm_gem_object_free);
> >
> > -/**
> > - * drm_gem_object_put_unlocked - drop a GEM buffer object reference
> > - * @obj: GEM buffer object
> > - *
> > - * This releases a reference to @obj. Callers must not hold the
> > - * &drm_device.struct_mutex lock when calling this function.
> > - *
> > - * See also __drm_gem_object_put().
> > - */
> > -void
> > -drm_gem_object_put_unlocked(struct drm_gem_object *obj)
> > -{
> > -     if (!obj)
> > -             return;
> > -
> > -     kref_put(&obj->refcount, drm_gem_object_free);
> > -}
> > -EXPORT_SYMBOL(drm_gem_object_put_unlocked);
> > -
> >  /**
> >   * drm_gem_object_put - release a GEM buffer object reference
> >   * @obj: GEM buffer object
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> > index 2faa481cc18f..41351cbf31b5 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> > @@ -105,7 +105,7 @@ __attribute__((nonnull))
> >  static inline void
> >  i915_gem_object_put(struct drm_i915_gem_object *obj)
> >  {
> > -     __drm_gem_object_put(&obj->base);
> > +     drm_gem_object_put_unlocked(&obj->base);
> >  }
> >
> >  #define assert_object_held(obj) dma_resv_assert_held((obj)->base.resv)
> > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> > index ec2d24a60a76..7c877bea7b3a 100644
> > --- a/include/drm/drm_gem.h
> > +++ b/include/drm/drm_gem.h
> > @@ -364,27 +364,18 @@ static inline void drm_gem_object_get(struct drm_gem_object *obj)
> >  }
> >
> >  /**
> > - * __drm_gem_object_put - raw function to release a GEM buffer object reference
> > + * drm_gem_object_put_unlocked - drop a GEM buffer object reference
> >   * @obj: GEM buffer object
> >   *
> > - * This function is meant to be used by drivers which are not encumbered with
> > - * &drm_device.struct_mutex legacy locking and which are using the
> > - * gem_free_object_unlocked callback. It avoids all the locking checks and
> > - * locking overhead of drm_gem_object_put() and drm_gem_object_put_unlocked().
> > - *
> > - * Drivers should never call this directly in their code. Instead they should
> > - * wrap it up into a ``driver_gem_object_put(struct driver_gem_object *obj)``
> > - * wrapper function, and use that. Shared code should never call this, to
> > - * avoid breaking drivers by accident which still depend upon
> > - * &drm_device.struct_mutex locking.
> > + * This releases a reference to @obj. Callers must not hold the
> > + * &drm_device.struct_mutex lock when calling this function.
>
> 2nd sentence talking about struct_mutex isn't true anymore, since nothing
> in here calls mutex_lock(obj->dev->struct_mutex); With your cleanup here
> we officially don't care about struct_mutex in the drm core!
>
> Aside from that lgtm, with that sentence removed:
>
Seems like I've forgot another reference in the documentation for
"gem_free_object_unlocked"

> Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
>

Thanks
Emil
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux