diff mbox series

[06/36] drm/amdgpu: use the unlocked drm_gem_object_put

Message ID 20200507150822.114464-7-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show
Series drm: Fareless gem_free_object | expand

Commit Message

Emil Velikov May 7, 2020, 3:07 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

The driver does not hold struct_mutex, thus using the locked version of
the helper is incorrect.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Fixes: a39414716ca0 ("drm/amdgpu: add independent DMA-buf import v9"):
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sam Ravnborg May 7, 2020, 6:03 p.m. UTC | #1
Hi Emil.

On Thu, May 07, 2020 at 04:07:52PM +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> The driver does not hold struct_mutex, thus using the locked version of
> the helper is incorrect.
> 
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Fixes: a39414716ca0 ("drm/amdgpu: add independent DMA-buf import v9"):
> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> index 43d8ed7dbd00..652c57a3b847 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> @@ -587,7 +587,7 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
>  	attach = dma_buf_dynamic_attach(dma_buf, dev->dev,
>  					&amdgpu_dma_buf_attach_ops, obj);
>  	if (IS_ERR(attach)) {
> -		drm_gem_object_put(obj);
> +		drm_gem_object_put_unlocked(obj);
>  		return ERR_CAST(attach);
>  	}
Likewise previous patch.
Drop this as the patch is correct after the rename a few pathces later.

	Sam

>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König May 8, 2020, 8:13 a.m. UTC | #2
Am 07.05.20 um 17:07 schrieb Emil Velikov:
> From: Emil Velikov <emil.velikov@collabora.com>
>
> The driver does not hold struct_mutex, thus using the locked version of
> the helper is incorrect.
>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Fixes: a39414716ca0 ("drm/amdgpu: add independent DMA-buf import v9"):
> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> index 43d8ed7dbd00..652c57a3b847 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> @@ -587,7 +587,7 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
>   	attach = dma_buf_dynamic_attach(dma_buf, dev->dev,
>   					&amdgpu_dma_buf_attach_ops, obj);
>   	if (IS_ERR(attach)) {
> -		drm_gem_object_put(obj);
> +		drm_gem_object_put_unlocked(obj);
>   		return ERR_CAST(attach);
>   	}
>
Christian König May 8, 2020, 8:16 a.m. UTC | #3
Am 07.05.20 um 20:03 schrieb Sam Ravnborg:
> Hi Emil.
>
> On Thu, May 07, 2020 at 04:07:52PM +0100, Emil Velikov wrote:
>> From: Emil Velikov <emil.velikov@collabora.com>
>>
>> The driver does not hold struct_mutex, thus using the locked version of
>> the helper is incorrect.
>>
>> Cc: Alex Deucher <alexander.deucher@amd.com>
>> Cc: Christian König <christian.koenig@amd.com>
>> Cc: amd-gfx@lists.freedesktop.org
>> Fixes: a39414716ca0 ("drm/amdgpu: add independent DMA-buf import v9"):
>> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
>> index 43d8ed7dbd00..652c57a3b847 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
>> @@ -587,7 +587,7 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
>>   	attach = dma_buf_dynamic_attach(dma_buf, dev->dev,
>>   					&amdgpu_dma_buf_attach_ops, obj);
>>   	if (IS_ERR(attach)) {
>> -		drm_gem_object_put(obj);
>> +		drm_gem_object_put_unlocked(obj);
>>   		return ERR_CAST(attach);
>>   	}
> Likewise previous patch.
> Drop this as the patch is correct after the rename a few pathces later.

Well this is a bug fix in the error path and should probably be back 
ported, so having a separate patch is certainly a good idea.

Christian.

>
> 	Sam
>
>>   
>> -- 
>> 2.25.1
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7C41036bd7ab804d8bebdf08d7f2b0e938%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637244713989571165&amp;sdata=d0LysMNmsc%2BSzSkYsZDmE43azU0nmAb%2B1tFHn%2BMNxDg%3D&amp;reserved=0
Emil Velikov May 8, 2020, 9:55 a.m. UTC | #4
On Fri, 8 May 2020 at 09:16, Christian König <christian.koenig@amd.com> wrote:
>
> Am 07.05.20 um 20:03 schrieb Sam Ravnborg:
> > Hi Emil.
> >
> > On Thu, May 07, 2020 at 04:07:52PM +0100, Emil Velikov wrote:
> >> From: Emil Velikov <emil.velikov@collabora.com>
> >>
> >> The driver does not hold struct_mutex, thus using the locked version of
> >> the helper is incorrect.
> >>
> >> Cc: Alex Deucher <alexander.deucher@amd.com>
> >> Cc: Christian König <christian.koenig@amd.com>
> >> Cc: amd-gfx@lists.freedesktop.org
> >> Fixes: a39414716ca0 ("drm/amdgpu: add independent DMA-buf import v9"):
> >> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> >> index 43d8ed7dbd00..652c57a3b847 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> >> @@ -587,7 +587,7 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
> >>      attach = dma_buf_dynamic_attach(dma_buf, dev->dev,
> >>                                      &amdgpu_dma_buf_attach_ops, obj);
> >>      if (IS_ERR(attach)) {
> >> -            drm_gem_object_put(obj);
> >> +            drm_gem_object_put_unlocked(obj);
> >>              return ERR_CAST(attach);
> >>      }
> > Likewise previous patch.
> > Drop this as the patch is correct after the rename a few pathces later.
>
> Well this is a bug fix in the error path and should probably be back
> ported, so having a separate patch is certainly a good idea.
>
Precisely the goal here. The fixes tag should allow Greg and team to
pick/port it where applicable.

-Emil
Sam Ravnborg May 8, 2020, 11:09 a.m. UTC | #5
On Fri, May 08, 2020 at 10:55:42AM +0100, Emil Velikov wrote:
> On Fri, 8 May 2020 at 09:16, Christian König <christian.koenig@amd.com> wrote:
> >
> > Am 07.05.20 um 20:03 schrieb Sam Ravnborg:
> > > Hi Emil.
> > >
> > > On Thu, May 07, 2020 at 04:07:52PM +0100, Emil Velikov wrote:
> > >> From: Emil Velikov <emil.velikov@collabora.com>
> > >>
> > >> The driver does not hold struct_mutex, thus using the locked version of
> > >> the helper is incorrect.
> > >>
> > >> Cc: Alex Deucher <alexander.deucher@amd.com>
> > >> Cc: Christian König <christian.koenig@amd.com>
> > >> Cc: amd-gfx@lists.freedesktop.org
> > >> Fixes: a39414716ca0 ("drm/amdgpu: add independent DMA-buf import v9"):
> > >> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
> > >> ---
> > >>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +-
> > >>   1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> > >> index 43d8ed7dbd00..652c57a3b847 100644
> > >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> > >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> > >> @@ -587,7 +587,7 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
> > >>      attach = dma_buf_dynamic_attach(dma_buf, dev->dev,
> > >>                                      &amdgpu_dma_buf_attach_ops, obj);
> > >>      if (IS_ERR(attach)) {
> > >> -            drm_gem_object_put(obj);
> > >> +            drm_gem_object_put_unlocked(obj);
> > >>              return ERR_CAST(attach);
> > >>      }
> > > Likewise previous patch.
> > > Drop this as the patch is correct after the rename a few pathces later.
> >
> > Well this is a bug fix in the error path and should probably be back
> > ported, so having a separate patch is certainly a good idea.
> >
> Precisely the goal here. The fixes tag should allow Greg and team to
> pick/port it where applicable.
I got it now... Thanks for spelling it out for my dense mind.

	Sam
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index 43d8ed7dbd00..652c57a3b847 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -587,7 +587,7 @@  struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
 	attach = dma_buf_dynamic_attach(dma_buf, dev->dev,
 					&amdgpu_dma_buf_attach_ops, obj);
 	if (IS_ERR(attach)) {
-		drm_gem_object_put(obj);
+		drm_gem_object_put_unlocked(obj);
 		return ERR_CAST(attach);
 	}