For upcoming blob resources, userspace can specify that the
resource will be used for cross-device sharing. This is mainly
for exportable blobs that will only shared with the virtgpu
display but not across devices.

Signed-off-by: Gurchetan Singh <gurchetansi...@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.viz...@collabora.com>
---
 drivers/gpu/drm/virtio/virtgpu_drv.h   |  2 ++
 drivers/gpu/drm/virtio/virtgpu_prime.c | 42 ++++++++++++++++++--------
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h 
b/drivers/gpu/drm/virtio/virtgpu_drv.h
index e1143a00017c5..bbbe28f8b9436 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -432,6 +432,8 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo);
 int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
                               uint32_t *resid);
 /* virtgpu_prime.c */
+int virtio_gpu_resource_assign_uuid(struct virtio_gpu_device *vgdev,
+                                   struct virtio_gpu_object *bo);
 struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
                                         int flags);
 struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev,
diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c 
b/drivers/gpu/drm/virtio/virtgpu_prime.c
index 3552db128ba3d..1ef1e2f226333 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -59,6 +59,24 @@ const struct virtio_dma_buf_ops virtgpu_dmabuf_ops =  {
        .get_uuid = virtgpu_virtio_get_uuid,
 };
 
+int virtio_gpu_resource_assign_uuid(struct virtio_gpu_device *vgdev,
+                                   struct virtio_gpu_object *bo)
+{
+       int ret;
+       struct virtio_gpu_object_array *objs;
+
+       objs = virtio_gpu_array_alloc(1);
+       if (!objs)
+               return -ENOMEM;
+
+       virtio_gpu_array_add_obj(objs, &bo->base.base);
+       ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
                                         int flags)
 {
@@ -66,22 +84,20 @@ struct dma_buf *virtgpu_gem_prime_export(struct 
drm_gem_object *obj,
        struct drm_device *dev = obj->dev;
        struct virtio_gpu_device *vgdev = dev->dev_private;
        struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
-       struct virtio_gpu_object_array *objs;
        int ret = 0;
+       bool blob = bo->host3d_blob || bo->guest_blob;
        DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
 
-       if (vgdev->has_resource_assign_uuid) {
-               objs = virtio_gpu_array_alloc(1);
-               if (!objs)
-                       return ERR_PTR(-ENOMEM);
-               virtio_gpu_array_add_obj(objs, &bo->base.base);
-
-               ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs);
-               if (ret)
-                       return ERR_PTR(ret);
-               virtio_gpu_notify(vgdev);
-       } else {
-               bo->uuid_state = STATE_ERR;
+       if (!blob) {
+               if (vgdev->has_resource_assign_uuid) {
+                       ret = virtio_gpu_resource_assign_uuid(vgdev, bo);
+                       if (ret)
+                               return ERR_PTR(ret);
+
+                       virtio_gpu_notify(vgdev);
+               } else {
+                       bo->uuid_state = STATE_ERR;
+               }
        }
 
        exp_info.ops = &virtgpu_dmabuf_ops.ops;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to