Re: [PATCH 03/49] drm/ttm: split the mm manager init code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 31.07.20 um 06:04 schrieb Dave Airlie:
From: Dave Airlie <airlied@xxxxxxxxxx>

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

Eventually the old path will be removed.

Signed-off-by: Dave Airlie <airlied@xxxxxxxxxx>
---
  drivers/gpu/drm/ttm/ttm_bo.c    | 34 +++++++++++++++++++--------------
  include/drm/ttm/ttm_bo_api.h    |  4 ++++
  include/drm/ttm/ttm_bo_driver.h |  6 ++++++
  3 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 041a0e73cd1b..a658fd584c6d 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1503,35 +1503,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_bo_init_mm_base(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_bo_init_mm_base);
+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_bo_init_mm_base(bdev, &bdev->man[type], p_size);
+
+	if (type != TTM_PL_SYSTEM) {
+		ret = (*man->func->init)(man, p_size);
+		if (ret)
+			return ret;
+	}
+	ttm_bo_use_mm(man);
  	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 a9e13b252820..0060925f507a 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -546,6 +546,10 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
   * -ENOMEM: Not enough memory.
   * May also return driver-specified errors.
   */
+struct ttm_mem_type_manager;
+void ttm_bo_init_mm_base(struct ttm_bo_device *bdev,
+			 struct ttm_mem_type_manager *man,
+			 unsigned long p_size);

As I wrote before I would completely rename the backend functions to ttm_resource_* since this is not related to the buffer objects in any way.

Moving a good bunch of the handling into a separate file might be a good idea as well. But that can obviously come later as well.

Christian.

  int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
  		   unsigned long p_size);
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 7958e411269a..68e75c3b8c7a 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -678,6 +678,12 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
  	dma_resv_unlock(bo->base.resv);
  }
+static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man)
+{
+	man->has_type = true;
+	man->use_type = true;
+}
+
  /*
   * ttm_bo_util.c
   */

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux