Skip to contentSkip to conversation

drm/amdgpu: Fix recursive evict/restore worker on a multiple mapped bo

PATCH In review Shaoyun Liu 2 participants 2 messages Aug 4, 2017 – Aug 5, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix recursive evict/restore worker on a multiple mapped bo

When one buffer object is mapped muliple times, KFD will treat them as different memory object but share the same ttm_bo with a single eviction fence. Seperate the ttm_bo_wait and attach eviction fence code to avoid ttm_bo_wait trigger the eviction worker on the bo that just be assigned with the eviction fence

Change-Id: I4a7dba32c21cbd5fc77512c0476b8d2b4b6ea155

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +5 -9
index a3ee5bf..8e03f44 100644
@@ -2309,9 +2309,6 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info)
 		goto ttm_reserve_fail;
 	}
 
-	if (!list_empty(&duplicate_save))
-		pr_err("BUG: list of BOs to reserve has duplicates!\n");
-
 	amdgpu_sync_create(&sync_obj);
 	ctx.sync = &sync_obj;
 
@@ -2360,12 +2357,11 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info)
 
 	/* Wait for validate to finish and attach new eviction fence */
 	list_for_each_entry(mem, &process_info->kfd_bo_list,
-		validate_list.head) {
-		struct amdgpu_bo *bo = mem->bo;
-
-		ttm_bo_wait(&bo->tbo, false, false);
-		amdgpu_bo_fence(bo, &process_info->eviction_fence->base, true);
-	}
+		validate_list.head)
+		ttm_bo_wait(&mem->bo->tbo, false, false);
+	list_for_each_entry(mem, &process_info->kfd_bo_list,
+		validate_list.head)
+		amdgpu_bo_fence(mem->bo, &process_info->eviction_fence->base, true);
 
 	/* Attach eviction fence to PD / PT BOs */
 	list_for_each_entry(peer_vm, &process_info->vm_list_head,
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1501887794-6136-1-git-send-email-Shaoyun.Liu-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Hi Shaoyun,

The change looks good to me. But I'd make the removal of the duplicate warning a separate commit and explain the scenario where this occurs in the commit description (same graphics BO imported multiple times for interop).

The code you're changing is not upstream yet. It's in amd-kfd-staging and in the hybrid branch. Let's review this in Gerrit for amd-kfd-staging.

Thanks,
Felix

Quoted 35 lines · Shaoyun Liu

When one buffer object is mapped muliple times, KFD will treat them as different memory object but share the same ttm_bo with a single eviction fence. Seperate the ttm_bo_wait and attach eviction fence code to avoid ttm_bo_wait trigger the eviction worker on the bo that just be assigned with the eviction fence

Change-Id: I4a7dba32c21cbd5fc77512c0476b8d2b4b6ea155

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -7
index a3ee5bf..8e03f44 100644
@@ -2309,9 +2309,6 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info)
 		goto ttm_reserve_fail;
 	}
 
-	if (!list_empty(&duplicate_save))
-		pr_err("BUG: list of BOs to reserve has duplicates!\n");
-
 	amdgpu_sync_create(&sync_obj);
 	ctx.sync = &sync_obj;
 
@@ -2360,12 +2357,11 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info)
 
 	/* Wait for validate to finish and attach new eviction fence */
 	list_for_each_entry(mem, &process_info->kfd_bo_list,
-		validate_list.head) {
-		struct amdgpu_bo *bo = mem->bo;
-
-		ttm_bo_wait(&bo->tbo, false, false);

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info) · line 2367

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +5 -2
-		amdgpu_bo_fence(bo, &process_info->eviction_fence->base, true);
-	}
+		validate_list.head)
+		ttm_bo_wait(&mem->bo->tbo, false, false);
+	list_for_each_entry(mem, &process_info->kfd_bo_list,
+		validate_list.head)
+		amdgpu_bo_fence(mem->bo, &process_info->eviction_fence->base, true);
 
 	/* Attach eviction fence to PD / PT BOs */
 	list_for_each_entry(peer_vm, &process_info->vm_list_head,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx