Skip to contentSkip to conversation

drm/amdgpu: avoid restore process run into dead loop.

PATCH In review Gang Ba 2 participants 2 messages Mar 2, 2023

Subsystems (3)
lore
Share & tools
lore

Gang Ba

author
#0 lore raw

PATCH 1/1 drm/amdgpu: avoid restore process run into dead loop.

In restore process worker, pinned BO cause update PTE fail, then the function re-schedule the restore_work. This will generate dead loop.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4 -1
index 4b46b936a804..a38be83e486e 100644
@@ -2586,7 +2586,7 @@ int amdgpu_amdkfd_gpuvm_export_ipc_obj(struct amdgpu_device *adev, void *vm,
 	struct dma_buf *dmabuf;
 	int r;
 
-	if (!adev|| !vm || !mem)
+	if (!adev || !vm || !mem)
 		return -EINVAL;
 
 	mutex_lock(&mem->lock);
@@ -3170,6 +3170,9 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
 			if (!attachment->is_mapped)
 				continue;
 
+			if (attachment->bo_va->base.bo->tbo.pin_count)
+				continue;
+
 			kfd_mem_dmaunmap_attachment(mem, attachment);
 			ret = update_gpuvm_pte(mem, attachment, &sync_obj);
 			if (ret) {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 2023-03-02 um 13:15 schrieb Gang Ba:

Quoted 4 lines

In restore process worker, pinned BO cause update PTE fail, then the function re-schedule the restore_work. This will generate dead loop.

Quoted 27 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4 -1
index 4b46b936a804..a38be83e486e 100644
@@ -2586,7 +2586,7 @@ int amdgpu_amdkfd_gpuvm_export_ipc_obj(struct amdgpu_device *adev, void *vm,
  	struct dma_buf *dmabuf;
  	int r;
 
-	if (!adev|| !vm || !mem)
+	if (!adev || !vm || !mem)
  		return -EINVAL;
 
  	mutex_lock(&mem->lock);
@@ -3170,6 +3170,9 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
  			if (!attachment->is_mapped)
  				continue;
 
+			if (attachment->bo_va->base.bo->tbo.pin_count)
+				continue;
+
  			kfd_mem_dmaunmap_attachment(mem, attachment);
  			ret = update_gpuvm_pte(mem, attachment, &sync_obj);
  			if (ret) {