FreeBSDDesktop / kms-drm

the DRM part of the linuxkpi-based KMS
63 stars 26 forks source link

DMA_BUF_IOCTL_SYNC doesn't work #156

Open jbeich opened 5 years ago

jbeich commented 5 years ago

EDIT: Description has been rewritten as the initial test case was incorrect.

Waypipe (package, workaround) relies on DMA_BUF_IOCTL_SYNC to check if a given file descripter is backed by DMABUF. On FreeBSD the ioctl always fails with EBADF which is unexpected according to the implementation: https://github.com/FreeBSDDesktop/kms-drm/blob/e31e5fc502d190ad488baec4ba2658db945b95e3/linuxkpi/gplv2/src/linux_dmabuf.c#L215-L260

Test case: https://gitlab.freedesktop.org/snippets/621

mstoeckl commented 5 years ago

The invalid flags used by waypipe are something of a hack, for lack of an easier way to generically detect DMABUFs on Linux without trying to import with GBM or using driver-specific code.

Also, FYI, the Linux version is https://github.com/torvalds/linux/blob/master/drivers/dma-buf/dma-buf.c#L279.

Edit: The sample code tries the ioctl on an fd for a render node, not for a DMABUF.

jbeich commented 2 years ago

Can someone try reproducing using DMA-BUF reimplementation ? drm-subtree doesn't seem to have i915 or amdgpu, so testing on amd64 is not currently possible.

mstoeckl commented 2 years ago

For future reference: Waypipe no longer relies on this behavior on FreeBSD, since v0.8.0, which was released more than a year ago. As of recent git commits, it has also stopped using the EBADF hack on Linux.