[PATCH 16/49] drm/ttm: start allowing drivers to use new takedown path

Dave Airlie airlied at gmail.com
Fri Jul 31 04:04:47 UTC 2020


From: Dave Airlie <airlied at redhat.com>

Allow the takedown path callback to be optional as well.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c         |  8 +++++---
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 21 +++++++++++++++++++--
 include/drm/ttm/ttm_bo_driver.h      |  5 ++++-
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f584e5e94383..f0f0f3101bd1 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1401,8 +1401,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_bo_create);
 
-static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
-				   struct ttm_mem_type_manager *man)
+int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
+			    struct ttm_mem_type_manager *man)
 {
 	struct ttm_operation_ctx ctx = {
 		.interruptible = false,
@@ -1444,6 +1444,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
 
 	return 0;
 }
+EXPORT_SYMBOL(ttm_bo_force_list_clean);
 
 int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 {
@@ -1472,7 +1473,8 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 			return ret;
 		}
 
-		ret = (*man->func->takedown)(man);
+		if (man->func->takedown)
+			ret = (*man->func->takedown)(man);
 	}
 
 	ttm_bo_man_cleanup(man);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index 1877425abdf0..1127868274b3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -129,7 +129,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_bo_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 drm_mm *mm = &rman->mm;
@@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
 	return -EBUSY;
 }
 
+int ttm_bo_man_takedown(struct ttm_bo_device *bdev,
+			struct ttm_mem_type_manager *man)
+{
+	int ret;
+
+	ttm_bo_disable_mm(man);
+
+	ret = ttm_bo_force_list_clean(bdev, man);
+	if (ret)
+		return ret;
+
+	ttm_bo_man_takedown_private(man);
+	ttm_bo_man_cleanup(man);
+	return 0;
+}
+EXPORT_SYMBOL(ttm_bo_man_takedown);
+
 static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 			     struct drm_printer *printer)
 {
@@ -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 = {
-	.takedown = ttm_bo_man_takedown,
+	.takedown = ttm_bo_man_takedown_private,
 	.get_node = ttm_bo_man_get_node,
 	.put_node = ttm_bo_man_put_node,
 	.debug = ttm_bo_man_debug
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 92bb54cce633..2ef33b407167 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -683,6 +683,8 @@ static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man)
 	man->move = NULL;
 }
 
+int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
+			    struct ttm_mem_type_manager *man);
 /*
  * ttm_bo_util.c
  */
@@ -801,5 +803,6 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
 int ttm_bo_man_init(struct ttm_bo_device *bdev,
 		    struct ttm_mem_type_manager *man,
 		    unsigned long p_size);
-
+int ttm_bo_man_takedown(struct ttm_bo_device *bdev,
+			struct ttm_mem_type_manager *man);
 #endif
-- 
2.26.2



More information about the dri-devel mailing list