diff mbox

drm/msm: for array in-fences, check if all backing fences are from our own context before waiting

Message ID 20170317183840.7491-1-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Philipp Zabel March 17, 2017, 6:38 p.m. UTC
Use the dma_fence_match_context helper to check if all backing fences
are from our own context, in which case we don't have to wait.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Gustavo Padovan <gustavo.padovan@collabora.com>
---
Not sure if this can be handled exactly the same as for etnaviv. This depends on
d5b72a2123df ("dma-fence: add dma_fence_match_context helper").
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Rob Clark March 18, 2017, 12:48 p.m. UTC | #1
On Fri, Mar 17, 2017 at 2:38 PM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Use the dma_fence_match_context helper to check if all backing fences
> are from our own context, in which case we don't have to wait.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Gustavo Padovan <gustavo.padovan@collabora.com>
> ---
> Not sure if this can be handled exactly the same as for etnaviv. This depends on
> d5b72a2123df ("dma-fence: add dma_fence_match_context helper").

Thanks, the helper is a nice improvement.  I'll pull this in when the
dma-fence patch lands (seems not to be in drm-next yet)..  and also
maybe shorten up the subject line a bit ;-)

BR,
-R

> ---
>  drivers/gpu/drm/msm/msm_gem_submit.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> index 1172fe7a9252c..507a6f5b911f0 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> @@ -439,17 +439,15 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>                         goto out;
>                 }
>
> -               /* TODO if we get an array-fence due to userspace merging multiple
> -                * fences, we need a way to determine if all the backing fences
> -                * are from our own context..
> +               /*
> +                * Wait if the fence is from a foreign context, or if the fence
> +                * array contains any fence from a foreign context.
>                  */
> -
> -               if (in_fence->context != gpu->fctx->context) {
> +               if (!dma_fence_match_context(in_fence, gpu->fctx->context)) {
>                         ret = dma_fence_wait(in_fence, true);
>                         if (ret)
>                                 goto out;
>                 }
> -
>         }
>
>         if (!(args->fence & MSM_SUBMIT_NO_IMPLICIT)) {
> --
> 2.11.0
>
Philipp Zabel March 20, 2017, 10:10 a.m. UTC | #2
On Sat, 2017-03-18 at 08:48 -0400, Rob Clark wrote:
> On Fri, Mar 17, 2017 at 2:38 PM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> > Use the dma_fence_match_context helper to check if all backing fences
> > are from our own context, in which case we don't have to wait.
> >
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > Cc: Rob Clark <robdclark@gmail.com>
> > Cc: Gustavo Padovan <gustavo.padovan@collabora.com>
> > ---
> > Not sure if this can be handled exactly the same as for etnaviv. This depends on
> > d5b72a2123df ("dma-fence: add dma_fence_match_context helper").
> 
> Thanks, the helper is a nice improvement.  I'll pull this in when the
> dma-fence patch lands (seems not to be in drm-next yet)..  and also
> maybe shorten up the subject line a bit ;-)

Yes, thank you :)

regards
Philipp
diff mbox

Patch

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 1172fe7a9252c..507a6f5b911f0 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -439,17 +439,15 @@  int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 			goto out;
 		}
 
-		/* TODO if we get an array-fence due to userspace merging multiple
-		 * fences, we need a way to determine if all the backing fences
-		 * are from our own context..
+		/*
+		 * Wait if the fence is from a foreign context, or if the fence
+		 * array contains any fence from a foreign context.
 		 */
-
-		if (in_fence->context != gpu->fctx->context) {
+		if (!dma_fence_match_context(in_fence, gpu->fctx->context)) {
 			ret = dma_fence_wait(in_fence, true);
 			if (ret)
 				goto out;
 		}
-
 	}
 
 	if (!(args->fence & MSM_SUBMIT_NO_IMPLICIT)) {