Commit 747074bb authored by Dave Airlie's avatar Dave Airlie

drm/ttm: split the mm manager init code (v2)

This will allow the driver to control the ordering here better.

Eventually the old path will be removed.

v2: add docs for new APIs.
rename new path to ttm_mem_type_manager_init/set_used(for now)
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-14-airlied@gmail.com
parent e22054de
......@@ -1507,35 +1507,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
}
EXPORT_SYMBOL(ttm_bo_evict_mm);
int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
struct ttm_mem_type_manager *man,
unsigned long p_size)
{
int ret;
struct ttm_mem_type_manager *man;
unsigned i;
BUG_ON(type >= TTM_NUM_MEM_TYPES);
man = &bdev->man[type];
BUG_ON(man->has_type);
man->use_io_reserve_lru = false;
mutex_init(&man->io_reserve_mutex);
spin_lock_init(&man->move_lock);
INIT_LIST_HEAD(&man->io_reserve_lru);
man->bdev = bdev;
if (type != TTM_PL_SYSTEM) {
ret = (*man->func->init)(man, p_size);
if (ret)
return ret;
}
man->has_type = true;
man->use_type = true;
man->size = p_size;
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
INIT_LIST_HEAD(&man->lru[i]);
man->move = NULL;
}
EXPORT_SYMBOL(ttm_mem_type_manager_init);
int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
unsigned long p_size)
{
int ret;
struct ttm_mem_type_manager *man;
BUG_ON(type >= TTM_NUM_MEM_TYPES);
ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
if (type != TTM_PL_SYSTEM) {
ret = (*man->func->init)(man, p_size);
if (ret)
return ret;
}
ttm_mem_type_manager_set_used(man, true);
return 0;
}
EXPORT_SYMBOL(ttm_bo_init_mm);
......
......@@ -54,6 +54,8 @@ struct ttm_place;
struct ttm_lru_bulk_move;
struct ttm_mem_type_manager;
/**
* struct ttm_bus_placement
*
......@@ -531,6 +533,19 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
uint32_t page_alignment, bool interruptible,
struct ttm_buffer_object **p_bo);
/**
* ttm_mem_type_manager_init
*
* @bdev: Pointer to a ttm_bo_device struct.
* @man: memory manager object to init
* @p_size: size managed area in pages.
*
* Initialise core parts of a a manager object.
*/
void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
struct ttm_mem_type_manager *man,
unsigned long p_size);
/**
* ttm_bo_init_mm
*
......
......@@ -689,6 +689,21 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
dma_resv_unlock(bo->base.resv);
}
/**
* ttm_mem_type_manager_set_used
*
* @man: A memory manager object.
* @used: usage state to set.
*
* Set the manager in use flag. If disabled the manager is no longer
* used for object placement.
*/
static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
{
man->has_type = true;
man->use_type = used;
}
/*
* ttm_bo_util.c
*/
......
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