[Mesa-dev] EXT_image_dma_buf_import FD ownership

John Sheu sheu at google.com
Sat Oct 12 00:29:39 CEST 2013


Hello folks:

About the ownership of dmabuf file descriptors that are passed into EGL.
 I'm looking in particular at this blurb from the spec:

       * If <target> is EGL_LINUX_DMA_BUF_EXT and eglCreateImageKHR fails,
         EGL does not retain ownership of the file descriptor and it is the
         responsibility of the application to close it."

My take on this is that this is different from most users of dmabuf, or
even file descriptors in general.  For example, mmap() doesn't own the
descriptor passed to it; and more specifically to dmabufs, neither does
(say) DRM_IOCTL_PRIME_HANDLE_TO_FD, or any of the V4L2 entry points that
support dmabuf (e.g. VIDIOC_QBUF).  They all increment the refcount on the
descriptor, not own it.

Since we're still iterating drafts on the EXT_image_dma_buf_import spec --
I'd like to see the spec specify that EGL has the similar behavior of
taking a reference, but not owning the descriptor.

As far as I see, in Mesa, only the Intel stack has
implemented EXT_image_dma_buf_import, and the change would be fairly
trivial (removing dri2_take_dma_buf_ownership), since it eventually just
passes the FD down to DRM_IOCTL_PRIME_HANDLE_TO_FD.  And as far as I'm
aware, the piglit conformance tests are the only present consumers.  (Maybe
the Wayland folks have something to say about this too.)  Hopefully the
extension's still at a stage where we can fix up this inconsistency.

-John Sheu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131011/acb841ab/attachment.html>


More information about the mesa-dev mailing list