Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
drm/gem: fold drm_gem_object_put_unlocked and __drm_gem_object_put()
Browse files Browse the repository at this point in the history
With earlier patch we removed the overhead so now we can lift the helper
into the header effectively folding it with __drm_object_put.

v2: drop struct_mutex references (Daniel)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org> (v1)
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20200515095118.2743122-11-emil.l.velikov@gmail.com
  • Loading branch information
evelikov-work authored and evelikov committed May 19, 2020
1 parent 1a9458a commit b5d2507
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 35 deletions.
19 changes: 0 additions & 19 deletions drivers/gpu/drm/drm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions include/drm/drm_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,6 @@ struct drm_driver {
*
* This is deprecated and should not be used by new drivers. Use
* &drm_gem_object_funcs.free instead.
* Compared to @gem_free_object this is not encumbered with
* &drm_device.struct_mutex legacy locking schemes.
*/
void (*gem_free_object_unlocked) (struct drm_gem_object *obj);

Expand Down
16 changes: 3 additions & 13 deletions include/drm/drm_gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,27 +364,17 @@ 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.
*/
static inline void
__drm_gem_object_put(struct drm_gem_object *obj)
drm_gem_object_put_unlocked(struct drm_gem_object *obj)
{
kref_put(&obj->refcount, drm_gem_object_free);
}

void drm_gem_object_put_unlocked(struct drm_gem_object *obj);
void drm_gem_object_put(struct drm_gem_object *obj);

int drm_gem_handle_create(struct drm_file *file_priv,
Expand Down

0 comments on commit b5d2507

Please sign in to comment.