drm/amdgpu: Remove explicit wait after VM validate
authorHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Fri, 26 Jan 2018 20:36:06 +0000 (15:36 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 20 Nov 2018 19:00:37 +0000 (14:00 -0500)
PD or PT might have to be moved during validation and this move has to be
completed before updating it. If page table updates are done using SDMA
then this serializing is done by SDMA command submission.

And if PD/PT updates are done by CPU, then explicit waiting for PD/PT
updates are done in amdgpu VM amdgpu_vm_wait_pd function.

Sync to PD BO moving fence to handle corner case where none of the PTs
are updated but PD is evicted.

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

index 9a1b2b2..e124d2d 100644 (file)
@@ -901,6 +901,26 @@ static int process_validate_vms(struct amdkfd_process_info *process_info)
        return 0;
 }
 
+static int process_sync_pds_resv(struct amdkfd_process_info *process_info,
+                                struct amdgpu_sync *sync)
+{
+       struct amdgpu_vm *peer_vm;
+       int ret;
+
+       list_for_each_entry(peer_vm, &process_info->vm_list_head,
+                           vm_list_node) {
+               struct amdgpu_bo *pd = peer_vm->root.base.bo;
+
+               ret = amdgpu_sync_resv(amdgpu_ttm_adev(pd->tbo.bdev),
+                                       sync, pd->tbo.resv,
+                                       AMDGPU_FENCE_OWNER_UNDEFINED, false);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 static int process_update_pds(struct amdkfd_process_info *process_info,
                              struct amdgpu_sync *sync)
 {
@@ -2045,13 +2065,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
        if (ret)
                goto validate_map_fail;
 
-       /* Wait for PD/PTs validate to finish */
-       /* FIXME: I think this isn't needed */
-       list_for_each_entry(peer_vm, &process_info->vm_list_head,
-                           vm_list_node) {
-               struct amdgpu_bo *bo = peer_vm->root.base.bo;
-
-               ttm_bo_wait(&bo->tbo, false, false);
+       ret = process_sync_pds_resv(process_info, &sync_obj);
+       if (ret) {
+               pr_debug("Memory eviction: Failed to sync to PD BO moving fence. Try again\n");
+               goto validate_map_fail;
        }
 
        /* Validate BOs and map them to GPUVM (update VM page tables). */