AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: don't create entity when use cpu to update page table
@ 2020-08-06 16:07 Kevin Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wang @ 2020-08-06 16:07 UTC (permalink / raw)
  To: amd-gfx; +Cc: Kevin Wang, christian.koenig

the entity isn't needed when vm use cpu to update page table.

Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 45 ++++++++++++++------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 71e005cf2952..e15c29d613d9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2802,20 +2802,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	spin_lock_init(&vm->invalidated_lock);
 	INIT_LIST_HEAD(&vm->freed);
 
-
-	/* create scheduler entities for page table updates */
-	r = drm_sched_entity_init(&vm->immediate, DRM_SCHED_PRIORITY_NORMAL,
-				  adev->vm_manager.vm_pte_scheds,
-				  adev->vm_manager.vm_pte_num_scheds, NULL);
-	if (r)
-		return r;
-
-	r = drm_sched_entity_init(&vm->delayed, DRM_SCHED_PRIORITY_NORMAL,
-				  adev->vm_manager.vm_pte_scheds,
-				  adev->vm_manager.vm_pte_num_scheds, NULL);
-	if (r)
-		goto error_free_immediate;
-
 	vm->pte_support_ats = false;
 	vm->is_compute_context = false;
 
@@ -2835,10 +2821,25 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		   !amdgpu_gmc_vram_full_visible(&adev->gmc)),
 		  "CPU update of VM recommended only for large BAR system\n");
 
-	if (vm->use_cpu_for_update)
+	if (vm->use_cpu_for_update) {
 		vm->update_funcs = &amdgpu_vm_cpu_funcs;
-	else
+	} else {
+		/* create scheduler entities for page table updates */
+		r = drm_sched_entity_init(&vm->immediate, DRM_SCHED_PRIORITY_NORMAL,
+					  adev->vm_manager.vm_pte_scheds,
+					  adev->vm_manager.vm_pte_num_scheds, NULL);
+		if (r)
+			return r;
+
+		r = drm_sched_entity_init(&vm->delayed, DRM_SCHED_PRIORITY_NORMAL,
+					  adev->vm_manager.vm_pte_scheds,
+					  adev->vm_manager.vm_pte_num_scheds, NULL);
+		if (r)
+			goto error_free_immediate;
+
 		vm->update_funcs = &amdgpu_vm_sdma_funcs;
+	}
+
 	vm->last_update = NULL;
 	vm->last_unlocked = dma_fence_get_stub();
 
@@ -2895,10 +2896,12 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 error_free_delayed:
 	dma_fence_put(vm->last_unlocked);
-	drm_sched_entity_destroy(&vm->delayed);
+	if (!vm->use_cpu_for_update)
+		drm_sched_entity_destroy(&vm->delayed);
 
 error_free_immediate:
-	drm_sched_entity_destroy(&vm->immediate);
+	if (!vm->use_cpu_for_update)
+		drm_sched_entity_destroy(&vm->immediate);
 
 	return r;
 }
@@ -3120,8 +3123,10 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	amdgpu_bo_unref(&root);
 	WARN_ON(vm->root.base.bo);
 
