[Mesa-dev] [PATCH 08/13] todo! egl/dri2: Questions about sync fd ownership

Chris Wilson chris at chris-wilson.co.uk
Sat Jul 9 09:15:57 UTC 2016


On Fri, Jul 08, 2016 at 05:00:58PM -0700, Chad Versace wrote:
> See the comments.
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index c7b81ce..03ed4b9 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2412,6 +2412,18 @@ dri2_egl_unref_sync(struct dri2_egl_display *dri2_dpy,
>           cnd_destroy(&dri2_sync->cond);
>           break;
>        case EGL_SYNC_NATIVE_FENCE_ANDROID:
> +         /* TODO(chadv): We must take care to not double-close nor leak the
> +          * fd. To avoid double-close and leak, we need to carefully document
> +          * fd ownership and duplication rules.
> +          *
> +          * TODO(chadv): Document the decision at _EGLSync::SyncFd,
> +          *
> +          * FIXME(chadv): Potential bug. If we define that EGL (not the
> +          * driver) owns the fence fd created by the flush after
> +          * eglCreateSync(), we need to ensure the fd doesn't leak. Today, it
> +          * leaks if the user never calls eglDupNativeFenceFDANDROID() because
> +          * _EGLSync::SyncFd remains -1 forever.
> +          */

My suspicion is that you want to dup() on the boundaries so that both
parties have a unique fd that they own, and can reference count / close
independently. (The only challenge would language in the spec that
implied that FENCE_FROM_FD steals the fd, for example.)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the mesa-dev mailing list