Skip to contentSkip to conversation

drm/amdkfd: Fix an inappropriate error handling in allloc memory of gpu

PATCH In review Lang Yu 3 participants 3 messages Oct 13, 2021

Subsystems (3)
lore
Share & tools
lore

Lang Yu

author
#0 lore raw

PATCH 1/1 drm/amdkfd: Fix an inappropriate error handling in allloc memory of gpu

We should unreference a gem object instead of an amdgpu bo here.

Fixes 5ae0283e831a ("drm/amdgpu: Add userptr support for KFD")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 054c1a224def..cdf46bd0d8d5 100644
@@ -1503,7 +1503,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
 	remove_kgd_mem_from_kfd_bo_list(*mem, avm->process_info);
 	drm_vma_node_revoke(&gobj->vma_node, drm_priv);
 err_node_allow:
-	amdgpu_bo_unref(&bo);
+	drm_gem_object_put(gobj);
 	/* Don't unreserve system mem limit twice */
 	goto err_reserve_limit;
 err_bo_create:
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw

LGTM as we create a gem object 1st and retrieve amdgpu_bo from the gem object.

Quoted 22 lines · Lang Yu

We should unreference a gem object instead of an amdgpu bo here.

Fixes 5ae0283e831a ("drm/amdgpu: Add userptr support for KFD")
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 054c1a224def..cdf46bd0d8d5 100644
@@ -1503,7 +1503,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
  	remove_kgd_mem_from_kfd_bo_list(*mem, avm->process_info);
  	drm_vma_node_revoke(&gobj->vma_node, drm_priv);
  err_node_allow:
-	amdgpu_bo_unref(&bo);
+	drm_gem_object_put(gobj);
  	/* Don't unreserve system mem limit twice */
  	goto err_reserve_limit;
  err_bo_create:
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Lang Yu

Am 2021-10-13 um 3:28 a.m. schrieb Lang Yu:

Quoted 3 lines

We should unreference a gem object instead of an amdgpu bo here.

Fixes 5ae0283e831a ("drm/amdgpu: Add userptr support for KFD")

I think the Fixes tag is incorrect. At that time there was no gobj in this function.

If anything I'd attribute the problem to fd9a9f8801de ("drm/amdgpu: Use GEM obj reference for KFD BOs"), where I missed the error handling code path.

Other than that, the patch is

Quoted 19 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 054c1a224def..cdf46bd0d8d5 100644
@@ -1503,7 +1503,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
 	remove_kgd_mem_from_kfd_bo_list(*mem, avm->process_info);
 	drm_vma_node_revoke(&gobj->vma_node, drm_priv);
 err_node_allow:
-	amdgpu_bo_unref(&bo);
+	drm_gem_object_put(gobj);
 	/* Don't unreserve system mem limit twice */
 	goto err_reserve_limit;
 err_bo_create: