diff options
author | Dave Airlie <airlied@redhat.com> | 2010-10-05 21:10:48 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-10-05 21:10:48 -0400 |
commit | fb7ba2114bcd8bb51640c20bc68f89164b29b9ed (patch) | |
tree | 80b4a779130a477680a72109257fb8c19d66cf22 /include/drm/drmP.h | |
parent | 9a170caed6fce89da77852575a7eee7dbadee332 (diff) | |
parent | abb295f3b3db602f91accf58b526b30b48673af1 (diff) |
Merge remote branch 'korg/drm-fixes' into drm-vmware-next
necessary for some of the vmware fixes to be pushed in.
Conflicts:
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/i915/intel_fb.c
include/drm/drmP.h
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r-- | include/drm/drmP.h | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index bb5c41893c00..274eaaa15c36 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -612,7 +612,7 @@ struct drm_gem_object { | |||
612 | struct kref refcount; | 612 | struct kref refcount; |
613 | 613 | ||
614 | /** Handle count of this object. Each handle also holds a reference */ | 614 | /** Handle count of this object. Each handle also holds a reference */ |
615 | struct kref handlecount; | 615 | atomic_t handle_count; /* number of handles on this object */ |
616 | 616 | ||
617 | /** Related drm device */ | 617 | /** Related drm device */ |
618 | struct drm_device *dev; | 618 | struct drm_device *dev; |
@@ -1151,6 +1151,7 @@ extern int drm_release(struct inode *inode, struct file *filp); | |||
1151 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); | 1151 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
1152 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); | 1152 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); |
1153 | extern void drm_vm_open_locked(struct vm_area_struct *vma); | 1153 | extern void drm_vm_open_locked(struct vm_area_struct *vma); |
1154 | extern void drm_vm_close_locked(struct vm_area_struct *vma); | ||
1154 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); | 1155 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
1155 | 1156 | ||
1156 | /* Memory management support (drm_memory.h) */ | 1157 | /* Memory management support (drm_memory.h) */ |
@@ -1411,12 +1412,11 @@ int drm_gem_init(struct drm_device *dev); | |||
1411 | void drm_gem_destroy(struct drm_device *dev); | 1412 | void drm_gem_destroy(struct drm_device *dev); |
1412 | void drm_gem_object_release(struct drm_gem_object *obj); | 1413 | void drm_gem_object_release(struct drm_gem_object *obj); |
1413 | void drm_gem_object_free(struct kref *kref); | 1414 | void drm_gem_object_free(struct kref *kref); |
1414 | void drm_gem_object_free_unlocked(struct kref *kref); | ||
1415 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, | 1415 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, |
1416 | size_t size); | 1416 | size_t size); |
1417 | int drm_gem_object_init(struct drm_device *dev, | 1417 | int drm_gem_object_init(struct drm_device *dev, |
1418 | struct drm_gem_object *obj, size_t size); | 1418 | struct drm_gem_object *obj, size_t size); |
1419 | void drm_gem_object_handle_free(struct kref *kref); | 1419 | void drm_gem_object_handle_free(struct drm_gem_object *obj); |
1420 | void drm_gem_vm_open(struct vm_area_struct *vma); | 1420 | void drm_gem_vm_open(struct vm_area_struct *vma); |
1421 | void drm_gem_vm_close(struct vm_area_struct *vma); | 1421 | void drm_gem_vm_close(struct vm_area_struct *vma); |
1422 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | 1422 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
@@ -1439,8 +1439,12 @@ drm_gem_object_unreference(struct drm_gem_object *obj) | |||
1439 | static inline void | 1439 | static inline void |
1440 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) | 1440 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) |
1441 | { | 1441 | { |
1442 | if (obj != NULL) | 1442 | if (obj != NULL) { |
1443 | kref_put(&obj->refcount, drm_gem_object_free_unlocked); | 1443 | struct drm_device *dev = obj->dev; |
1444 | mutex_lock(&dev->struct_mutex); | ||
1445 | kref_put(&obj->refcount, drm_gem_object_free); | ||
1446 | mutex_unlock(&dev->struct_mutex); | ||
1447 | } | ||
1444 | } | 1448 | } |
1445 | 1449 | ||
1446 | int drm_gem_handle_create(struct drm_file *file_priv, | 1450 | int drm_gem_handle_create(struct drm_file *file_priv, |
@@ -1451,7 +1455,7 @@ static inline void | |||
1451 | drm_gem_object_handle_reference(struct drm_gem_object *obj) | 1455 | drm_gem_object_handle_reference(struct drm_gem_object *obj) |
1452 | { | 1456 | { |
1453 | drm_gem_object_reference(obj); | 1457 | drm_gem_object_reference(obj); |
1454 | kref_get(&obj->handlecount); | 1458 | atomic_inc(&obj->handle_count); |
1455 | } | 1459 | } |
1456 | 1460 | ||
1457 | static inline void | 1461 | static inline void |
@@ -1460,12 +1464,15 @@ drm_gem_object_handle_unreference(struct drm_gem_object *obj) | |||
1460 | if (obj == NULL) | 1464 | if (obj == NULL) |
1461 | return; | 1465 | return; |
1462 | 1466 | ||
1467 | if (atomic_read(&obj->handle_count) == 0) | ||
1468 | return; | ||
1463 | /* | 1469 | /* |
1464 | * Must bump handle count first as this may be the last | 1470 | * Must bump handle count first as this may be the last |
1465 | * ref, in which case the object would disappear before we | 1471 | * ref, in which case the object would disappear before we |
1466 | * checked for a name | 1472 | * checked for a name |
1467 | */ | 1473 | */ |
1468 | kref_put(&obj->handlecount, drm_gem_object_handle_free); | 1474 | if (atomic_dec_and_test(&obj->handle_count)) |
1475 | drm_gem_object_handle_free(obj); | ||
1469 | drm_gem_object_unreference(obj); | 1476 | drm_gem_object_unreference(obj); |
1470 | } | 1477 | } |
1471 | 1478 | ||
@@ -1475,12 +1482,17 @@ drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) | |||
1475 | if (obj == NULL) | 1482 | if (obj == NULL) |
1476 | return; | 1483 | return; |
1477 | 1484 | ||
1485 | if (atomic_read(&obj->handle_count) == 0) | ||
1486 | return; | ||
1487 | |||
1478 | /* | 1488 | /* |
1479 | * Must bump handle count first as this may be the last | 1489 | * Must bump handle count first as this may be the last |
1480 | * ref, in which case the object would disappear before we | 1490 | * ref, in which case the object would disappear before we |
1481 | * checked for a name | 1491 | * checked for a name |
1482 | */ | 1492 | */ |
1483 | kref_put(&obj->handlecount, drm_gem_object_handle_free); | 1493 | |
1494 | if (atomic_dec_and_test(&obj->handle_count)) | ||
1495 | drm_gem_object_handle_free(obj); | ||
1484 | drm_gem_object_unreference_unlocked(obj); | 1496 | drm_gem_object_unreference_unlocked(obj); |
1485 | } | 1497 | } |
1486 | 1498 | ||