summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-08-04 12:55:46 +1000
committerDave Airlie <airlied@redhat.com>2020-08-06 12:31:29 +1000
commit747074bb04b5a6be8e562d06b5a312d6ddb253d0 (patch)
tree7487a788034d14dd2dd499aafc85cb7880d99fcd
parente22054debc079ed1c9db7561b8efda43a078fbe0 (diff)
downloadlinux-stable-747074bb04b5a6be8e562d06b5a312d6ddb253d0.tar.gz
linux-stable-747074bb04b5a6be8e562d06b5a312d6ddb253d0.tar.bz2
linux-stable-747074bb04b5a6be8e562d06b5a312d6ddb253d0.zip
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: Christian König <christian.koenig@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-14-airlied@gmail.com
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c34
-rw-r--r--include/drm/ttm/ttm_bo_api.h15
-rw-r--r--include/drm/ttm/ttm_bo_driver.h15
3 files changed, 50 insertions, 14 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8cd012f6bba2..ebc850ce1273 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -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,
- unsigned long p_size)
+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);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index b1c705a93517..cc876cd3b82c 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -54,6 +54,8 @@ struct ttm_place;
struct ttm_lru_bulk_move;
+struct ttm_mem_type_manager;
+
/**
* struct ttm_bus_placement
*
@@ -532,6 +534,19 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
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
*
* @bdev: Pointer to a ttm_bo_device struct.
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index ee11ae621c3b..02aa1b996b3a 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -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
*/