提交 1e2554f4 编写于 作者: G Gurchetan Singh 提交者: Gerd Hoffmann

drm/virtio: implement blob resources: refactor UUID code somewhat

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: NGurchetan Singh <gurchetansingh@chromium.org>
Acked-by: NTomeu Vizoso <tomeu.vizoso@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-15-gurchetansingh@chromium.orgSigned-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 0b0f1afe
...@@ -432,6 +432,8 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo); ...@@ -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, int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
uint32_t *resid); uint32_t *resid);
/* virtgpu_prime.c */ /* 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, struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
int flags); int flags);
struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev,
......
...@@ -59,6 +59,24 @@ const struct virtio_dma_buf_ops virtgpu_dmabuf_ops = { ...@@ -59,6 +59,24 @@ const struct virtio_dma_buf_ops virtgpu_dmabuf_ops = {
.get_uuid = virtgpu_virtio_get_uuid, .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, struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
int flags) int flags)
{ {
...@@ -66,22 +84,20 @@ struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj, ...@@ -66,22 +84,20 @@ struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
struct drm_device *dev = obj->dev; struct drm_device *dev = obj->dev;
struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
struct virtio_gpu_object_array *objs;
int ret = 0; int ret = 0;
bool blob = bo->host3d_blob || bo->guest_blob;
DEFINE_DMA_BUF_EXPORT_INFO(exp_info); DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
if (vgdev->has_resource_assign_uuid) { if (!blob) {
objs = virtio_gpu_array_alloc(1); if (vgdev->has_resource_assign_uuid) {
if (!objs) ret = virtio_gpu_resource_assign_uuid(vgdev, bo);
return ERR_PTR(-ENOMEM); if (ret)
virtio_gpu_array_add_obj(objs, &bo->base.base); return ERR_PTR(ret);
ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs); virtio_gpu_notify(vgdev);
if (ret) } else {
return ERR_PTR(ret); bo->uuid_state = STATE_ERR;
virtio_gpu_notify(vgdev); }
} else {
bo->uuid_state = STATE_ERR;
} }
exp_info.ops = &virtgpu_dmabuf_ops.ops; exp_info.ops = &virtgpu_dmabuf_ops.ops;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册