diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-04-09 15:05:05 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-04-19 23:19:33 -0400 |
commit | fd632aa34c8592fb1d37fc83cbffa827bc7dd42c (patch) | |
tree | 5c6a0fc186e297590aee2c050b837a721db337b2 | |
parent | 1d397043bcc2c8cdccb584a8ef73131f28f18e4c (diff) |
drm: free core gem object from driver callbacks
When drivers embed the core gem object into their own structures,
they'll have to do this. Temporarily this results in an ugly
kfree(gem_obj);
in every gem driver.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_gem.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_gem.c | 3 | ||||
-rw-r--r-- | include/drm/drmP.h | 1 |
5 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 3b64d0ef1998..33dad3fa6043 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -422,15 +422,15 @@ drm_gem_release(struct drm_device *dev, struct drm_file *file_private) | |||
422 | idr_destroy(&file_private->object_idr); | 422 | idr_destroy(&file_private->object_idr); |
423 | } | 423 | } |
424 | 424 | ||
425 | static void | 425 | void |
426 | drm_gem_object_free_common(struct drm_gem_object *obj) | 426 | drm_gem_object_release(struct drm_gem_object *obj) |
427 | { | 427 | { |
428 | struct drm_device *dev = obj->dev; | 428 | struct drm_device *dev = obj->dev; |
429 | fput(obj->filp); | 429 | fput(obj->filp); |
430 | atomic_dec(&dev->object_count); | 430 | atomic_dec(&dev->object_count); |
431 | atomic_sub(obj->size, &dev->object_memory); | 431 | atomic_sub(obj->size, &dev->object_memory); |
432 | kfree(obj); | ||
433 | } | 432 | } |
433 | EXPORT_SYMBOL(drm_gem_object_release); | ||
434 | 434 | ||
435 | /** | 435 | /** |
436 | * Called after the last reference to the object has been lost. | 436 | * Called after the last reference to the object has been lost. |
@@ -448,8 +448,6 @@ drm_gem_object_free(struct kref *kref) | |||
448 | 448 | ||
449 | if (dev->driver->gem_free_object != NULL) | 449 | if (dev->driver->gem_free_object != NULL) |
450 | dev->driver->gem_free_object(obj); | 450 | dev->driver->gem_free_object(obj); |
451 | |||
452 | drm_gem_object_free_common(obj); | ||
453 | } | 451 | } |
454 | EXPORT_SYMBOL(drm_gem_object_free); | 452 | EXPORT_SYMBOL(drm_gem_object_free); |
455 | 453 | ||
@@ -472,8 +470,6 @@ drm_gem_object_free_unlocked(struct kref *kref) | |||
472 | dev->driver->gem_free_object(obj); | 470 | dev->driver->gem_free_object(obj); |
473 | mutex_unlock(&dev->struct_mutex); | 471 | mutex_unlock(&dev->struct_mutex); |
474 | } | 472 | } |
475 | |||
476 | drm_gem_object_free_common(obj); | ||
477 | } | 473 | } |
478 | EXPORT_SYMBOL(drm_gem_object_free_unlocked); | 474 | EXPORT_SYMBOL(drm_gem_object_free_unlocked); |
479 | 475 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 80871c62a571..d4ea90999f67 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -4474,6 +4474,9 @@ void i915_gem_free_object(struct drm_gem_object *obj) | |||
4474 | kfree(obj_priv->page_cpu_valid); | 4474 | kfree(obj_priv->page_cpu_valid); |
4475 | kfree(obj_priv->bit_17); | 4475 | kfree(obj_priv->bit_17); |
4476 | kfree(obj->driver_private); | 4476 | kfree(obj->driver_private); |
4477 | |||
4478 | drm_gem_object_release(obj); | ||
4479 | kfree(obj); | ||
4477 | } | 4480 | } |
4478 | 4481 | ||
4479 | /** Unbinds all inactive objects. */ | 4482 | /** Unbinds all inactive objects. */ |
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 1bc0b38a5167..6d1aa89ec870 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c | |||
@@ -57,6 +57,9 @@ nouveau_gem_object_del(struct drm_gem_object *gem) | |||
57 | } | 57 | } |
58 | 58 | ||
59 | ttm_bo_unref(&bo); | 59 | ttm_bo_unref(&bo); |
60 | |||
61 | drm_gem_object_release(gem); | ||
62 | kfree(gem); | ||
60 | } | 63 | } |
61 | 64 | ||
62 | int | 65 | int |
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 28dd3e1b9c3a..a72a3ee5d69b 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c | |||
@@ -44,6 +44,9 @@ void radeon_gem_object_free(struct drm_gem_object *gobj) | |||
44 | if (robj) { | 44 | if (robj) { |
45 | radeon_bo_unref(&robj); | 45 | radeon_bo_unref(&robj); |
46 | } | 46 | } |
47 | |||
48 | drm_gem_object_release(gobj); | ||
49 | kfree(gobj); | ||
47 | } | 50 | } |
48 | 51 | ||
49 | int radeon_gem_object_create(struct radeon_device *rdev, int size, | 52 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index b3b57b561b92..c1b987158dfa 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -1428,6 +1428,7 @@ extern void drm_sysfs_connector_remove(struct drm_connector *connector); | |||
1428 | /* Graphics Execution Manager library functions (drm_gem.c) */ | 1428 | /* Graphics Execution Manager library functions (drm_gem.c) */ |
1429 | int drm_gem_init(struct drm_device *dev); | 1429 | int drm_gem_init(struct drm_device *dev); |
1430 | void drm_gem_destroy(struct drm_device *dev); | 1430 | void drm_gem_destroy(struct drm_device *dev); |
1431 | void drm_gem_object_release(struct drm_gem_object *obj); | ||
1431 | void drm_gem_object_free(struct kref *kref); | 1432 | void drm_gem_object_free(struct kref *kref); |
1432 | void drm_gem_object_free_unlocked(struct kref *kref); | 1433 | void drm_gem_object_free_unlocked(struct kref *kref); |
1433 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, | 1434 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, |