Commit 56ee8b1c authored by Dave Airlie's avatar Dave Airlie

drm/ttm: start allowing drivers to use new takedown path (v2)

Allow the takedown path callback to be optional as well.

v2: use fini for range manager
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-27-airlied@gmail.com
parent 4265accb
...@@ -1405,7 +1405,7 @@ int ttm_bo_create(struct ttm_bo_device *bdev, ...@@ -1405,7 +1405,7 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
} }
EXPORT_SYMBOL(ttm_bo_create); EXPORT_SYMBOL(ttm_bo_create);
static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
struct ttm_mem_type_manager *man) struct ttm_mem_type_manager *man)
{ {
struct ttm_operation_ctx ctx = { struct ttm_operation_ctx ctx = {
...@@ -1448,6 +1448,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, ...@@ -1448,6 +1448,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
return 0; return 0;
} }
EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
{ {
...@@ -1470,12 +1471,13 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ...@@ -1470,12 +1471,13 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
ret = 0; ret = 0;
if (mem_type > 0) { if (mem_type > 0) {
ret = ttm_bo_force_list_clean(bdev, man); ret = ttm_mem_type_manager_force_list_clean(bdev, man);
if (ret) { if (ret) {
pr_err("Cleanup eviction failed\n"); pr_err("Cleanup eviction failed\n");
return ret; return ret;
} }
if (man->func->takedown)
ret = (*man->func->takedown)(man); ret = (*man->func->takedown)(man);
} }
...@@ -1499,7 +1501,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) ...@@ -1499,7 +1501,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
return 0; return 0;
} }
return ttm_bo_force_list_clean(bdev, man); return ttm_mem_type_manager_force_list_clean(bdev, man);
} }
EXPORT_SYMBOL(ttm_bo_evict_mm); EXPORT_SYMBOL(ttm_bo_evict_mm);
......
...@@ -129,7 +129,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev, ...@@ -129,7 +129,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
} }
EXPORT_SYMBOL(ttm_range_man_init); EXPORT_SYMBOL(ttm_range_man_init);
static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man)
{ {
struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
struct drm_mm *mm = &rman->mm; struct drm_mm *mm = &rman->mm;
...@@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) ...@@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
return -EBUSY; return -EBUSY;
} }
int ttm_range_man_fini(struct ttm_bo_device *bdev,
struct ttm_mem_type_manager *man)
{
int ret;
ttm_mem_type_manager_disable(man);
ret = ttm_mem_type_manager_force_list_clean(bdev, man);
if (ret)
return ret;
ttm_bo_man_takedown_private(man);
ttm_mem_type_manager_cleanup(man);
return 0;
}
EXPORT_SYMBOL(ttm_range_man_fini);
static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
struct drm_printer *printer) struct drm_printer *printer)
{ {
...@@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, ...@@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
} }
static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
.takedown = ttm_bo_man_takedown, .takedown = ttm_bo_man_takedown_private,
.get_node = ttm_bo_man_get_node, .get_node = ttm_bo_man_get_node,
.put_node = ttm_bo_man_put_node, .put_node = ttm_bo_man_put_node,
.debug = ttm_bo_man_debug .debug = ttm_bo_man_debug
......
...@@ -717,6 +717,18 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man ...@@ -717,6 +717,18 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man
man->move = NULL; man->move = NULL;
} }
/*
* ttm_mem_type_manager_force_list_clean
*
* @bdev - device to use
* @man - manager to use
*
* Force all the objects out of a memory manager until clean.
* Part of memory manager cleanup sequence.
*/
int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
struct ttm_mem_type_manager *man);
/* /*
* ttm_bo_util.c * ttm_bo_util.c
*/ */
...@@ -846,6 +858,17 @@ int ttm_range_man_init(struct ttm_bo_device *bdev, ...@@ -846,6 +858,17 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
struct ttm_mem_type_manager *man, struct ttm_mem_type_manager *man,
unsigned long p_size); unsigned long p_size);
/**
* ttm_range_man_fini
*
* @bdev: ttm device
* @type: memory manager type
*
* Remove the generic range manager from a slot and tear it down.
*/
int ttm_range_man_fini(struct ttm_bo_device *bdev,
struct ttm_mem_type_manager *man);
/** /**
* ttm_mem_type_manager_debug * ttm_mem_type_manager_debug
* *
...@@ -854,4 +877,5 @@ int ttm_range_man_init(struct ttm_bo_device *bdev, ...@@ -854,4 +877,5 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
*/ */
void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man, void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
struct drm_printer *p); struct drm_printer *p);
#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