All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 09/18] drm/amdgpu: update pt shadow
Date: Fri, 12 Aug 2016 14:38:58 +0800	[thread overview]
Message-ID: <1470983947-32579-10-git-send-email-David1.Zhou@amd.com> (raw)
In-Reply-To: <1470983947-32579-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>

Change-Id: I33b31cbe794c1c83b8e02e3069159c8204ac03e3
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 108 +++++++++++++++++++++------------
 1 file changed, 69 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index bd69cf83..73272d9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -871,7 +871,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
 					*vm_update_params,
 				  struct amdgpu_vm *vm,
 				  uint64_t start, uint64_t end,
-				  uint64_t dst, uint32_t flags)
+				  uint64_t dst, uint32_t flags,
+				  bool shadow)
 {
 	const uint64_t mask = AMDGPU_VM_PTE_COUNT - 1;
 
@@ -885,7 +886,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
 	/* initialize the variables */
 	addr = start;
 	pt_idx = addr >> amdgpu_vm_block_size;
-	pt = vm->page_tables[pt_idx].entry.robj;
+	pt = shadow ? vm->page_tables[pt_idx].entry.robj->shadow :
+		vm->page_tables[pt_idx].entry.robj;
 
 	if ((addr & ~mask) == (end & ~mask))
 		nptes = end - addr;
@@ -904,7 +906,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
 	/* walk over the address space and update the page tables */
 	while (addr < end) {
 		pt_idx = addr >> amdgpu_vm_block_size;
-		pt = vm->page_tables[pt_idx].entry.robj;
+		pt = shadow ? vm->page_tables[pt_idx].entry.robj->shadow :
+			vm->page_tables[pt_idx].entry.robj;
 
 		if ((addr & ~mask) == (end & ~mask))
 			nptes = end - addr;
@@ -939,31 +942,15 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
 			    cur_pe_end, cur_dst, flags);
 }
 
-/**
- * amdgpu_vm_bo_update_mapping - update a mapping in the vm page table
- *
- * @adev: amdgpu_device pointer
- * @exclusive: fence we need to sync to
- * @src: address where to copy page table entries from
- * @pages_addr: DMA addresses to use for mapping
- * @vm: requested vm
- * @start: start of mapped range
- * @last: last mapped entry
- * @flags: flags for the entries
- * @addr: addr to set the area to
- * @fence: optional resulting fence
- *
- * Fill in the page table entries between @start and @last.
- * Returns 0 for success, -EINVAL for failure.
- */
-static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
-				       struct fence *exclusive,
-				       uint64_t src,
-				       dma_addr_t *pages_addr,
-				       struct amdgpu_vm *vm,
-				       uint64_t start, uint64_t last,
-				       uint32_t flags, uint64_t addr,
-				       struct fence **fence)
+static int amdgpu_vm_bo_update_mapping_or_shadow(struct amdgpu_device *adev,
+						 struct fence *exclusive,
+						 uint64_t src,
+						 dma_addr_t *pages_addr,
+						 struct amdgpu_vm *vm,
+						 uint64_t start, uint64_t last,
+						 uint32_t flags, uint64_t addr,
+						 struct fence **fence,
+						 bool shadow)
 {
 	struct amdgpu_ring *ring;
 	void *owner = AMDGPU_FENCE_OWNER_VM;
@@ -1018,29 +1005,30 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
 
 	vm_update_params.ib = &job->ibs[0];
 
-	r = amdgpu_sync_fence(adev, &job->sync, exclusive);
-	if (r)
-		goto error_free;
-
-	r = amdgpu_sync_resv(adev, &job->sync, vm->page_directory->tbo.resv,
-			     owner);
-	if (r)
-		goto error_free;
+	if (!shadow) {
+		r = amdgpu_sync_fence(adev, &job->sync, exclusive);
+		if (r)
+			goto error_free;
 
+		r = amdgpu_sync_resv(adev, &job->sync, vm->page_directory->tbo.resv,
+				     owner);
+		if (r)
+			goto error_free;
+	}
 	r = reservation_object_reserve_shared(vm->page_directory->tbo.resv);
 	if (r)
 		goto error_free;
 
 	amdgpu_vm_update_ptes(adev, &vm_update_params, vm, start,
-			      last + 1, addr, flags);
+			      last + 1, addr, flags, shadow);
 
 	amdgpu_ring_pad_ib(ring, vm_update_params.ib);
 	WARN_ON(vm_update_params.ib->length_dw > ndw);
-	r = amdgpu_job_submit(job, ring, &vm->entity,
+	r = amdgpu_job_submit(job, ring,
+			      shadow ? &vm->shadow_entity : &vm->entity,
 			      AMDGPU_FENCE_OWNER_VM, &f);
 	if (r)
 		goto error_free;
-
 	amdgpu_bo_fence(vm->page_directory, f, true);
 	if (fence) {
 		fence_put(*fence);
@@ -1055,6 +1043,48 @@ error_free:
 }
 
 /**
+ * amdgpu_vm_bo_update_mapping - update a mapping in the vm page table
+ *
+ * @adev: amdgpu_device pointer
+ * @exclusive: fence we need to sync to
+ * @src: address where to copy page table entries from
+ * @pages_addr: DMA addresses to use for mapping
+ * @vm: requested vm
+ * @start: start of mapped range
+ * @last: last mapped entry
+ * @flags: flags for the entries
+ * @addr: addr to set the area to
+ * @fence: optional resulting fence
+ *
+ * Fill in the page table entries between @start and @last.
+ * Returns 0 for success, -EINVAL for failure.
+ */
+static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
+				       struct fence *exclusive,
+				       uint64_t src,
+				       dma_addr_t *pages_addr,
+				       struct amdgpu_vm *vm,
+				       uint64_t start, uint64_t last,
+				       uint32_t flags, uint64_t addr,
+				       struct fence **fence)
+{
+	int r;
+
+	r = amdgpu_vm_bo_update_mapping_or_shadow(adev, exclusive, src,
+						  pages_addr, vm,
+						  start, last,
+						  flags, addr,
+						  NULL, true);
+	if (r)
+		return r;
+	return amdgpu_vm_bo_update_mapping_or_shadow(adev, exclusive, src,
+						     pages_addr, vm,
+						     start, last,
+						     flags, addr,
+						     fence, false);
+}
+
+/**
  * amdgpu_vm_bo_split_mapping - split a mapping into smaller chunks
  *
  * @adev: amdgpu_device pointer
-- 
1.9.1

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

  parent reply	other threads:[~2016-08-12  6:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12  6:38 [PATCH 00/18] shadow page table support V3 Chunming Zhou
     [not found] ` <1470983947-32579-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-12  6:38   ` [PATCH 01/18] drm/amdgpu: add shadow bo support V2 Chunming Zhou
2016-08-12  6:38   ` [PATCH 02/18] drm/amdgpu: validate shadow as well when validating bo Chunming Zhou
2016-08-12  6:38   ` [PATCH 03/18] drm/amdgpu: allocate shadow for pd/pt bo V2 Chunming Zhou
2016-08-12  6:38   ` [PATCH 04/18] drm/amdgpu: add shadow flag V2 Chunming Zhou
2016-08-12  6:38   ` [PATCH 05/18] drm/amdgpu: sync bo and shadow Chunming Zhou
2016-08-12  6:38   ` [PATCH 06/18] drm/amdgpu: implement vm recovery function from shadow Chunming Zhou
2016-08-12  6:38   ` [PATCH 07/18] drm/amdgpu: add shadow_entity for shadow page table updates Chunming Zhou
2016-08-12  6:38   ` [PATCH 08/18] drm/amdgpu: update pd shadow bo Chunming Zhou
     [not found]     ` <1470983947-32579-9-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-12  9:50       ` Edward O'Callaghan
2016-08-12  6:38   ` Chunming Zhou [this message]
2016-08-12  6:38   ` [PATCH 10/18] drm/amd: add last fence in sched entity Chunming Zhou
2016-08-12  6:39   ` [PATCH 11/18] drm/amdgpu: link all vm clients Chunming Zhou
2016-08-12  6:39   ` [PATCH 12/18] drm/amdgpu: add vm_list_lock Chunming Zhou
2016-08-12  6:39   ` [PATCH 13/18] drm/amd: add block entity function Chunming Zhou
2016-08-12  6:39   ` [PATCH 14/18] drm/amdgpu: add shadow fence owner Chunming Zhou
2016-08-12  6:39   ` [PATCH 15/18] drm/amd: block entity Chunming Zhou
     [not found]     ` <1470983947-32579-16-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-12  9:42       ` Edward O'Callaghan
     [not found]         ` <f8dfeb55-132f-1ddf-2e2f-02776aa5d3e0-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
2016-08-12  9:43           ` zhoucm1
2016-08-12  6:39   ` [PATCH 16/18] drm/amdgpu: recover page tables after gpu reset Chunming Zhou
2016-08-12  6:39   ` [PATCH 17/18] drm/amdgpu: add need backup function Chunming Zhou
2016-08-12  6:39   ` [PATCH 18/18] drm/amdgpu: add backup condition for vm Chunming Zhou
2016-08-12  8:00   ` [PATCH 00/18] shadow page table support V3 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=1470983947-32579-10-git-send-email-David1.Zhou@amd.com \
    --to=david1.zhou-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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 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.