[PATCH 01/11] drm/ttm: add ttm process struct

Chunming Zhou david1.zhou at amd.com
Thu Apr 12 10:09:30 UTC 2018


Change-Id: I34924a40392653e72eeeef143c30ab312cbbf9fa
Signed-off-by: Chunming Zhou <david1.zhou at amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 23 +++++++++++++++++++++++
 include/drm/ttm/ttm_bo_api.h    |  1 +
 include/drm/ttm/ttm_bo_driver.h | 10 ++++++++++
 3 files changed, 34 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 98e06f8bf23b..b740d8f390ca 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1556,6 +1556,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 				    0x10000000);
 	INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
 	INIT_LIST_HEAD(&bdev->ddestroy);
+	INIT_LIST_HEAD(&bdev->process_list);
 	bdev->dev_mapping = mapping;
 	bdev->glob = glob;
 	bdev->need_dma32 = need_dma32;
@@ -1569,6 +1570,28 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_bo_device_init);
 
+int ttm_process_init(struct ttm_process *process, struct ttm_bo_device *bdev,
+		     struct reservation_object *resv)
+{
+	int i, j;
+
+	INIT_LIST_HEAD(&process->process_list);
+	for (i = 0; i < TTM_NUM_MEM_TYPES; i++) {
+		for (j = 0; j < TTM_MAX_BO_PRIORITY; j++) {
+			INIT_LIST_HEAD(&process->fixed_lru[i][j]);
+			INIT_LIST_HEAD(&process->dynamic_lru[i][j]);
+		}
+	}
+	spin_lock(&bdev->glob->lru_lock);
+	list_add_tail(&process->process_list, &bdev->process_list);
+	spin_unlock(&bdev->glob->lru_lock);
+
+	process->resv = resv;
+
+	return 0;
+}
+EXPORT_SYMBOL(ttm_process_init);
+
 /*
  * buffer object vm functions.
  */
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index c67977aa1a0e..8cb4b48f387a 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -172,6 +172,7 @@ struct ttm_buffer_object {
 	 */
 
 	struct ttm_bo_device *bdev;
+	struct ttm_process *process;
 	enum ttm_bo_type type;
 	void (*destroy) (struct ttm_buffer_object *);
 	unsigned long num_pages;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 3234cc322e70..91120923de81 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -438,6 +438,13 @@ struct ttm_bo_global {
 
 #define TTM_NUM_MEM_TYPES 8
 
+struct ttm_process {
+	struct list_head process_list;
+	struct list_head fixed_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
+	struct list_head dynamic_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
+	struct reservation_object *resv;
+};
+
 /**
  * struct ttm_bo_device - Buffer object driver device-specific data.
  *
@@ -459,6 +466,7 @@ struct ttm_bo_device {
 	 * Constant after bo device init / atomic.
 	 */
 	struct list_head device_list;
+	struct list_head process_list;
 	struct ttm_bo_global *glob;
 	struct ttm_bo_driver *driver;
 	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
@@ -575,6 +583,8 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, struct ttm_bo_global *glob,
 		       struct address_space *mapping,
 		       uint64_t file_page_offset, bool need_dma32);
 
+int ttm_process_init(struct ttm_process *process, struct ttm_bo_device *bdev,
+		     struct reservation_object *resv);
 /**
  * ttm_bo_unmap_virtual
  *
-- 
2.14.1



More information about the amd-gfx mailing list