mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
drm/virtio: Support virtgpu exported resources
Add support for UUID-based resource sharing mechanism to virtgpu. This implements the new virtgpu commands and hooks them up to dma-buf's get_uuid callback. Signed-off-by: David Stevens <stevensd@chromium.org> Acked-by: Michael S. Tsirkin <mst@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200818071343.3461203-4-stevensd@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
592d9fba33
commit
c84adb304c
5 changed files with 176 additions and 3 deletions
|
@ -1107,3 +1107,58 @@ void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev,
|
|||
memcpy(cur_p, &output->cursor, sizeof(output->cursor));
|
||||
virtio_gpu_queue_cursor(vgdev, vbuf);
|
||||
}
|
||||
|
||||
static void virtio_gpu_cmd_resource_uuid_cb(struct virtio_gpu_device *vgdev,
|
||||
struct virtio_gpu_vbuffer *vbuf)
|
||||
{
|
||||
struct virtio_gpu_object *obj =
|
||||
gem_to_virtio_gpu_obj(vbuf->objs->objs[0]);
|
||||
struct virtio_gpu_resp_resource_uuid *resp =
|
||||
(struct virtio_gpu_resp_resource_uuid *)vbuf->resp_buf;
|
||||
uint32_t resp_type = le32_to_cpu(resp->hdr.type);
|
||||
|
||||
spin_lock(&vgdev->resource_export_lock);
|
||||
WARN_ON(obj->uuid_state != UUID_INITIALIZING);
|
||||
|
||||
if (resp_type == VIRTIO_GPU_RESP_OK_RESOURCE_UUID &&
|
||||
obj->uuid_state == UUID_INITIALIZING) {
|
||||
memcpy(&obj->uuid.b, resp->uuid, sizeof(obj->uuid.b));
|
||||
obj->uuid_state = UUID_INITIALIZED;
|
||||
} else {
|
||||
obj->uuid_state = UUID_INITIALIZATION_FAILED;
|
||||
}
|
||||
spin_unlock(&vgdev->resource_export_lock);
|
||||
|
||||
wake_up_all(&vgdev->resp_wq);
|
||||
}
|
||||
|
||||
int
|
||||
virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
|
||||
struct virtio_gpu_object_array *objs)
|
||||
{
|
||||
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
|
||||
struct virtio_gpu_resource_assign_uuid *cmd_p;
|
||||
struct virtio_gpu_vbuffer *vbuf;
|
||||
struct virtio_gpu_resp_resource_uuid *resp_buf;
|
||||
|
||||
resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
|
||||
if (!resp_buf) {
|
||||
spin_lock(&vgdev->resource_export_lock);
|
||||
bo->uuid_state = UUID_INITIALIZATION_FAILED;
|
||||
spin_unlock(&vgdev->resource_export_lock);
|
||||
virtio_gpu_array_put_free(objs);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cmd_p = virtio_gpu_alloc_cmd_resp
|
||||
(vgdev, virtio_gpu_cmd_resource_uuid_cb, &vbuf, sizeof(*cmd_p),
|
||||
sizeof(struct virtio_gpu_resp_resource_uuid), resp_buf);
|
||||
memset(cmd_p, 0, sizeof(*cmd_p));
|
||||
|
||||
cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID);
|
||||
cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
|
||||
|
||||
vbuf->objs = objs;
|
||||
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue