dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu: add missing unreserve on error
@ 2021-05-25 12:46 Dan Carpenter
  2021-05-25 12:47 ` [PATCH 2/2] drm/amdgpu: Fix an error code in kfd_mem_attach_dmabuf() Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-05-25 12:46 UTC (permalink / raw)
  To: Felix Kuehling
  Cc: David Airlie, Oak Zeng, Pan, Xinhui, kernel-janitors,
	linux-kernel, amd-gfx, Ramesh Errabolu, dri-devel, Alex Deucher,
	Christian König

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

Fixes: b4f0f97b8f5f ("drm/amdgpu: Move kfd_mem_attach outside reservation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 928e8d57cd08..68109908a869 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -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);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] drm/amdgpu: Fix an error code in kfd_mem_attach_dmabuf()
  2021-05-25 12:46 [PATCH 1/2] drm/amdgpu: add missing unreserve on error Dan Carpenter
@ 2021-05-25 12:47 ` Dan Carpenter
  2021-05-25 19:39   ` Felix Kuehling
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-05-25 12:47 UTC (permalink / raw)
  To: Felix Kuehling
  Cc: David Airlie, Oak Zeng, Pan, Xinhui, kernel-janitors, amd-gfx,
	Ramesh Errabolu, dri-devel, Alex Deucher, Christian König

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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 68109908a869..9b7a3f849a16 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -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;
 		}
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] drm/amdgpu: Fix an error code in kfd_mem_attach_dmabuf()
  2021-05-25 12:47 ` [PATCH 2/2] drm/amdgpu: Fix an error code in kfd_mem_attach_dmabuf() Dan Carpenter
@ 2021-05-25 19:39   ` Felix Kuehling
  0 siblings, 0 replies; 3+ messages in thread
From: Felix Kuehling @ 2021-05-25 19:39 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Airlie, Oak Zeng, Pan, Xinhui, kernel-janitors, amd-gfx,
	Ramesh Errabolu, dri-devel, Alex Deucher, Christian König

Am 2021-05-25 um 8:47 a.m. schrieb Dan Carpenter:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thank you for catching these. The series is

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>

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


> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 68109908a869..9b7a3f849a16 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -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;
>  		}
>  	}
>  

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-25 19:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 12:46 [PATCH 1/2] drm/amdgpu: add missing unreserve on error Dan Carpenter
2021-05-25 12:47 ` [PATCH 2/2] drm/amdgpu: Fix an error code in kfd_mem_attach_dmabuf() Dan Carpenter
2021-05-25 19:39   ` Felix Kuehling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).