aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drmP.h
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-02-09 00:49:11 -0500
committerDave Airlie <airlied@redhat.com>2010-02-10 23:21:24 -0500
commitc3ae90c099bb62387507e86da7cf799850444b08 (patch)
tree4f546a65e35fddea09a97fbfd28ce724ea86f7c2 /include/drm/drmP.h
parent77c1ff3982c6b36961725dd19e872a1c07df7f3b (diff)
drm: introduce drm_gem_object_[handle_]unreference_unlocked
This patch introduces the drm_gem_object_unreference_unlocked and drm_gem_object_handle_unreference_unlocked functions that do not require holding struct_mutex. drm_gem_object_unreference_unlocked calls the new ->gem_free_object_unlocked entry point if available, and otherwise just takes struct_mutex and just calls ->gem_free_object Signed-off-by: Luca Barbieri <luca@luca-barbieri.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r--include/drm/drmP.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ffac157fb5b2..4a3c4e441027 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -801,6 +801,7 @@ struct drm_driver {
801 */ 801 */
802 int (*gem_init_object) (struct drm_gem_object *obj); 802 int (*gem_init_object) (struct drm_gem_object *obj);
803 void (*gem_free_object) (struct drm_gem_object *obj); 803 void (*gem_free_object) (struct drm_gem_object *obj);
804 void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
804 805
805 /* vga arb irq handler */ 806 /* vga arb irq handler */
806 void (*vgaarb_irq)(struct drm_device *dev, bool state); 807 void (*vgaarb_irq)(struct drm_device *dev, bool state);
@@ -1427,6 +1428,7 @@ extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1427int drm_gem_init(struct drm_device *dev); 1428int drm_gem_init(struct drm_device *dev);
1428void drm_gem_destroy(struct drm_device *dev); 1429void drm_gem_destroy(struct drm_device *dev);
1429void drm_gem_object_free(struct kref *kref); 1430void drm_gem_object_free(struct kref *kref);
1431void drm_gem_object_free_unlocked(struct kref *kref);
1430struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, 1432struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1431 size_t size); 1433 size_t size);
1432void drm_gem_object_handle_free(struct kref *kref); 1434void drm_gem_object_handle_free(struct kref *kref);
@@ -1443,10 +1445,15 @@ drm_gem_object_reference(struct drm_gem_object *obj)
1443static inline void 1445static inline void
1444drm_gem_object_unreference(struct drm_gem_object *obj) 1446drm_gem_object_unreference(struct drm_gem_object *obj)
1445{ 1447{
1446 if (obj == NULL) 1448 if (obj != NULL)
1447 return; 1449 kref_put(&obj->refcount, drm_gem_object_free);
1450}
1448 1451
1449 kref_put(&obj->refcount, drm_gem_object_free); 1452static inline void
1453drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1454{
1455 if (obj != NULL)
1456 kref_put(&obj->refcount, drm_gem_object_free_unlocked);
1450} 1457}
1451 1458
1452int drm_gem_handle_create(struct drm_file *file_priv, 1459int drm_gem_handle_create(struct drm_file *file_priv,
@@ -1475,6 +1482,21 @@ drm_gem_object_handle_unreference(struct drm_gem_object *obj)
1475 drm_gem_object_unreference(obj); 1482 drm_gem_object_unreference(obj);
1476} 1483}
1477 1484
1485static inline void
1486drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj)
1487{
1488 if (obj == NULL)
1489 return;
1490
1491 /*
1492 * Must bump handle count first as this may be the last
1493 * ref, in which case the object would disappear before we
1494 * checked for a name
1495 */
1496 kref_put(&obj->handlecount, drm_gem_object_handle_free);
1497 drm_gem_object_unreference_unlocked(obj);
1498}
1499
1478struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, 1500struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1479 struct drm_file *filp, 1501 struct drm_file *filp,
1480 u32 handle); 1502 u32 handle);