drm/i915: Introduce GEM object functions
GEM object functions deprecate several similar callback interfaces in struct drm_driver. This patch replaces the per-driver callbacks with per-instance callbacks in i915. v2: * move object-function instance to i915_gem_object.c (Jani) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Acked-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200923102159.24084-7-tzimmermann@suse.de
This commit is contained in:
parent
7cd467d0fc
commit
10012620ea
|
@ -39,9 +39,18 @@ static struct i915_global_object {
|
||||||
struct kmem_cache *slab_objects;
|
struct kmem_cache *slab_objects;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
|
static const struct drm_gem_object_funcs i915_gem_object_funcs;
|
||||||
|
|
||||||
struct drm_i915_gem_object *i915_gem_object_alloc(void)
|
struct drm_i915_gem_object *i915_gem_object_alloc(void)
|
||||||
{
|
{
|
||||||
return kmem_cache_zalloc(global.slab_objects, GFP_KERNEL);
|
struct drm_i915_gem_object *obj;
|
||||||
|
|
||||||
|
obj = kmem_cache_zalloc(global.slab_objects, GFP_KERNEL);
|
||||||
|
if (!obj)
|
||||||
|
return NULL;
|
||||||
|
obj->base.funcs = &i915_gem_object_funcs;
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void i915_gem_object_free(struct drm_i915_gem_object *obj)
|
void i915_gem_object_free(struct drm_i915_gem_object *obj)
|
||||||
|
@ -101,7 +110,7 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
|
||||||
!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE);
|
!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file)
|
static void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file)
|
||||||
{
|
{
|
||||||
struct drm_i915_gem_object *obj = to_intel_bo(gem);
|
struct drm_i915_gem_object *obj = to_intel_bo(gem);
|
||||||
struct drm_i915_file_private *fpriv = file->driver_priv;
|
struct drm_i915_file_private *fpriv = file->driver_priv;
|
||||||
|
@ -264,7 +273,7 @@ static void __i915_gem_free_work(struct work_struct *work)
|
||||||
i915_gem_flush_free_objects(i915);
|
i915_gem_flush_free_objects(i915);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i915_gem_free_object(struct drm_gem_object *gem_obj)
|
static void i915_gem_free_object(struct drm_gem_object *gem_obj)
|
||||||
{
|
{
|
||||||
struct drm_i915_gem_object *obj = to_intel_bo(gem_obj);
|
struct drm_i915_gem_object *obj = to_intel_bo(gem_obj);
|
||||||
struct drm_i915_private *i915 = to_i915(obj->base.dev);
|
struct drm_i915_private *i915 = to_i915(obj->base.dev);
|
||||||
|
@ -403,6 +412,12 @@ int __init i915_global_objects_init(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct drm_gem_object_funcs i915_gem_object_funcs = {
|
||||||
|
.free = i915_gem_free_object,
|
||||||
|
.close = i915_gem_close_object,
|
||||||
|
.export = i915_gem_prime_export,
|
||||||
|
};
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
|
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
|
||||||
#include "selftests/huge_gem_object.c"
|
#include "selftests/huge_gem_object.c"
|
||||||
#include "selftests/huge_pages.c"
|
#include "selftests/huge_pages.c"
|
||||||
|
|
|
@ -38,9 +38,6 @@ void __i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
|
||||||
|
|
||||||
int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align);
|
int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align);
|
||||||
|
|
||||||
void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file);
|
|
||||||
void i915_gem_free_object(struct drm_gem_object *obj);
|
|
||||||
|
|
||||||
void i915_gem_flush_free_objects(struct drm_i915_private *i915);
|
void i915_gem_flush_free_objects(struct drm_i915_private *i915);
|
||||||
|
|
||||||
struct sg_table *
|
struct sg_table *
|
||||||
|
|
|
@ -1853,12 +1853,8 @@ static struct drm_driver driver = {
|
||||||
.lastclose = i915_driver_lastclose,
|
.lastclose = i915_driver_lastclose,
|
||||||
.postclose = i915_driver_postclose,
|
.postclose = i915_driver_postclose,
|
||||||
|
|
||||||
.gem_close_object = i915_gem_close_object,
|
|
||||||
.gem_free_object_unlocked = i915_gem_free_object,
|
|
||||||
|
|
||||||
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
||||||
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
||||||
.gem_prime_export = i915_gem_prime_export,
|
|
||||||
.gem_prime_import = i915_gem_prime_import,
|
.gem_prime_import = i915_gem_prime_import,
|
||||||
|
|
||||||
.dumb_create = i915_gem_dumb_create,
|
.dumb_create = i915_gem_dumb_create,
|
||||||
|
|
|
@ -85,9 +85,6 @@ static struct drm_driver mock_driver = {
|
||||||
.name = "mock",
|
.name = "mock",
|
||||||
.driver_features = DRIVER_GEM,
|
.driver_features = DRIVER_GEM,
|
||||||
.release = mock_device_release,
|
.release = mock_device_release,
|
||||||
|
|
||||||
.gem_close_object = i915_gem_close_object,
|
|
||||||
.gem_free_object_unlocked = i915_gem_free_object,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void release_dev(struct device *dev)
|
static void release_dev(struct device *dev)
|
||||||
|
|
Loading…
Reference in New Issue