-	drm_sched_entity_destroy(&vm->immediate);
-	drm_sched_entity_destroy(&vm->delayed);
+	if (!vm->use_cpu_for_update) {
+		drm_sched_entity_destroy(&vm->immediate);
+		drm_sched_entity_destroy(&vm->delayed);
+	}
 
 	if (!RB_EMPTY_ROOT(&vm->va.rb_root)) {
 		dev_err(adev->dev, "still active bo inside vm\n");
-- 
2.27.0

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amdgpu: don't create entity when use cpu to update page table
@ 2020-08-06 16:35 Koenig, Christian
  0 siblings, 0 replies; 2+ messages in thread
From: Koenig, Christian @ 2020-08-06 16:35 UTC (permalink / raw)
  To: Wang, Kevin(Yang); +Cc: amd-gfx@lists.freedesktop.org


[-- Attachment #1.1: Type: text/plain, Size: 3993 bytes --]

NAK, we also use the entity context number for debugging.

Additional to this the entities should not need any additional resources. So the functions are only initializing fields.

Regards,
Christian.


Am 06.08.2020 18:06 schrieb "Wang, Kevin(Yang)" <Kevin1.Wang@amd.com>:
the entity isn't needed when vm use cpu to update page table.

Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 45 ++++++++++++++------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 71e005cf2952..e15c29d613d9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2802,20 +2802,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
         spin_lock_init(&vm->invalidated_lock);
         INIT_LIST_HEAD(&vm->freed);

-
-       /* create scheduler entities for page table updates */
-       r = drm_sched_entity_init(&vm->immediate, DRM_SCHED_PRIORITY_NORMAL,
-                                 adev->vm_manager.vm_pte_scheds,
-                                 adev->vm_manager.vm_pte_num_scheds, NULL);
-       if (r)
-               return r;
-
-       r = drm_sched_entity_init(&vm->delayed, DRM_SCHED_PRIORITY_NORMAL,
-                                 adev->vm_manager.vm_pte_scheds,
-                                 adev->vm_manager.vm_pte_num_scheds, NULL);
-       if (r)
-               goto error_free_immediate;
-
         vm->pte_support_ats = false;
         vm->is_compute_context = false;

@@ -2835,10 +2821,25 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
                    !amdgpu_gmc_vram_full_visible(&adev->gmc)),
                   "CPU update of VM recommended only for large BAR system\n");

-       if (vm->use_cpu_for_update)
+       if (vm->use_cpu_for_update) {
                 vm->update_funcs = &amdgpu_vm_cpu_funcs;
-       else
+       } else {
+               /* create scheduler entities for page table updates */
+               r = drm_sched_entity_init(&vm->immediate, DRM_SCHED_PRIORITY_NORMAL,
+                                         adev->vm_manager.vm_pte_scheds,
+                                         adev->vm_manager.vm_pte_num_scheds, NULL);
+               if (r)
+                       return r;
+
+               r = drm_sched_entity_init(&vm->delayed, DRM_SCHED_PRIORITY_NORMAL,
+                                         adev->vm_manager.vm_pte_scheds,
+                                         adev->vm_manager.vm_pte_num_scheds, NULL);
+               if (r)
+                       goto error_free_immediate;
+
                 vm->update_funcs = &amdgpu_vm_sdma_funcs;
+       }
+
         vm->last_update = NULL;
         vm->last_unlocked = dma_fence_get_stub();

@@ -2895,10 +2896,12 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,

 error_free_delayed:
         dma_fence_put(vm->last_unlocked);
-       drm_sched_entity_destroy(&vm->delayed);
+       if (!vm->use_cpu_for_update)
+               drm_sched_entity_destroy(&vm->delayed);

 error_free_immediate:
-       drm_sched_entity_destroy(&vm->immediate);
+       if (!vm->use_cpu_for_update)
+               drm_sched_entity_destroy(&vm->immediate);

         return r;
 }
@@ -3120,8 +3123,10 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
         amdgpu_bo_unref(&root);
         WARN_ON(vm->root.base.bo);

-       drm_sched_entity_destroy(&vm->immediate);
-       drm_sched_entity_destroy(&vm->delayed);
+       if (!vm->use_cpu_for_update) {
+               drm_sched_entity_destroy(&vm->immediate);
+               drm_sched_entity_destroy(&vm->delayed);
+       }

         if (!RB_EMPTY_ROOT(&vm->va.rb_root)) {
                 dev_err(adev->dev, "still active bo inside vm\n");
--
2.27.0



[-- Attachment #1.2: Type: text/html, Size: 9117 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-06 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-06 16:35 [PATCH] drm/amdgpu: don't create entity when use cpu to update page table Koenig, Christian
  -- strict thread matches above, loose matches on Subject: below --
2020-08-06 16:07 Kevin Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox