linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/amdgpu: fix double reference dropping
@ 2019-11-06 11:35 Pan Bian
  2019-11-06 12:48 ` Koenig, Christian
  0 siblings, 1 reply; 3+ messages in thread
From: Pan Bian @ 2019-11-06 11:35 UTC (permalink / raw)
  To: Alex Deucher, christian.koenig, David1.Zhou, David Airlie,
	Daniel Vetter, Sam Ravnborg
  Cc: amd-gfx, dri-devel, linux-kernel, Pan Bian

The reference to object fence is dropped at the end of the loop.
However, it is dropped again outside the loop. The reference can be
dropped immediately after calling dma_fence_wait() in the loop and
thus the dropping operation outside the loop can be removed.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
v2: fix the bug in a more concise way
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
index 649e68c4479b..d1495e1c9289 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
@@ -33,7 +33,7 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
 {
 	unsigned long start_jiffies;
 	unsigned long end_jiffies;
-	struct dma_fence *fence = NULL;
+	struct dma_fence *fence;
 	int i, r;
 
 	start_jiffies = jiffies;
@@ -44,16 +44,14 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
 		if (r)
 			goto exit_do_move;
 		r = dma_fence_wait(fence, false);
+		dma_fence_put(fence);
 		if (r)
 			goto exit_do_move;
-		dma_fence_put(fence);
 	}
 	end_jiffies = jiffies;
 	r = jiffies_to_msecs(end_jiffies - start_jiffies);
 
 exit_do_move:
-	if (fence)
-		dma_fence_put(fence);
 	return r;
 }
 
-- 
2.7.4


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

* Re: [PATCH v2] drm/amdgpu: fix double reference dropping
  2019-11-06 11:35 [PATCH v2] drm/amdgpu: fix double reference dropping Pan Bian
@ 2019-11-06 12:48 ` Koenig, Christian
  2019-11-06 17:23   ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Koenig, Christian @ 2019-11-06 12:48 UTC (permalink / raw)
  To: Pan Bian, Deucher, Alexander, Zhou, David(ChunMing),
	David Airlie, Daniel Vetter, Sam Ravnborg
  Cc: amd-gfx, dri-devel, linux-kernel

Am 06.11.19 um 12:35 schrieb Pan Bian:
> The reference to object fence is dropped at the end of the loop.
> However, it is dropped again outside the loop. The reference can be
> dropped immediately after calling dma_fence_wait() in the loop and
> thus the dropping operation outside the loop can be removed.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>

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

> ---
> v2: fix the bug in a more concise way
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> index 649e68c4479b..d1495e1c9289 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> @@ -33,7 +33,7 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
>   {
>   	unsigned long start_jiffies;
>   	unsigned long end_jiffies;
> -	struct dma_fence *fence = NULL;
> +	struct dma_fence *fence;
>   	int i, r;
>   
>   	start_jiffies = jiffies;
> @@ -44,16 +44,14 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
>   		if (r)
>   			goto exit_do_move;
>   		r = dma_fence_wait(fence, false);
> +		dma_fence_put(fence);
>   		if (r)
>   			goto exit_do_move;
> -		dma_fence_put(fence);
>   	}
>   	end_jiffies = jiffies;
>   	r = jiffies_to_msecs(end_jiffies - start_jiffies);
>   
>   exit_do_move:
> -	if (fence)
> -		dma_fence_put(fence);
>   	return r;
>   }
>   


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

* Re: [PATCH v2] drm/amdgpu: fix double reference dropping
  2019-11-06 12:48 ` Koenig, Christian
@ 2019-11-06 17:23   ` Alex Deucher
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2019-11-06 17:23 UTC (permalink / raw)
  To: Koenig, Christian
  Cc: Pan Bian, Deucher, Alexander, Zhou, David(ChunMing),
	David Airlie, Daniel Vetter, Sam Ravnborg, dri-devel, amd-gfx,
	linux-kernel

On Wed, Nov 6, 2019 at 7:48 AM Koenig, Christian
<Christian.Koenig@amd.com> wrote:
>
> Am 06.11.19 um 12:35 schrieb Pan Bian:
> > The reference to object fence is dropped at the end of the loop.
> > However, it is dropped again outside the loop. The reference can be
> > dropped immediately after calling dma_fence_wait() in the loop and
> > thus the dropping operation outside the loop can be removed.
> >
> > Signed-off-by: Pan Bian <bianpan2016@163.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>

Applied.  thanks!

Alex

> > ---
> > v2: fix the bug in a more concise way
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 6 ++----
> >   1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> > index 649e68c4479b..d1495e1c9289 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> > @@ -33,7 +33,7 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
> >   {
> >       unsigned long start_jiffies;
> >       unsigned long end_jiffies;
> > -     struct dma_fence *fence = NULL;
> > +     struct dma_fence *fence;
> >       int i, r;
> >
> >       start_jiffies = jiffies;
> > @@ -44,16 +44,14 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
> >               if (r)
> >                       goto exit_do_move;
> >               r = dma_fence_wait(fence, false);
> > +             dma_fence_put(fence);
> >               if (r)
> >                       goto exit_do_move;
> > -             dma_fence_put(fence);
> >       }
> >       end_jiffies = jiffies;
> >       r = jiffies_to_msecs(end_jiffies - start_jiffies);
> >
> >   exit_do_move:
> > -     if (fence)
> > -             dma_fence_put(fence);
> >       return r;
> >   }
> >
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2019-11-06 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 11:35 [PATCH v2] drm/amdgpu: fix double reference dropping Pan Bian
2019-11-06 12:48 ` Koenig, Christian
2019-11-06 17:23   ` Alex Deucher

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).