linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] drm/msm: Move fence put to where failure occurs
@ 2018-11-01 16:12 Robert Foss
  2018-11-01 16:26 ` Chris Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Foss @ 2018-11-01 16:12 UTC (permalink / raw)
  To: robdclark, airlied, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, Chris Wilson
  Cc: Robert Foss

If dma_fence_wait fails to wait for a supplied in-fence in
msm_ioctl_gem_submit, make sure we release that in-fence.

Also remove this dma_fence_put() from the 'out' label.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index a90aedd6883a..3e7704af5b24 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -411,7 +411,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 	struct msm_file_private *ctx = file->driver_priv;
 	struct msm_gem_submit *submit;
 	struct msm_gpu *gpu = priv->gpu;
-	struct dma_fence *in_fence = NULL;
 	struct sync_file *sync_file = NULL;
 	struct msm_gpu_submitqueue *queue;
 	struct msm_ringbuffer *ring;
@@ -444,7 +443,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 	ring = gpu->rb[queue->prio];
 
 	if (args->flags & MSM_SUBMIT_FENCE_FD_IN) {
-		in_fence = sync_file_get_fence(args->fence_fd);
+		struct dma_fence *in_fence = sync_file_get_fence(
+			args->fence_fd);
 
 		if (!in_fence)
 			return -EINVAL;
@@ -455,8 +455,10 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 		 */
 		if (!dma_fence_match_context(in_fence, ring->fctx->context)) {
 			ret = dma_fence_wait(in_fence, true);
-			if (ret)
+			if (ret) {
+				dma_fence_put(in_fence);
 				return ret;
+			}
 		}
 	}
 
@@ -583,8 +585,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 	}
 
 out:
-	if (in_fence)
-		dma_fence_put(in_fence);
 	submit_cleanup(submit);
 	if (ret)
 		msm_gem_submit_free(submit);
-- 
2.17.1


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

* Re: [PATCH v1] drm/msm: Move fence put to where failure occurs
  2018-11-01 16:12 [PATCH v1] drm/msm: Move fence put to where failure occurs Robert Foss
@ 2018-11-01 16:26 ` Chris Wilson
  2018-11-01 17:08   ` Robert Foss
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wilson @ 2018-11-01 16:26 UTC (permalink / raw)
  To: Robert Foss, airlied, dri-devel, freedreno, linux-arm-msm,
	linux-kernel, robdclark
  Cc: Robert Foss

Quoting Robert Foss (2018-11-01 16:12:28)
> If dma_fence_wait fails to wait for a supplied in-fence in
> msm_ioctl_gem_submit, make sure we release that in-fence.
> 
> Also remove this dma_fence_put() from the 'out' label.
> 
> Signed-off-by: Robert Foss <robert.foss@collabora.com>
> ---
>  drivers/gpu/drm/msm/msm_gem_submit.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> index a90aedd6883a..3e7704af5b24 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> @@ -411,7 +411,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>         struct msm_file_private *ctx = file->driver_priv;
>         struct msm_gem_submit *submit;
>         struct msm_gpu *gpu = priv->gpu;
> -       struct dma_fence *in_fence = NULL;
>         struct sync_file *sync_file = NULL;
>         struct msm_gpu_submitqueue *queue;
>         struct msm_ringbuffer *ring;
> @@ -444,7 +443,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>         ring = gpu->rb[queue->prio];
>  
>         if (args->flags & MSM_SUBMIT_FENCE_FD_IN) {
> -               in_fence = sync_file_get_fence(args->fence_fd);
> +               struct dma_fence *in_fence = sync_file_get_fence(
> +                       args->fence_fd);
>  
>                 if (!in_fence)
>                         return -EINVAL;
> @@ -455,8 +455,10 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>                  */
>                 if (!dma_fence_match_context(in_fence, ring->fctx->context)) {
>                         ret = dma_fence_wait(in_fence, true);
> -                       if (ret)
> +                       if (ret) {
> +                               dma_fence_put(in_fence);
>                                 return ret;
> +                       }
>                 }

Careful, we need to keep the put for the normal path. Maybe,

if (args->flags & MSM_SUBMIT_FENCE_FD_IN) {
	struct dma_fence *in_fence;

	in_fence = sync_file_get_fence(args->fence_fd); // keep line breaks natural
	if (!in_fence)
		return -EINVAL;
	
	ret = 0;
	if (!dma_fence_match_match_context(in_fence, ring->fctx->context)
		ret = dma_fence_wait(in_fence, true);
	dma_fence_put(in_fence);
	if (ret)
		return ret;
}

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

* Re: [PATCH v1] drm/msm: Move fence put to where failure occurs
  2018-11-01 16:26 ` Chris Wilson
@ 2018-11-01 17:08   ` Robert Foss
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Foss @ 2018-11-01 17:08 UTC (permalink / raw)
  To: Chris Wilson, airlied, dri-devel, freedreno, linux-arm-msm,
	linux-kernel, robdclark

Hey Chris,

On 2018-11-01 17:26, Chris Wilson wrote:
> Quoting Robert Foss (2018-11-01 16:12:28)
>> If dma_fence_wait fails to wait for a supplied in-fence in
>> msm_ioctl_gem_submit, make sure we release that in-fence.
>>
>> Also remove this dma_fence_put() from the 'out' label.
>>
>> Signed-off-by: Robert Foss <robert.foss@collabora.com>
>> ---
>>   drivers/gpu/drm/msm/msm_gem_submit.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
>> index a90aedd6883a..3e7704af5b24 100644
>> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
>> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
>> @@ -411,7 +411,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>>          struct msm_file_private *ctx = file->driver_priv;
>>          struct msm_gem_submit *submit;
>>          struct msm_gpu *gpu = priv->gpu;
>> -       struct dma_fence *in_fence = NULL;
>>          struct sync_file *sync_file = NULL;
>>          struct msm_gpu_submitqueue *queue;
>>          struct msm_ringbuffer *ring;
>> @@ -444,7 +443,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>>          ring = gpu->rb[queue->prio];
>>   
>>          if (args->flags & MSM_SUBMIT_FENCE_FD_IN) {
>> -               in_fence = sync_file_get_fence(args->fence_fd);
>> +               struct dma_fence *in_fence = sync_file_get_fence(
>> +                       args->fence_fd);
>>   
>>                  if (!in_fence)
>>                          return -EINVAL;
>> @@ -455,8 +455,10 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>>                   */
>>                  if (!dma_fence_match_context(in_fence, ring->fctx->context)) {
>>                          ret = dma_fence_wait(in_fence, true);
>> -                       if (ret)
>> +                       if (ret) {
>> +                               dma_fence_put(in_fence);
>>                                  return ret;
>> +                       }
>>                  }
> 
> Careful, we need to keep the put for the normal path. Maybe,

Good catch, I'll send out a fixed version tomorrow.

> 
> if (args->flags & MSM_SUBMIT_FENCE_FD_IN) {
> 	struct dma_fence *in_fence;
> 
> 	in_fence = sync_file_get_fence(args->fence_fd); // keep line breaks natural
> 	if (!in_fence)
> 		return -EINVAL;
> 	
> 	ret = 0;
> 	if (!dma_fence_match_match_context(in_fence, ring->fctx->context)
> 		ret = dma_fence_wait(in_fence, true);
> 	dma_fence_put(in_fence);
> 	if (ret)
> 		return ret;
> }
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 

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

end of thread, other threads:[~2018-11-01 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01 16:12 [PATCH v1] drm/msm: Move fence put to where failure occurs Robert Foss
2018-11-01 16:26 ` Chris Wilson
2018-11-01 17:08   ` Robert Foss

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