Commit 105f2070 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Alex Deucher

drm/ttm: Provide ttm_bo_global_{init/release}() for struct ttm_bo_global

So far, struct ttm_bo_global_ref was the only way of initializing a struct
ttm_bo_global. Providing separate initializer and release functions for
struct ttm_bo_global gives drivers the option of implementing their own
init and release callbacks for drm_global_references of type
DRM_GLOBAL_TTM_BO.

The original functions for initializing and releasing via struct
ttm_bo_global_ref are wrappers around the new interfaces.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e55a5c9b
...@@ -1522,26 +1522,22 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj) ...@@ -1522,26 +1522,22 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
kfree(glob); kfree(glob);
} }
void ttm_bo_global_ref_release(struct drm_global_reference *ref) void ttm_bo_global_release(struct ttm_bo_global *glob)
{ {
struct ttm_bo_global *glob = ref->object;
kobject_del(&glob->kobj); kobject_del(&glob->kobj);
kobject_put(&glob->kobj); kobject_put(&glob->kobj);
} }
EXPORT_SYMBOL(ttm_bo_global_ref_release); EXPORT_SYMBOL(ttm_bo_global_release);
int ttm_bo_global_ref_init(struct drm_global_reference *ref) int ttm_bo_global_init(struct ttm_bo_global *glob,
struct ttm_mem_global *mem_glob)
{ {
struct ttm_bo_global_ref *bo_ref =
container_of(ref, struct ttm_bo_global_ref, ref);
struct ttm_bo_global *glob = ref->object;
int ret; int ret;
unsigned i; unsigned i;
mutex_init(&glob->device_list_mutex); mutex_init(&glob->device_list_mutex);
spin_lock_init(&glob->lru_lock); spin_lock_init(&glob->lru_lock);
glob->mem_glob = bo_ref->mem_glob; glob->mem_glob = mem_glob;
glob->mem_glob->bo_glob = glob; glob->mem_glob->bo_glob = glob;
glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32); glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32);
...@@ -1564,7 +1560,7 @@ int ttm_bo_global_ref_init(struct drm_global_reference *ref) ...@@ -1564,7 +1560,7 @@ int ttm_bo_global_ref_init(struct drm_global_reference *ref)
kfree(glob); kfree(glob);
return ret; return ret;
} }
EXPORT_SYMBOL(ttm_bo_global_ref_init); EXPORT_SYMBOL(ttm_bo_global_init);
int ttm_bo_device_release(struct ttm_bo_device *bdev) int ttm_bo_device_release(struct ttm_bo_device *bdev)
......
...@@ -384,15 +384,6 @@ struct ttm_bo_driver { ...@@ -384,15 +384,6 @@ struct ttm_bo_driver {
void *buf, int len, int write); void *buf, int len, int write);
}; };
/**
* struct ttm_bo_global_ref - Argument to initialize a struct ttm_bo_global.
*/
struct ttm_bo_global_ref {
struct drm_global_reference ref;
struct ttm_mem_global *mem_glob;
};
/** /**
* struct ttm_bo_global - Buffer object driver global data. * struct ttm_bo_global - Buffer object driver global data.
* *
...@@ -578,8 +569,9 @@ void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem); ...@@ -578,8 +569,9 @@ void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem);
void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo, void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo,
struct ttm_mem_reg *mem); struct ttm_mem_reg *mem);
void ttm_bo_global_ref_release(struct drm_global_reference *ref); void ttm_bo_global_release(struct ttm_bo_global *glob);
int ttm_bo_global_ref_init(struct drm_global_reference *ref); int ttm_bo_global_init(struct ttm_bo_global *glob,
struct ttm_mem_global *mem_glob);
int ttm_bo_device_release(struct ttm_bo_device *bdev); int ttm_bo_device_release(struct ttm_bo_device *bdev);
...@@ -897,4 +889,43 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); ...@@ -897,4 +889,43 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
extern const struct ttm_mem_type_manager_func ttm_bo_manager_func; extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
/**
* struct ttm_bo_global_ref - Argument to initialize a struct ttm_bo_global.
*/
struct ttm_bo_global_ref {
struct drm_global_reference ref;
struct ttm_mem_global *mem_glob;
};
/**
* ttm_bo_global_ref_init
*
* @ref: DRM global reference
*
* Helper function that initializes a struct ttm_bo_global. This function
* is used as init call-back function for DRM global references of type
* DRM_GLOBAL_TTM_BO_REF.
*/
static inline int ttm_bo_global_ref_init(struct drm_global_reference *ref)
{
struct ttm_bo_global_ref *bo_ref =
container_of(ref, struct ttm_bo_global_ref, ref);
return ttm_bo_global_init(ref->object, bo_ref->mem_glob);
}
/**
* ttm_bo_global_ref_release
*
* @ref: DRM global reference
*
* Helper function that releases a struct ttm_bo_global. This function
* is used as release call-back function for DRM global references of type
* DRM_GLOBAL_TTM_BO_REF.
*/
static inline void ttm_bo_global_ref_release(struct drm_global_reference *ref)
{
ttm_bo_global_release(ref->object);
}
#endif #endif
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