aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_gem.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-10-05 21:10:48 -0400
committerDave Airlie <airlied@redhat.com>2010-10-05 21:10:48 -0400
commitfb7ba2114bcd8bb51640c20bc68f89164b29b9ed (patch)
tree80b4a779130a477680a72109257fb8c19d66cf22 /drivers/gpu/drm/drm_gem.c
parent9a170caed6fce89da77852575a7eee7dbadee332 (diff)
parentabb295f3b3db602f91accf58b526b30b48673af1 (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 'drivers/gpu/drm/drm_gem.c')
-rw-r--r--drivers/gpu/drm/drm_gem.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 3ea0692ce59a..ea1c4b019ebf 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -142,7 +142,7 @@ int drm_gem_object_init(struct drm_device *dev,
142 return -ENOMEM; 142 return -ENOMEM;
143 143
144 kref_init(&obj->refcount); 144 kref_init(&obj->refcount);
145 kref_init(&obj->handlecount); 145 atomic_set(&obj->handle_count, 0);
146 obj->size = size; 146 obj->size = size;
147 147
148 return 0; 148 return 0;
@@ -448,26 +448,6 @@ drm_gem_object_free(struct kref *kref)
448} 448}
449EXPORT_SYMBOL(drm_gem_object_free); 449EXPORT_SYMBOL(drm_gem_object_free);
450 450
451/**
452 * Called after the last reference to the object has been lost.
453 * Must be called without holding struct_mutex
454 *
455 * Frees the object
456 */
457void
458drm_gem_object_free_unlocked(struct kref *kref)
459{
460 struct drm_gem_object *obj = (struct drm_gem_object *) kref;
461 struct drm_device *dev = obj->dev;
462
463 if (dev->driver->gem_free_object != NULL) {
464 mutex_lock(&dev->struct_mutex);
465 dev->driver->gem_free_object(obj);
466 mutex_unlock(&dev->struct_mutex);
467 }
468}
469EXPORT_SYMBOL(drm_gem_object_free_unlocked);
470
471static void drm_gem_object_ref_bug(struct kref *list_kref) 451static void drm_gem_object_ref_bug(struct kref *list_kref)
472{ 452{
473 BUG(); 453 BUG();
@@ -480,12 +460,8 @@ static void drm_gem_object_ref_bug(struct kref *list_kref)
480 * called before drm_gem_object_free or we'll be touching 460 * called before drm_gem_object_free or we'll be touching
481 * freed memory 461 * freed memory
482 */ 462 */
483void 463void drm_gem_object_handle_free(struct drm_gem_object *obj)
484drm_gem_object_handle_free(struct kref *kref)
485{ 464{
486 struct drm_gem_object *obj = container_of(kref,
487 struct drm_gem_object,
488 handlecount);
489 struct drm_device *dev = obj->dev; 465 struct drm_device *dev = obj->dev;
490 466
491 /* Remove any name for this object */ 467 /* Remove any name for this object */
@@ -512,6 +488,10 @@ void drm_gem_vm_open(struct vm_area_struct *vma)
512 struct drm_gem_object *obj = vma->vm_private_data; 488 struct drm_gem_object *obj = vma->vm_private_data;
513 489
514 drm_gem_object_reference(obj); 490 drm_gem_object_reference(obj);
491
492 mutex_lock(&obj->dev->struct_mutex);
493 drm_vm_open_locked(vma);
494 mutex_unlock(&obj->dev->struct_mutex);
515} 495}
516EXPORT_SYMBOL(drm_gem_vm_open); 496EXPORT_SYMBOL(drm_gem_vm_open);
517 497
@@ -519,7 +499,10 @@ void drm_gem_vm_close(struct vm_area_struct *vma)
519{ 499{
520 struct drm_gem_object *obj = vma->vm_private_data; 500 struct drm_gem_object *obj = vma->vm_private_data;
521 501
522 drm_gem_object_unreference_unlocked(obj); 502 mutex_lock(&obj->dev->struct_mutex);
503 drm_vm_close_locked(vma);
504 drm_gem_object_unreference(obj);
505 mutex_unlock(&obj->dev->struct_mutex);
523} 506}
524EXPORT_SYMBOL(drm_gem_vm_close); 507EXPORT_SYMBOL(drm_gem_vm_close);
525 508