All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v3] drm/msm: Move fence put to where failure occurs
@ 2018-12-04 16:56 Robert Foss
  2018-12-04 20:21 ` Rob Clark
       [not found] ` <20181204215331.595E720672@mail.kernel.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Foss @ 2018-12-04 16:56 UTC (permalink / raw)
  To: robdclark, airlied, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, Chris Wilson
  Cc: Greg KH, Robert Foss, stable

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>
Cc: stable@vger.kernel.org
---
 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: [RESEND PATCH v3] drm/msm: Move fence put to where failure occurs
  2018-12-04 16:56 [RESEND PATCH v3] drm/msm: Move fence put to where failure occurs Robert Foss
@ 2018-12-04 20:21 ` Rob Clark
       [not found]   ` <CAF6AEGt+SJPoTChr=zn+g8Vth_F_D39EmWGXpo3qbsUgL=638A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
       [not found] ` <20181204215331.595E720672@mail.kernel.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Rob Clark @ 2018-12-04 20:21 UTC (permalink / raw)
  To: Robert Foss
  Cc: David Airlie, linux-arm-msm, dri-devel, freedreno,
	Linux Kernel Mailing List, Chris Wilson, Greg KH, stable

On Tue, Dec 4, 2018 at 11:56 AM Robert Foss <robert.foss@collabora.com> 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>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: stable@vger.kernel.org

Fyi, this is queued up in msm-next/fixes

BR,
-R


> ---
>  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	[flat|nested] 5+ messages in thread

* Re: [RESEND PATCH v3] drm/msm: Move fence put to where failure occurs
  2018-12-04 20:21 ` Rob Clark
@ 2018-12-05 10:36       ` Robert Foss
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Foss @ 2018-12-05 10:36 UTC (permalink / raw)
  To: Rob Clark
  Cc: David Airlie, linux-arm-msm, Linux Kernel Mailing List,
	dri-devel, Chris Wilson, stable, Greg KH, freedreno



On 2018-12-04 21:21, Rob Clark wrote:
> On Tue, Dec 4, 2018 at 11:56 AM Robert Foss <robert.foss@collabora.com> 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>
>> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: stable@vger.kernel.org
> 
> Fyi, this is queued up in msm-next/fixes

Ah!

I had a look for it in drm=misc-next, but didn't find it.
Thanks for the heads up!

> 
> BR,
> -R
> 
> 
>> ---
>>   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
>>
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

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

* Re: [RESEND PATCH v3] drm/msm: Move fence put to where failure occurs
@ 2018-12-05 10:36       ` Robert Foss
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Foss @ 2018-12-05 10:36 UTC (permalink / raw)
  To: Rob Clark
  Cc: David Airlie, linux-arm-msm, dri-devel, freedreno,
	Linux Kernel Mailing List, Chris Wilson, Greg KH, stable



On 2018-12-04 21:21, Rob Clark wrote:
> On Tue, Dec 4, 2018 at 11:56 AM Robert Foss <robert.foss@collabora.com> 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>
>> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: stable@vger.kernel.org
> 
> Fyi, this is queued up in msm-next/fixes

Ah!

I had a look for it in drm=misc-next, but didn't find it.
Thanks for the heads up!

> 
> BR,
> -R
> 
> 
>> ---
>>   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	[flat|nested] 5+ messages in thread

* Re: [RESEND PATCH v3] drm/msm: Move fence put to where failure occurs
       [not found] ` <20181204215331.595E720672@mail.kernel.org>
@ 2018-12-05 13:23   ` Robert Foss
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Foss @ 2018-12-05 13:23 UTC (permalink / raw)
  To: Sasha Levin, robdclark, airlied; +Cc: Greg KH, stable

Hey,

On 2018-12-04 22:53, Sasha Levin wrote:
> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a -stable tag.
> The stable tag indicates that it's relevant for the following trees: all
> 
> The bot has tested the following trees: v4.19.6, v4.14.85, v4.9.142, v4.4.166, v3.18.128,
> 
> v4.19.6: Build OK!
> v4.14.85: Failed to apply! Possible dependencies:
>      cd414f3d9316 ("drm/msm: Move memptrs to msm_gpu")
>      eec874ce5ff1 ("drm/msm/adreno: load gpu at probe/bind time")
>      f7de15450e90 ("drm/msm: Add per-instance submit queues")
>      f97decac5f4c ("drm/msm: Support multiple ringbuffers")


v4.14.85 can be rebased fairly cleanly:

https://gitlab.collabora.com/robertfoss/linux/commits/msm_in_fence_put_v3_v4.14.85


However v4.9.142 and earlier does not rebase very cleanly at all.
I don't know what the rule of thumb for backporting fixes is, but the feature 
that is fixed here does not seem to exist in v4.9.142 and earlier.


Rob.

