All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@amd.com>
To: amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, Nirmoy Das <nirmoy.das@amd.com>,
	Christian.Koenig@amd.com
Subject: [PATCH 5/7] drm/amdgpu: switch to amdgpu_bo_vm's shadow
Date: Fri, 21 May 2021 14:45:31 +0200	[thread overview]
Message-ID: <20210521124533.4380-5-nirmoy.das@amd.com> (raw)
In-Reply-To: <20210521124533.4380-1-nirmoy.das@amd.com>

Use shadow of amdgpu_bo_vm instead of the base class.

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c      |  4 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c      | 27 ++++++++++++---------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 16 ++++++------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 90136f9dedd6..46ccd43566e2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -460,8 +460,8 @@ static int amdgpu_cs_validate(void *param, struct amdgpu_bo *bo)
 	if (r)
 		return r;
 
-	if (bo->shadow)
-		r = amdgpu_cs_bo_validate(p, bo->shadow);
+	if (bo->has_shadow)
+		r = amdgpu_cs_bo_validate(p, to_amdgpu_bo_vm(bo)->shadow);
 
 	return r;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index cead68181197..120e6b7a0286 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -658,9 +658,9 @@ void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev,
 
 		ttm_bo_move_to_lru_tail(&bo->tbo, &bo->tbo.mem,
 					&vm->lru_bulk_move);
-		if (bo->shadow)
-			ttm_bo_move_to_lru_tail(&bo->shadow->tbo,
-						&bo->shadow->tbo.mem,
+		if (bo->has_shadow)
+			ttm_bo_move_to_lru_tail(&to_amdgpu_bo_vm(bo)->shadow->tbo,
+						&to_amdgpu_bo_vm(bo)->shadow->tbo.mem,
 						&vm->lru_bulk_move);
 	}
 	spin_unlock(&adev->mman.bdev.lru_lock);
@@ -788,8 +788,9 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
 	if (r)
 		return r;
 
-	if (bo->shadow) {
-		r = ttm_bo_validate(&bo->shadow->tbo, &bo->shadow->placement,
+	if (bo->has_shadow) {
+		r = ttm_bo_validate(&to_amdgpu_bo_vm(bo)->shadow->tbo,
+				    &to_amdgpu_bo_vm(bo)->shadow->placement,
 				    &ctx);
 		if (r)
 			return r;
@@ -924,7 +925,7 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
 	mutex_lock(&adev->shadow_list_lock);
 	list_add_tail(&shadow_bo->shadow_list, &adev->shadow_list);
 	mutex_unlock(&adev->shadow_list_lock);
-	bo->shadow = shadow_bo;
+	(*vmbo)->shadow = shadow_bo;
 
 	return 0;
 }
@@ -985,7 +986,7 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
 	return 0;
 
 error_free_pt:
-	amdgpu_bo_unref(&pt_bo->shadow);
+	amdgpu_bo_unref(&pt->shadow);
 	amdgpu_bo_unref(&pt_bo);
 	return r;
 }
@@ -1000,7 +1001,8 @@ static void amdgpu_vm_free_table(struct amdgpu_vm_pt *entry)
 	if (entry->base.bo) {
 		entry->base.bo->vm_bo = NULL;
 		list_del(&entry->base.vm_status);
-		amdgpu_bo_unref(&entry->base.bo->shadow);
+		if (&entry->base.bo->has_shadow)
+			amdgpu_bo_unref(&to_amdgpu_bo_vm(entry->base.bo)->shadow);
 		amdgpu_bo_unref(&entry->base.bo);
 	}
 	kvfree(entry->entries);
@@ -2691,7 +2693,8 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
 	struct amdgpu_vm_bo_base *bo_base;
 
 	/* shadow bo doesn't have bo base, its validation needs its parent */
-	if (bo->parent && bo->parent->shadow == bo)
+	if (bo->parent && bo->parent->has_shadow &&
+	    to_amdgpu_bo_vm(bo->parent)->shadow == bo)
 		bo = bo->parent;
 
 	for (bo_base = bo->vm_bo; bo_base; bo_base = bo_base->next) {
@@ -2953,8 +2956,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, u32 pasid)
 	amdgpu_bo_unreserve(vm->root.base.bo);
 
 error_free_root:
-	amdgpu_bo_unref(&vm->root.base.bo->shadow);
-	amdgpu_bo_unref(&vm->root.base.bo);
+	amdgpu_bo_unref(&root->shadow);
+	amdgpu_bo_unref(&root_bo);
 	vm->root.base.bo = NULL;
 
 error_free_delayed:
@@ -3096,7 +3099,7 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	}
 
 	/* Free the shadow bo for compute VM */
