linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/msm: Move fence put to where failure occurs
@ 2018-11-02 12:13 Robert Foss
  2018-11-02 12:16 ` Chris Wilson
  2018-11-02 12:29 ` Robert Foss
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Foss @ 2018-11-02 12:13 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>
---
Changes since v1:
 - Chris Wilson: Make sure that dma_fence_put() is always executed


 drivers/gpu/drm/msm/msm_gem_submit.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index a90aedd6883a..d5e6665a4c8f 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,6 +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) {
+		struct dma_fence *in_fence;
+
 		in_fence = sync_file_get_fence(args->fence_fd);
 
 		if (!in_fence)
@@ -453,11 +454,13 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 		 * Wait if the fence is from a foreign context, or if the fence
 		 * array contains any fence from a foreign context.
 		 */
-		if (!dma_fence_match_context(in_fence, ring->fctx->context)) {
+		ret = 0;
+		if (!dma_fence_match_context(in_fence, ring->fctx->context))
 			ret = dma_fence_wait(in_fence, true);
-			if (ret)
-				return ret;
-		}
+
+		dma_fence_put(in_fence);
+		if (ret)
+			return ret;
 	}
 
 	ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -583,8 +586,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] 5+ messages in thread

* Re: [PATCH v2] drm/msm: Move fence put to where failure occurs
  2018-11-02 12:13 [PATCH v2] drm/msm: Move fence put to where failure occurs Robert Foss
@ 2018-11-02 12:16 ` Chris Wilson
  2018-11-02 12:30   ` Robert Foss
  2018-11-02 12:29 ` Robert Foss
  1 sibling, 1 reply; 5+ messages in thread
From: Chris Wilson @ 2018-11-02 12:16 UTC (permalink / raw)
  To: Robert Foss, airlied, dri-devel, freedreno, linux-arm-msm,
	linux-kernel, robdclark
  Cc: Robert Foss

Quoting Robert Foss (2018-11-02 12:13:13)
> 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>

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Rob, this probably merits a cc:stable tag -- if the wait was interrupted
by a signal, the fence would be leaked.
-Chris

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

* Re: [PATCH v2] drm/msm: Move fence put to where failure occurs
  2018-11-02 12:13 [PATCH v2] drm/msm: Move fence put to where failure occurs Robert Foss
  2018-11-02 12:16 ` Chris Wilson
@ 2018-11-02 12:29 ` Robert Foss
  2018-11-02 13:13   ` Greg KH
  1 sibling, 1 reply; 5+ messages in thread
From: Robert Foss @ 2018-11-02 12:29 UTC (permalink / raw)
  To: robdclark, airlied, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, Chris Wilson
  Cc: stable

+stable

On 2018-11-02 13:13, Robert Foss wrote:
> 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>
> ---
> Changes since v1:
>   - Chris Wilson: Make sure that dma_fence_put() is always executed
> 
> 
>   drivers/gpu/drm/msm/msm_gem_submit.c | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> index a90aedd6883a..d5e6665a4c8f 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,6 +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) {
> +		struct dma_fence *in_fence;
> +
>   		in_fence = sync_file_get_fence(args->fence_fd);
>   
>   		if (!in_fence)
> @@ -453,11 +454,13 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>   		 * Wait if the fence is from a foreign context, or if the fence
>   		 * array contains any fence from a foreign context.
>   		 */
> -		if (!dma_fence_match_context(in_fence, ring->fctx->context)) {
> +		ret = 0;
> +		if (!dma_fence_match_context(in_fence, ring->fctx->context))
>   			ret = dma_fence_wait(in_fence, true);
> -			if (ret)
> -				return ret;
> -		}
> +
> +		dma_fence_put(in_fence);
> +		if (ret)
> +			return ret;
>   	}
>   
>   	ret = mutex_lock_interruptible(&dev->struct_mutex);
> @@ -583,8 +586,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);
> 

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

* Re: [PATCH v2] drm/msm: Move fence put to where failure occurs
  2018-11-02 12:16 ` Chris Wilson
@ 2018-11-02 12:30   ` Robert Foss
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Foss @ 2018-11-02 12:30 UTC (permalink / raw)
  To: Chris Wilson, dri-devel, freedreno, linux-arm-msm, linux-kernel

Hey Chris,

On 2018-11-02 13:16, Chris Wilson wrote:
> Quoting Robert Foss (2018-11-02 12:13:13)
>> 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>
> 
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Danke!

> 
> Rob, this probably merits a cc:stable tag -- if the wait was interrupted
> by a signal, the fence would be leaked.

Ack, CC-ed the v2 submission.


Rob.

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

* Re: [PATCH v2] drm/msm: Move fence put to where failure occurs
  2018-11-02 12:29 ` Robert Foss
@ 2018-11-02 13:13   ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2018-11-02 13:13 UTC (permalink / raw)
  To: Robert Foss
  Cc: robdclark, airlied, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, Chris Wilson, stable

On Fri, Nov 02, 2018 at 01:29:25PM +0100, Robert Foss wrote:
> +stable

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

end of thread, other threads:[~2018-11-02 13:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-02 12:13 [PATCH v2] drm/msm: Move fence put to where failure occurs Robert Foss
2018-11-02 12:16 ` Chris Wilson
2018-11-02 12:30   ` Robert Foss
2018-11-02 12:29 ` Robert Foss
2018-11-02 13:13   ` Greg KH

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