Skip to contentSkip to conversation

drm/amdgpu: add missing unreserve on error

PATCH In review Dan Carpenter 2 participants 3 messages May 25, 2021

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

PATCH 1/2 drm/amdgpu: add missing unreserve on error

The amdgpu_bo_unreserve() has to be done on the error path as well.

Fixes b4f0f97b8f5f ("drm/amdgpu: Move kfd_mem_attach outside reservation")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -2
index 928e8d57cd08..68109908a869 100644
@@ -624,11 +624,10 @@ kfd_mem_attach_userptr(struct amdgpu_device *adev, struct kgd_mem *mem,
 				       0, ttm_bo_type_sg,
 				       mem->bo->tbo.base.resv,
 				       &gobj);
+	amdgpu_bo_unreserve(mem->bo);
 	if (ret)
 		return ret;
 
-	amdgpu_bo_unreserve(mem->bo);
-
 	*bo = gem_to_amdgpu_bo(gobj);
 	(*bo)->parent = amdgpu_bo_ref(mem->bo);
 
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/2 drm/amdgpu: Fix an error code in kfd_mem_attach_dmabuf()

If amdgpu_gem_prime_export() fails, then this code accidentally returns zero/success instead of a negative error code.

Fixes 190f2d7696c8 ("drm/amdgpu: Add DMA mapping of GTT BOs")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3 -1
index 68109908a869..9b7a3f849a16 100644
@@ -639,14 +639,16 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
 		      struct amdgpu_bo **bo)
 {
 	struct drm_gem_object *gobj;
+	int ret;
 
 	if (!mem->dmabuf) {
 		mem->dmabuf = amdgpu_gem_prime_export(&mem->bo->tbo.base,
 			mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
 				DRM_RDWR : 0);
 		if (IS_ERR(mem->dmabuf)) {
+			ret = PTR_ERR(mem->dmabuf);
 			mem->dmabuf = NULL;
-			return PTR_ERR(mem->dmabuf);
+			return ret;
 		}
 	}
 
Signature · 6 lines
2.30.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu: Fix an error code in kfd_mem_attach_dmabuf()

Am 2021-05-25 um 8:47 a.m. schrieb Dan Carpenter:

Quoted 5 lines

If amdgpu_gem_prime_export() fails, then this code accidentally returns zero/success instead of a negative error code.

Fixes 190f2d7696c8 ("drm/amdgpu: Add DMA mapping of GTT BOs")

Thank you for catching these. The series is

I am applying the patches to amd-staging-drm-next.

Quoted 16 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -0
index 68109908a869..9b7a3f849a16 100644
@@ -639,14 +639,16 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
 		      struct amdgpu_bo **bo)
 {
 	struct drm_gem_object *gobj;
+	int ret;
 
 	if (!mem->dmabuf) {
 		mem->dmabuf = amdgpu_gem_prime_export(&mem->bo->tbo.base,

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem, · line 654

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -1
 			mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
 				DRM_RDWR : 0);
 		if (IS_ERR(mem->dmabuf)) {
+			ret = PTR_ERR(mem->dmabuf);
 			mem->dmabuf = NULL;
-			return PTR_ERR(mem->dmabuf);
+			return ret;
 		}
 	}
 

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