]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
drm/amdgpu: Handle duplicate BOs during process restore
authorMukul Joshi <mukul.joshi@amd.com>
Fri, 8 Mar 2024 16:11:03 +0000 (11:11 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 20 Mar 2024 17:12:56 +0000 (13:12 -0400)
In certain situations, some apps can import a BO multiple times
(through IPC for example). To restore such processes successfully,
we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures
when process restore fails.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

index 14dc9d2d8d53ad0e4085fb137b42d9b2967f3b33..df58a6a1a67ec51f1bb81ff1bd8364be8a46cc13 100644 (file)
@@ -2869,14 +2869,16 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu *
 
        mutex_lock(&process_info->lock);
 
-       drm_exec_init(&exec, 0, 0);
+       drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 0);
        drm_exec_until_all_locked(&exec) {
                list_for_each_entry(peer_vm, &process_info->vm_list_head,
                                    vm_list_node) {
                        ret = amdgpu_vm_lock_pd(peer_vm, &exec, 2);
                        drm_exec_retry_on_contention(&exec);
-                       if (unlikely(ret))
+                       if (unlikely(ret)) {
+                               pr_err("Locking VM PD failed, ret: %d\n", ret);
                                goto ttm_reserve_fail;
+                       }
                }
 
                /* Reserve all BOs and page tables/directory. Add all BOs from
@@ -2889,8 +2891,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu *
                        gobj = &mem->bo->tbo.base;
                        ret = drm_exec_prepare_obj(&exec, gobj, 1);
                        drm_exec_retry_on_contention(&exec);
-                       if (unlikely(ret))
+                       if (unlikely(ret)) {
+                               pr_err("drm_exec_prepare_obj failed, ret: %d\n", ret);
                                goto ttm_reserve_fail;
+                       }
                }
        }
 
@@ -2950,8 +2954,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu *
         * validations above would invalidate DMABuf imports again.
         */
        ret = process_validate_vms(process_info, &exec.ticket);
-       if (ret)
+       if (ret) {
+               pr_debug("Validating VMs failed, ret: %d\n", ret);
                goto validate_map_fail;
+       }
 
        /* Update mappings not managed by KFD */
        list_for_each_entry(peer_vm, &process_info->vm_list_head,