All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: daniel.vetter@ffwll.ch, thomas.hellstrom@linux.intel.com
Subject: [PATCH 6/7] drm/ttm: always initialize the full ttm_resource
Date: Tue, 13 Apr 2021 15:52:47 +0200	[thread overview]
Message-ID: <20210413135248.1266-6-christian.koenig@amd.com> (raw)
In-Reply-To: <20210413135248.1266-1-christian.koenig@amd.com>

Init all fields in ttm_resource_alloc() when we create a new resource.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |  2 --
 drivers/gpu/drm/ttm/ttm_bo.c            | 26 ++++---------------------
 drivers/gpu/drm/ttm/ttm_bo_util.c       |  4 ++--
 drivers/gpu/drm/ttm/ttm_resource.c      |  9 +++++++++
 4 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index a785acc09f20..78ae6ccc8836 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1095,8 +1095,6 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 	} else {
 
 		/* allocate GART space */
-		tmp = bo->mem;
-		tmp.mm_node = NULL;
 		placement.num_placement = 1;
 		placement.placement = &placements;
 		placement.num_busy_placement = 1;
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2efae620759a..d3580dfa2bc6 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -507,11 +507,6 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
 		return ttm_tt_create(bo, false);
 	}
 
-	evict_mem = bo->mem;
-	evict_mem.mm_node = NULL;
-	evict_mem.bus.offset = 0;
-	evict_mem.bus.addr = NULL;
-
 	ret = ttm_bo_mem_space(bo, &placement, &evict_mem, ctx);
 	if (ret) {
 		if (ret != -ERESTARTSYS) {
@@ -867,12 +862,8 @@ static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo,
 				     struct ttm_place *hop)
 {
 	struct ttm_placement hop_placement;
+	struct ttm_resource hop_mem;
 	int ret;
-	struct ttm_resource hop_mem = *mem;
-
-	hop_mem.mm_node = NULL;
-	hop_mem.mem_type = TTM_PL_SYSTEM;
-	hop_mem.placement = 0;
 
 	hop_placement.num_placement = hop_placement.num_busy_placement = 1;
 	hop_placement.placement = hop_placement.busy_placement = hop;
@@ -894,19 +885,14 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
 			      struct ttm_placement *placement,
 			      struct ttm_operation_ctx *ctx)
 {
-	int ret = 0;
 	struct ttm_place hop;
 	struct ttm_resource mem;
+	int ret;
 
 	dma_resv_assert_held(bo->base.resv);
 
 	memset(&hop, 0, sizeof(hop));
 
-	mem.num_pages = PAGE_ALIGN(bo->base.size) >> PAGE_SHIFT;
-	mem.bus.offset = 0;
-	mem.bus.addr = NULL;
-	mem.mm_node = NULL;
-
 	/*
 	 * Determine where to move the buffer.
 	 *
@@ -1027,6 +1013,7 @@ int ttm_bo_init_reserved(struct ttm_device *bdev,
 			 struct dma_resv *resv,
 			 void (*destroy) (struct ttm_buffer_object *))
 {
+	static const struct ttm_place sys_mem = { .mem_type = TTM_PL_SYSTEM };
 	bool locked;
 	int ret = 0;
 
@@ -1038,13 +1025,8 @@ int ttm_bo_init_reserved(struct ttm_device *bdev,
 	bo->bdev = bdev;
 	bo->type = type;
 	bo->page_alignment = page_alignment;
-	bo->mem.mem_type = TTM_PL_SYSTEM;
-	bo->mem.num_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
-	bo->mem.mm_node = NULL;
-	bo->mem.bus.offset = 0;
-	bo->mem.bus.addr = NULL;
+	ttm_resource_alloc(bo, &sys_mem, &bo->mem);
 	bo->moving = NULL;
-	bo->mem.placement = 0;
 	bo->pin_count = 0;
 	bo->sg = sg;
 	if (resv) {
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index efb7e9c34ab4..ae8b61460724 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -664,6 +664,7 @@ EXPORT_SYMBOL(ttm_bo_move_accel_cleanup);
 
 int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
 {
+	static const struct ttm_place sys_mem = { .mem_type = TTM_PL_SYSTEM };
 	struct ttm_buffer_object *ghost;
 	int ret;
 
@@ -676,8 +677,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
 	if (ret)
 		ttm_bo_wait(bo, false, false);
 
-	memset(&bo->mem, 0, sizeof(bo->mem));
-	bo->mem.mem_type = TTM_PL_SYSTEM;
+	ttm_resource_alloc(bo, &sys_mem, &bo->mem);
 	bo->ttm = NULL;
 
 	dma_resv_unlock(&ghost->base._resv);
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index a6900b82f31a..56c4d3550c86 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -33,6 +33,15 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,
 		ttm_manager_type(bo->bdev, res->mem_type);
 
 	res->mm_node = NULL;
+	res->start = 0;
+	res->num_pages = PAGE_ALIGN(bo->base.size) >> PAGE_SHIFT;
+	res->mem_type = place->mem_type;
+	res->placement = place->flags;
+	res->bus.addr = NULL;
+	res->bus.offset = 0;
+	res->bus.is_iomem = false;
+	res->bus.caching = ttm_cached;
+
 	return man->func->alloc(man, bo, place, res);
 }
 
-- 
2.25.1

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

  parent reply	other threads:[~2021-04-13 13:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 13:52 [PATCH 1/7] drm/nouveau: use bo->base.size instead of mem->num_pages Christian König
2021-04-13 13:52 ` [PATCH 2/7] drm/amdgpu: check base size instead of mem.num_pages Christian König
2021-04-13 16:16   ` Matthew Auld
2021-04-13 13:52 ` [PATCH 3/7] drm/ttm: minor range manager coding style clean ups Christian König
2021-04-13 16:18   ` Matthew Auld
2021-04-13 13:52 ` [PATCH 4/7] drm/ttm: move the page_alignment into the BO Christian König
2021-04-14  9:46   ` Matthew Auld
2021-04-14  9:57     ` Christian König
2021-04-14 14:32       ` Matthew Auld
2021-04-13 13:52 ` [PATCH 5/7] drm/ttm: add ttm_sys_manager Christian König
2021-04-14 10:05   ` Matthew Auld
2021-04-14 10:48     ` Christian König
2021-04-13 13:52 ` Christian König [this message]
2021-04-15 16:44   ` [PATCH 6/7] drm/ttm: always initialize the full ttm_resource Matthew Auld
2021-04-13 13:52 ` [PATCH 7/7] drm/ttm: rename bo->mem and make it a pointer Christian König
2021-04-15 17:06   ` Matthew Auld
2021-04-13 15:54 ` [PATCH 1/7] drm/nouveau: use bo->base.size instead of mem->num_pages Matthew Auld
2021-04-15 12:29   ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210413135248.1266-6-christian.koenig@amd.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.