Commit fd632aa3 authored by Daniel Vetter's avatar Daniel Vetter Committed by Dave Airlie

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: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 1d397043
...@@ -422,15 +422,15 @@ drm_gem_release(struct drm_device *dev, struct drm_file *file_private) ...@@ -422,15 +422,15 @@ drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
idr_destroy(&file_private->object_idr); idr_destroy(&file_private->object_idr);
} }
static void void
drm_gem_object_free_common(struct drm_gem_object *obj) drm_gem_object_release(struct drm_gem_object *obj)
{ {
struct drm_device *dev = obj->dev; struct drm_device *dev = obj->dev;
fput(obj->filp); fput(obj->filp);
atomic_dec(&dev->object_count); atomic_dec(&dev->object_count);
atomic_sub(obj->size, &dev->object_memory); atomic_sub(obj->size, &dev->object_memory);
kfree(obj);
} }
EXPORT_SYMBOL(drm_gem_object_release);
/** /**
* Called after the last reference to the object has been lost. * Called after the last reference to the object has been lost.
...@@ -448,8 +448,6 @@ drm_gem_object_free(struct kref *kref) ...@@ -448,8 +448,6 @@ drm_gem_object_free(struct kref *kref)
if (dev->driver->gem_free_object != NULL) if (dev->driver->gem_free_object != NULL)
dev->driver->gem_free_object(obj); dev->driver->gem_free_object(obj);
drm_gem_object_free_common(obj);
} }
EXPORT_SYMBOL(drm_gem_object_free); EXPORT_SYMBOL(drm_gem_object_free);
...@@ -472,8 +470,6 @@ drm_gem_object_free_unlocked(struct kref *kref) ...@@ -472,8 +470,6 @@ drm_gem_object_free_unlocked(struct kref *kref)
dev->driver->gem_free_object(obj); dev->driver->gem_free_object(obj);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
} }
drm_gem_object_free_common(obj);
} }
EXPORT_SYMBOL(drm_gem_object_free_unlocked); EXPORT_SYMBOL(drm_gem_object_free_unlocked);
......
...@@ -4474,6 +4474,9 @@ void i915_gem_free_object(struct drm_gem_object *obj) ...@@ -4474,6 +4474,9 @@ void i915_gem_free_object(struct drm_gem_object *obj)
kfree(obj_priv->page_cpu_valid); kfree(obj_priv->page_cpu_valid);
kfree(obj_priv->bit_17); kfree(obj_priv->bit_17);
kfree(obj->driver_private); kfree(obj->driver_private);
drm_gem_object_release(obj);
kfree(obj);
} }
/** Unbinds all inactive objects. */ /** Unbinds all inactive objects. */
......
...@@ -57,6 +57,9 @@ nouveau_gem_object_del(struct drm_gem_object *gem) ...@@ -57,6 +57,9 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
} }
ttm_bo_unref(&bo); ttm_bo_unref(&bo);
drm_gem_object_release(gem);
kfree(gem);
} }
int int
......
...@@ -44,6 +44,9 @@ void radeon_gem_object_free(struct drm_gem_object *gobj) ...@@ -44,6 +44,9 @@ void radeon_gem_object_free(struct drm_gem_object *gobj)
if (robj) { if (robj) {
radeon_bo_unref(&robj); radeon_bo_unref(&robj);
} }
drm_gem_object_release(gobj);
kfree(gobj);
} }
int radeon_gem_object_create(struct radeon_device *rdev, int size, int radeon_gem_object_create(struct radeon_device *rdev, int size,
......
...@@ -1428,6 +1428,7 @@ extern void drm_sysfs_connector_remove(struct drm_connector *connector); ...@@ -1428,6 +1428,7 @@ extern void drm_sysfs_connector_remove(struct drm_connector *connector);
/* Graphics Execution Manager library functions (drm_gem.c) */ /* Graphics Execution Manager library functions (drm_gem.c) */
int drm_gem_init(struct drm_device *dev); int drm_gem_init(struct drm_device *dev);
void drm_gem_destroy(struct drm_device *dev); void drm_gem_destroy(struct drm_device *dev);
void drm_gem_object_release(struct drm_gem_object *obj);
void drm_gem_object_free(struct kref *kref); void drm_gem_object_free(struct kref *kref);
void drm_gem_object_free_unlocked(struct kref *kref); void drm_gem_object_free_unlocked(struct kref *kref);
struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment