virgl/gbm: exported read/writable buffers

With old DRM implementations, drmPrimeHandleToFD always returned a fd
that could be mapped read/write. However, new kernels require the
DRM_RDWR flag to be specified to create read/write mappings.

Try passing the DRM_RDWR flag but fall back to the old way if that
fails.

Signed-off-by: David Stevens <stevensd@chromium.org>
Acked-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
David Stevens 5 years ago
parent a46624628a
commit 1a73838b1f
  1. 12
      src/virgl_gbm.c

@ -400,10 +400,16 @@ int virgl_gbm_export_query(struct gbm_bo *bo, struct virgl_renderer_export_query
if (i == query->out_num_fds) {
if (query->in_export_fds) {
ret = drmPrimeHandleToFD(gbm_device_get_fd(gbm), handle, DRM_CLOEXEC,
ret = drmPrimeHandleToFD(gbm_device_get_fd(gbm), handle, DRM_CLOEXEC | DRM_RDWR,
&query->out_fds[query->out_num_fds]);
if (ret)
goto err_close;
// Kernels with older DRM core versions block DRM_RDWR but give a
// read/write mapping anyway.
if (ret) {
ret = drmPrimeHandleToFD(gbm_device_get_fd(gbm), handle, DRM_CLOEXEC,
&query->out_fds[query->out_num_fds]);
if (ret)
goto err_close;
}
}
query->out_num_fds++;
}

Loading…
Cancel
Save