> 
> v4.9.142: Failed to apply! Possible dependencies:
>      1cec20f0ea0e ("dma-buf: Restart reservation_object_wait_timeout_rcu() after writes")
>      78010cd9736e ("dma-buf/fence: add an lockdep_assert_held()")
>      f54d1867005c ("dma-buf: Rename struct fence to dma_fence")
>      fedf54132d24 ("dma-buf: Restart reservation_object_get_fences_rcu() after writes")
> 
> v4.4.166: Failed to apply! Possible dependencies:
>      0f477c6dea70 ("staging/android/sync: add sync_fence_create_dma")
>      31954660a7a6 ("dma-buf/sync_file: improve Kconfig description for Sync Files")
>      375fb53ec1be ("staging: android: replace explicit NULL comparison")
>      395dec6f6bc5 ("Documentation: add doc for sync_file_get_fence()")
>      62304fb1fc08 ("dma-buf/sync_file: de-stage sync_file")
>      696f74cf5439 ("staging/android: move sync_file functions comments to sync.c")
>      699f68556943 ("android: unconditionally remove callbacks in sync_fence_free()")
>      73465f1c0825 ("staging/android/sync: Support sync points created from dma-fences")
>      8a0044846115 ("staging/android: create a 'sync' dir for debugfs information")
>      9b32381ca50f ("staging/android: fix sync framework documentation")
>      a44eb74cd413 ("staging/android: move SW_SYNC_USER to a debugfs file")
>      b55b54b5db33 ("staging/android: remove struct sync_pt")
>      c01a958eca6e ("drm/msm: reject submit ioctl if no gpu")
>      c784c82a3fd6 ("Documentation: add Sync File doc")
>      cd572182bd3d ("Staging: android: Fix brace coding style warning in sync_debug.c")
>      d4cab38e153d ("staging/android: prepare sync_file for de-staging")
>      d7c3110c28de ("staging/android: remove name arg from sync_file_create()")
>      d7fdb0ae9d11 ("staging/android: rename sync_fence to sync_file")
>      f54d1867005c ("dma-buf: Rename struct fence to dma_fence")
>      fac8434dab96 ("Documentation: Fix some grammar mistakes in sync_file.txt")
> 
> v3.18.128: Failed to apply! Possible dependencies:
>      0541cdf585a8 ("Staging: android: fix line length coding style issue in sync_debug.c")
>      0f477c6dea70 ("staging/android/sync: add sync_fence_create_dma")
>      31954660a7a6 ("dma-buf/sync_file: improve Kconfig description for Sync Files")
>      353fdf17060b ("staging: android: Replace timeval with timespec64")
>      375fb53ec1be ("staging: android: replace explicit NULL comparison")
>      395dec6f6bc5 ("Documentation: add doc for sync_file_get_fence()")
>      62304fb1fc08 ("dma-buf/sync_file: de-stage sync_file")
>      699f68556943 ("android: unconditionally remove callbacks in sync_fence_free()")
>      73465f1c0825 ("staging/android/sync: Support sync points created from dma-fences")
>      8a0044846115 ("staging/android: create a 'sync' dir for debugfs information")
>      9b32381ca50f ("staging/android: fix sync framework documentation")
>      a44eb74cd413 ("staging/android: move SW_SYNC_USER to a debugfs file")
>      b8797affa142 ("staging: android: fix coding style checks in sw_sync.c")
>      c01a958eca6e ("drm/msm: reject submit ioctl if no gpu")
>      c784c82a3fd6 ("Documentation: add Sync File doc")
>      cd572182bd3d ("Staging: android: Fix brace coding style warning in sync_debug.c")
>      d30649a8b618 ("staging: android: Remove unnecessary externs")
>      d4cab38e153d ("staging/android: prepare sync_file for de-staging")
>      d7c3110c28de ("staging/android: remove name arg from sync_file_create()")
>      d7fdb0ae9d11 ("staging/android: rename sync_fence to sync_file")
>      db1ad33bcfc4 ("drivers/staging: make android sw_sync.c explicitly non-modular")
>      f54d1867005c ("dma-buf: Rename struct fence to dma_fence")
>      fac8434dab96 ("Documentation: Fix some grammar mistakes in sync_file.txt")
> 
> 
> How should we proceed with this patch?
> 
> --
> Thanks,
> Sasha
> 

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

end of thread, other threads:[~2018-12-05 13:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-04 16:56 [RESEND PATCH v3] drm/msm: Move fence put to where failure occurs Robert Foss
2018-12-04 20:21 ` Rob Clark
     [not found]   ` <CAF6AEGt+SJPoTChr=zn+g8Vth_F_D39EmWGXpo3qbsUgL=638A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-12-05 10:36     ` Robert Foss
2018-12-05 10:36       ` Robert Foss
     [not found] ` <20181204215331.595E720672@mail.kernel.org>
2018-12-05 13:23   ` Robert Foss

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.