drm: Use kref_put_mutex in drm_gem_object_unreference_unlocked
Subsystems (2)
Maarten Lankhorst
maintainerPATCH 1/1 drm: Use kref_put_mutex in drm_gem_object_unreference_unlocked
If kref_put_mutex returns true then the caller or the put function is responsible for unlocking the mutex.
---
include/drm/drm_gem.h +8 -6
@@ -149,14 +149,16 @@ drm_gem_object_unreference(struct drm_gem_object *obj)static inline void drm_gem_object_unreference_unlocked (struct drm_gem_object *obj) { -if (obj && !atomic_add_unless (&obj->refcount.refcount,-1 ,1 )) { -struct drm_device *dev = obj->dev; +struct drm_device *dev; + +if (!obj) +return ; -mutex_lock (&dev->struct_mutex); -if (likely (atomic_dec_and_test (&obj->refcount.refcount))) -drm_gem_object_free (&obj->refcount); + dev = obj->dev; +if (kref_put_mutex (&obj->refcount, drm_gem_object_free, &dev->struct_mutex))mutex_unlock (&dev->struct_mutex); - } +else +might_lock (&dev->struct_mutex); } int drm_gem_handle_create(struct drm_file *file_priv,
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 2 lines · Maarten Lankhorst
If
kref_put_mutexreturns true then the caller or the put function is responsible for unlocking the mutex.
This patch introduces the kref_put_mutex() usage, so this commit message is rather confusing.
Quoted 35 lines
Signed-off-by Maarten Lankhorst <[email protected]>---
include/drm/drm_gem.h +8
-6@@ -149,14 +149,16 @@ drm_gem_object_unreference(struct drm_gem_object *obj)static inline void drm_gem_object_unreference_unlocked (struct drm_gem_object *obj) { -if (obj && !atomic_add_unless (&obj->refcount.refcount,-1 ,1 )) { -struct drm_device *dev = obj->dev; +struct drm_device *dev; + +if (!obj) +return ; -mutex_lock (&dev->struct_mutex); -if (likely (atomic_dec_and_test (&obj->refcount.refcount))) -drm_gem_object_free (&obj->refcount); + dev = obj->dev; +if (kref_put_mutex (&obj->refcount, drm_gem_object_free, &dev->struct_mutex))mutex_unlock (&dev->struct_mutex); - } +else +might_lock (&dev->struct_mutex); } int drm_gem_handle_create(struct drm_file *file_priv,_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerHey,
Op 07-04-15 om 16:19 schreef Ville Syrjälä:
Quoted 6 lines · Maarten Lankhorst
Quoted 2 lines
If
kref_put_mutexreturns true then the caller or the put function is responsible for unlocking the mutex.This patch introduces the
kref_put_mutex()usage, so this commit message is rather confusing.
This was because of the confusion that happened when doing the same in i915_gem_request_unreference__unlocked, so I thought I would mention it explicitly in the commit message. :-)
~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Maarten Lankhorst
Hey,
Op 07-04-15 om 16:19 schreef Ville Syrjälä:
Quoted 1 line · Maarten Lankhorst
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If
kref_put_mutexreturns true then the caller or the put function is responsible for unlocking the mutex.This patch introduces the
kref_put_mutex()usage, so this commit message is rather confusing.This was because of the confusion that happened when doing the same in
i915_gem_request_unreference__unlocked, so I thought I would mention it explicitly in the commit message. :-)
I've added a bit more text to make it clearer and applied the patch to topic/drm-misc.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel