freedreno/drm, turnip: set DRM_RDWR for exported dma-bufs

This allows the exported fds to be mapped for writing.  My use case is
for virtio-gpu blob resources where the fds are mapped rw and mappings
are added to the guests using KVM_SET_USER_MEMORY_REGION.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14699>
This commit is contained in:
Chia-I Wu
2022-01-24 17:30:23 -08:00
committed by Marge Bot
parent bdf1163c2a
commit ef325d4650
2 changed files with 3 additions and 2 deletions

View File

@@ -416,7 +416,8 @@ fd_bo_dmabuf(struct fd_bo *bo)
{
int ret, prime_fd;
ret = drmPrimeHandleToFD(bo->dev->fd, bo->handle, DRM_CLOEXEC, &prime_fd);
ret = drmPrimeHandleToFD(bo->dev->fd, bo->handle, DRM_CLOEXEC | DRM_RDWR,
&prime_fd);
if (ret) {
ERROR_MSG("failed to get dmabuf fd: %d", ret);
return ret;

View File

@@ -288,7 +288,7 @@ tu_bo_export_dmabuf(struct tu_device *dev, struct tu_bo *bo)
{
int prime_fd;
int ret = drmPrimeHandleToFD(dev->fd, bo->gem_handle,
DRM_CLOEXEC, &prime_fd);
DRM_CLOEXEC | DRM_RDWR, &prime_fd);
return ret == 0 ? prime_fd : -1;
}