amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@amd.com>
To: Christian.Koenig@amd.com
Cc: Nirmoy Das <nirmoy.das@amd.com>, amd-gfx@lists.freedesktop.org
Subject: [PATCH 2/4] drm/amdgpu: create shadow bo using amdgpu_bo_create_shadow()
Date: Wed, 21 Apr 2021 18:35:21 +0200	[thread overview]
Message-ID: <20210421163523.14493-2-nirmoy.das@amd.com> (raw)
In-Reply-To: <20210421163523.14493-1-nirmoy.das@amd.com>

Shadow BOs are only needed for vm code so call amdgpu_bo_create_shadow()
directly instead of depending on amdgpu_bo_create().

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f95bcda8463f..bc302548dfba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -873,8 +873,7 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	bp->bo_ptr_size = sizeof(struct amdgpu_bo);
 	if (vm->use_cpu_for_update)
 		bp->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
-	else if (!vm->root.base.bo || vm->root.base.bo->shadow)
-		bp->flags |= AMDGPU_GEM_CREATE_SHADOW;
+
 	bp->type = ttm_bo_type_kernel;
 	bp->no_wait_gpu = immediate;
 	if (vm->root.base.bo)
@@ -2844,12 +2843,24 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	vm->evicting = false;
 
 	amdgpu_vm_bo_param(adev, vm, adev->vm_manager.root_level, false, &bp);
-	if (vm_context == AMDGPU_VM_CONTEXT_COMPUTE)
-		bp.flags &= ~AMDGPU_GEM_CREATE_SHADOW;
 	r = amdgpu_bo_create(adev, &bp, &root);
 	if (r)
 		goto error_free_delayed;
 
+	if (!(vm_context == AMDGPU_VM_CONTEXT_COMPUTE) &&
+	    (!vm->root.base.bo || vm->root.base.bo->shadow)) {
+		if (!bp.resv)
+			WARN_ON(dma_resv_lock(root->tbo.base.resv,
+					      NULL));
+		r = amdgpu_bo_create_shadow(adev, bp.size, root);
+
+		if (!bp.resv)
+			dma_resv_unlock(root->tbo.base.resv);
+
+		if (r)
+			amdgpu_bo_unref(&root);
+	}
+
 	r = amdgpu_bo_reserve(root, true);
 	if (r)
 		goto error_free_root;
-- 
2.31.1

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

  reply	other threads:[~2021-04-21 16:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 16:35 [PATCH 1/4] drm/amdgpu: expose amdgpu_bo_create_shadow() Nirmoy Das
2021-04-21 16:35 ` Nirmoy Das [this message]
2021-04-22  7:08   ` [PATCH 2/4] drm/amdgpu: create shadow bo using amdgpu_bo_create_shadow() Christian König
2021-04-22  8:04     ` Nirmoy
2021-04-21 16:35 ` [PATCH 3/4] drm/amdgpu: cleanup amdgpu_bo_create() Nirmoy Das
2021-04-21 16:35 ` [PATCH 4/4] drm/amdgpu: remove AMDGPU_GEM_CREATE_SHADOW flag Nirmoy Das

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=20210421163523.14493-2-nirmoy.das@amd.com \
    --to=nirmoy.das@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).