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 4/7] drm/amdgpu: create shadow bo directly
Date: Fri, 21 May 2021 14:45:30 +0200	[thread overview]
Message-ID: <20210521124533.4380-4-nirmoy.das@amd.com> (raw)
In-Reply-To: <20210521124533.4380-1-nirmoy.das@amd.com>

Shadow BOs are only needed by VM code so create it
directly within vm code.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 1ac0293e5123..cead68181197 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -867,6 +867,8 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
 {
 	struct amdgpu_bo_param bp;
 	struct amdgpu_bo *bo;
+	struct amdgpu_bo *shadow_bo;
+	struct dma_resv *resv;
 	int r;
 
 	memset(&bp, 0, sizeof(bp));
@@ -897,9 +899,19 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
 	if (!bp.resv)
 		WARN_ON(dma_resv_lock(bo->tbo.base.resv,
 				      NULL));
-	r = amdgpu_bo_create_shadow(adev, bp.size, bo);
+	resv = bp.resv;
+	memset(&bp, 0, sizeof(bp));
+	bp.size = amdgpu_vm_bo_size(adev, level);
+	bp.domain = AMDGPU_GEM_DOMAIN_GTT;
+	bp.flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+	bp.type = ttm_bo_type_kernel;
+	bp.resv = bo->tbo.base.resv;
+	bp.bo_ptr_size = sizeof(struct amdgpu_bo);
 
-	if (!bp.resv)
+	r = amdgpu_bo_create(adev, &bp, &shadow_bo);
+
+
+	if (!resv)
 		dma_resv_unlock(bo->tbo.base.resv);
 
 	if (r) {
@@ -907,6 +919,13 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
 		return r;
 	}
 
+	shadow_bo->parent = amdgpu_bo_ref(bo);
+	bo->has_shadow = true;
+	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;
+
 	return 0;
 }
 
-- 
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: 14+ 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 ` Nirmoy Das [this message]
2021-05-21 12:45 ` [PATCH 5/7] drm/amdgpu: switch to amdgpu_bo_vm's shadow Nirmoy Das
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
2021-05-26 10:10 Nirmoy Das
2021-05-26 10:10 ` [PATCH 4/7] drm/amdgpu: create shadow bo directly 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=20210521124533.4380-4-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 4/7] drm/amdgpu: create shadow bo directly' \
    /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.