<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="auto">
<div>NAK, we also use the entity context number for debugging.
<div dir="auto"><br>
</div>
<div dir="auto">Additional to this the entities should not need any additional resources. So the functions are only initializing fields.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Regards,</div>
<div dir="auto">Christian.</div>
<br>
<div class="gmail_extra"><br>
<div class="gmail_quote">Am 06.08.2020 18:06 schrieb "Wang, Kevin(Yang)" <Kevin1.Wang@amd.com>:<br type="attribution">
<blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><font size="2"><span style="font-size:11pt">
<div>the entity isn't needed when vm use cpu to update page table.<br>
<br>
Signed-off-by: Kevin Wang <kevin1.wang@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 45 ++++++++++++++------------<br>
 1 file changed, 25 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
index 71e005cf2952..e15c29d613d9 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
@@ -2802,20 +2802,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,<br>
         spin_lock_init(&vm->invalidated_lock);<br>
         INIT_LIST_HEAD(&vm->freed);<br>
 <br>
-<br>
-       /* create scheduler entities for page table updates */<br>
-       r = drm_sched_entity_init(&vm->immediate, DRM_SCHED_PRIORITY_NORMAL,<br>
-                                 adev->vm_manager.vm_pte_scheds,<br>
-                                 adev->vm_manager.vm_pte_num_scheds, NULL);<br>
-       if (r)<br>
-               return r;<br>
-<br>
-       r = drm_sched_entity_init(&vm->delayed, DRM_SCHED_PRIORITY_NORMAL,<br>
-                                 adev->vm_manager.vm_pte_scheds,<br>
-                                 adev->vm_manager.vm_pte_num_scheds, NULL);<br>
-       if (r)<br>
-               goto error_free_immediate;<br>
-<br>
         vm->pte_support_ats = false;<br>
         vm->is_compute_context = false;<br>
 <br>
@@ -2835,10 +2821,25 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,<br>
                    !amdgpu_gmc_vram_full_visible(&adev->gmc)),<br>
                   "CPU update of VM recommended only for large BAR system\n");<br>
 <br>
-       if (vm->use_cpu_for_update)<br>
+       if (vm->use_cpu_for_update) {<!-- --><br>
                 vm->update_funcs = &amdgpu_vm_cpu_funcs;<br>
-       else<br>
+       } else {<!-- --><br>
+               /* create scheduler entities for page table updates */<br>
+               r = drm_sched_entity_init(&vm->immediate, DRM_SCHED_PRIORITY_NORMAL,<br>
+                                         adev->vm_manager.vm_pte_scheds,<br>
+                                         adev->vm_manager.vm_pte_num_scheds, NULL);<br>
+               if (r)<br>
+                       return r;<br>
+<br>
+               r = drm_sched_entity_init(&vm->delayed, DRM_SCHED_PRIORITY_NORMAL,<br>
+                                         adev->vm_manager.vm_pte_scheds,<br>
+                                         adev->vm_manager.vm_pte_num_scheds, NULL);<br>
+               if (r)<br>
+                       goto error_free_immediate;<br>
+<br>
                 vm->update_funcs = &amdgpu_vm_sdma_funcs;<br>
+       }<br>
+<br>
         vm->last_update = NULL;<br>
         vm->last_unlocked = dma_fence_get_stub();<br>
 <br>
@@ -2895,10 +2896,12 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,<br>
 <br>
 error_free_delayed:<br>
         dma_fence_put(vm->last_unlocked);<br>
-       drm_sched_entity_destroy(&vm->delayed);<br>
+       if (!vm->use_cpu_for_update)<br>
+               drm_sched_entity_destroy(&vm->delayed);<br>
 <br>
 error_free_immediate:<br>
-       drm_sched_entity_destroy(&vm->immediate);<br>
+       if (!vm->use_cpu_for_update)<br>
+               drm_sched_entity_destroy(&vm->immediate);<br>
 <br>
         return r;<br>
 }<br>
@@ -3120,8 +3123,10 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)<br>
         amdgpu_bo_unref(&root);<br>
         WARN_ON(vm->root.base.bo);<br>
 <br>
-       drm_sched_entity_destroy(&vm->immediate);<br>
-       drm_sched_entity_destroy(&vm->delayed);<br>
+       if (!vm->use_cpu_for_update) {<!-- --><br>
+               drm_sched_entity_destroy(&vm->immediate);<br>
+               drm_sched_entity_destroy(&vm->delayed);<br>
+       }<br>
 <br>
         if (!RB_EMPTY_ROOT(&vm->va.rb_root)) {<!-- --><br>
                 dev_err(adev->dev, "still active bo inside vm\n");<br>
-- <br>
2.27.0<br>
<br>
</div>
</span></font></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>