vdrm+tu+fd: Make cross-device optional
Similar to commit087e9a96d1
("venus: make cross-device optional"), make VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE use optional, because qemu does not support this. Fixes:06e57e3231
("virtio: Add vdrm native-context helper") Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32392> (cherry picked from commitdfd519ed80
)
This commit is contained in:
@@ -1694,7 +1694,7 @@
|
||||
"description": "vdrm+tu+fd: Make cross-device optional",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "06e57e32310f51e752d7798e287400e8edc10312",
|
||||
"notes": null
|
||||
|
@@ -316,8 +316,9 @@ virtio_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags)
|
||||
|
||||
uint32_t blob_flags = 0;
|
||||
if (flags & (FD_BO_SHARED | FD_BO_SCANOUT)) {
|
||||
blob_flags = VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE |
|
||||
VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
|
||||
blob_flags = VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
|
||||
if (virtio_dev->vdrm->supports_cross_device)
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE;
|
||||
}
|
||||
|
||||
if (!(flags & FD_BO_NOMAP)) {
|
||||
|
@@ -667,8 +667,9 @@ virtio_bo_init(struct tu_device *dev,
|
||||
}
|
||||
|
||||
if (!(mem_property & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT)) {
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE |
|
||||
VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
|
||||
if (vdev->vdrm->supports_cross_device)
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE;
|
||||
}
|
||||
|
||||
if (flags & TU_BO_ALLOC_GPU_READ_ONLY)
|
||||
|
@@ -54,6 +54,7 @@ struct vdrm_device {
|
||||
const struct vdrm_device_funcs *funcs;
|
||||
|
||||
struct virgl_renderer_capset_drm caps;
|
||||
bool supports_cross_device;
|
||||
struct vdrm_shmem *shmem;
|
||||
uint8_t *rsp_mem;
|
||||
uint32_t rsp_mem_len;
|
||||
|
@@ -350,6 +350,20 @@ init_shmem(struct virtgpu_device *vgdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
get_param(int fd, uint64_t param)
|
||||
{
|
||||
/* val must be zeroed because kernel only writes the lower 32 bits */
|
||||
uint64_t val = 0;
|
||||
struct drm_virtgpu_getparam args = {
|
||||
.param = param,
|
||||
.value = (uintptr_t)&val,
|
||||
};
|
||||
|
||||
const int ret = virtgpu_ioctl(fd, VIRTGPU_GETPARAM, &args);
|
||||
return ret ? 0 : val;
|
||||
}
|
||||
|
||||
struct vdrm_device * vdrm_virtgpu_connect(int fd, uint32_t context_type);
|
||||
|
||||
struct vdrm_device *
|
||||
@@ -395,5 +409,12 @@ vdrm_virtgpu_connect(int fd, uint32_t context_type)
|
||||
vdev->caps = caps;
|
||||
vdev->funcs = &funcs;
|
||||
|
||||
/* Cross-device feature is optional. It enables sharing dma-bufs
|
||||
* with other virtio devices, like virtio-wl or virtio-video used
|
||||
* by ChromeOS VMs. Qemu doesn't support cross-device sharing.
|
||||
*/
|
||||
if (get_param(fd, VIRTGPU_PARAM_CROSS_DEVICE))
|
||||
vdev->supports_cross_device = true;
|
||||
|
||||
return vdev;
|
||||
}
|
||||
|
Reference in New Issue
Block a user