-	amdgpu_bo_unref(&vm->root.base.bo->shadow);
+	amdgpu_bo_unref(&to_amdgpu_bo_vm(vm->root.base.bo)->shadow);
 
 	if (pasid)
 		vm->pasid = pasid;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
index a83a646759c5..f92260594c72 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
@@ -41,8 +41,8 @@ static int amdgpu_vm_sdma_map_table(struct amdgpu_bo *table)
 	if (r)
 		return r;
 
-	if (table->shadow)
-		r = amdgpu_ttm_alloc_gart(&table->shadow->tbo);
+	if (table->has_shadow)
+		r = amdgpu_ttm_alloc_gart(&to_amdgpu_bo_vm(table)->shadow->tbo);
 
 	return r;
 }
@@ -238,8 +238,9 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
 
 		if (!p->pages_addr) {
 			/* set page commands needed */
-			if (bo->shadow)
-				amdgpu_vm_sdma_set_ptes(p, bo->shadow, pe, addr,
+			if (bo->has_shadow)
+				amdgpu_vm_sdma_set_ptes(p, to_amdgpu_bo_vm(bo)->shadow,
+							pe, addr,
 							count, incr, flags);
 			amdgpu_vm_sdma_set_ptes(p, bo, pe, addr, count,
 						incr, flags);
@@ -248,7 +249,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
 
 		/* copy commands needed */
 		ndw -= p->adev->vm_manager.vm_pte_funcs->copy_pte_num_dw *
-			(bo->shadow ? 2 : 1);
+			(bo->has_shadow ? 2 : 1);
 
 		/* for padding */
 		ndw -= 7;
@@ -263,8 +264,9 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
 			pte[i] |= flags;
 		}
 
-		if (bo->shadow)
-			amdgpu_vm_sdma_copy_ptes(p, bo->shadow, pe, nptes);
+		if (bo->has_shadow)
+			amdgpu_vm_sdma_copy_ptes(p, to_amdgpu_bo_vm(bo)->shadow,
+						 pe, nptes);
 		amdgpu_vm_sdma_copy_ptes(p, bo, pe, nptes);
 
 		pe += nptes * 8;
-- 
2.31.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2021-05-21 12:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 12:45 [PATCH 1/7] drm/amdgpu: add amdgpu_bo_vm bo type Nirmoy Das
2021-05-21 12:45 ` [PATCH 2/7] drm/amdgpu: add a new identifier for amdgpu_bo Nirmoy Das
2021-05-21 12:58   ` Christian König
2021-05-21 13:54     ` Nirmoy
2021-05-21 12:45 ` [PATCH 3/7] drm/amdgpu: use amdgpu_bo_vm for vm code Nirmoy Das
2021-05-21 12:45 ` [PATCH 4/7] drm/amdgpu: create shadow bo directly Nirmoy Das
2021-05-21 12:45 ` Nirmoy Das [this message]
2021-05-21 12:45 ` [PATCH 6/7] drm/amdgpu: remove unused code Nirmoy Das
2021-05-21 12:45 ` [PATCH 7/7] drm/amdgpu: do not allocate entries separately Nirmoy Das
2021-05-21 13:01   ` Christian König
2021-05-21 14:04     ` Nirmoy
2021-05-21 14:54 ` [PATCH 1/7] drm/amdgpu: add amdgpu_bo_vm bo type Alex Deucher
2021-05-21 15:19   ` Nirmoy

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=20210521124533.4380-5-nirmoy.das@amd.com \
    --to=nirmoy.das@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --subject='Re: [PATCH 5/7] drm/amdgpu: switch to amdgpu_bo_vm'\''s shadow' \
    /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

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.