Commit b072b9cd authored by Christian König's avatar Christian König

drm/ttm: add ttm_sys_manager v3

Add a separate manager for the system domain and make function tables
mandatory.

v2: debug is still optional
v3: return void during init
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210430092508.60710-1-christian.koenig@amd.com
parent dc52e41d
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
ttm-y := ttm_tt.o ttm_bo.o ttm_bo_util.o ttm_bo_vm.o ttm_module.o \ ttm-y := ttm_tt.o ttm_bo.o ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
ttm_execbuf_util.o ttm_range_manager.o ttm_resource.o ttm_pool.o \ ttm_execbuf_util.o ttm_range_manager.o ttm_resource.o ttm_pool.o \
ttm_device.o ttm_device.o ttm_sys_manager.o
ttm-$(CONFIG_AGP) += ttm_agp_backend.o ttm-$(CONFIG_AGP) += ttm_agp_backend.o
obj-$(CONFIG_DRM_TTM) += ttm.o obj-$(CONFIG_DRM_TTM) += ttm.o
...@@ -165,21 +165,6 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, ...@@ -165,21 +165,6 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,
} }
EXPORT_SYMBOL(ttm_device_swapout); EXPORT_SYMBOL(ttm_device_swapout);
static void ttm_init_sysman(struct ttm_device *bdev)
{
struct ttm_resource_manager *man = &bdev->sysman;
/*
* Initialize the system memory buffer type.
* Other types need to be driver / IOCTL initialized.
*/
man->use_tt = true;
ttm_resource_manager_init(man, 0);
ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
ttm_resource_manager_set_used(man, true);
}
static void ttm_device_delayed_workqueue(struct work_struct *work) static void ttm_device_delayed_workqueue(struct work_struct *work)
{ {
struct ttm_device *bdev = struct ttm_device *bdev =
...@@ -222,7 +207,7 @@ int ttm_device_init(struct ttm_device *bdev, struct ttm_device_funcs *funcs, ...@@ -222,7 +207,7 @@ int ttm_device_init(struct ttm_device *bdev, struct ttm_device_funcs *funcs,
bdev->funcs = funcs; bdev->funcs = funcs;
ttm_init_sysman(bdev); ttm_sys_man_init(bdev);
ttm_pool_init(&bdev->pool, dev, use_dma_alloc, use_dma32); ttm_pool_init(&bdev->pool, dev, use_dma_alloc, use_dma32);
bdev->vma_manager = vma_manager; bdev->vma_manager = vma_manager;
......
...@@ -34,7 +34,10 @@ ...@@ -34,7 +34,10 @@
#define TTM_PFX "[TTM] " #define TTM_PFX "[TTM] "
struct dentry; struct dentry;
struct ttm_device;
extern struct dentry *ttm_debugfs_root; extern struct dentry *ttm_debugfs_root;
void ttm_sys_man_init(struct ttm_device *bdev);
#endif /* _TTM_MODULE_H_ */ #endif /* _TTM_MODULE_H_ */
...@@ -33,9 +33,6 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo, ...@@ -33,9 +33,6 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,
ttm_manager_type(bo->bdev, res->mem_type); ttm_manager_type(bo->bdev, res->mem_type);
res->mm_node = NULL; res->mm_node = NULL;
if (!man->func || !man->func->alloc)
return 0;
return man->func->alloc(man, bo, place, res); return man->func->alloc(man, bo, place, res);
} }
...@@ -44,9 +41,7 @@ void ttm_resource_free(struct ttm_buffer_object *bo, struct ttm_resource *res) ...@@ -44,9 +41,7 @@ void ttm_resource_free(struct ttm_buffer_object *bo, struct ttm_resource *res)
struct ttm_resource_manager *man = struct ttm_resource_manager *man =
ttm_manager_type(bo->bdev, res->mem_type); ttm_manager_type(bo->bdev, res->mem_type);
if (man->func && man->func->free) man->func->free(man, res);
man->func->free(man, res);
res->mm_node = NULL; res->mm_node = NULL;
res->mem_type = TTM_PL_SYSTEM; res->mem_type = TTM_PL_SYSTEM;
} }
...@@ -139,7 +134,7 @@ void ttm_resource_manager_debug(struct ttm_resource_manager *man, ...@@ -139,7 +134,7 @@ void ttm_resource_manager_debug(struct ttm_resource_manager *man,
drm_printf(p, " use_type: %d\n", man->use_type); drm_printf(p, " use_type: %d\n", man->use_type);
drm_printf(p, " use_tt: %d\n", man->use_tt); drm_printf(p, " use_tt: %d\n", man->use_tt);
drm_printf(p, " size: %llu\n", man->size); drm_printf(p, " size: %llu\n", man->size);
if (man->func && man->func->debug) if (man->func->debug)
(*man->func->debug)(man, p); man->func->debug(man, p);
} }
EXPORT_SYMBOL(ttm_resource_manager_debug); EXPORT_SYMBOL(ttm_resource_manager_debug);
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
#include <drm/ttm/ttm_resource.h>
#include <drm/ttm/ttm_device.h>
#include <drm/ttm/ttm_placement.h>
static int ttm_sys_man_alloc(struct ttm_resource_manager *man,
struct ttm_buffer_object *bo,
const struct ttm_place *place,
struct ttm_resource *mem)
{
return 0;
}
static void ttm_sys_man_free(struct ttm_resource_manager *man,
struct ttm_resource *mem)
{
}
static const struct ttm_resource_manager_func ttm_sys_manager_func = {
.alloc = ttm_sys_man_alloc,
.free = ttm_sys_man_free,
};
void ttm_sys_man_init(struct ttm_device *bdev)
{
struct ttm_resource_manager *man = &bdev->sysman;
/*
* Initialize the system memory buffer type.
* Other types need to be driver / IOCTL initialized.
*/
man->use_tt = true;
man->func = &ttm_sys_manager_func;
ttm_resource_manager_init(man, 0);
ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
ttm_resource_manager_set_used(man, true);
}
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