Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio-gpu api: multiple context types with explicit initialization

This feature allows for each virtio-gpu 3D context to be created
with a "context_init" variable. This variable can specify:

- the type of protocol used by the context via the capset id.
This is useful for differentiating virgl, gfxstream, and venus
protocols by host userspace.

- other things in the future, such as the version of the context.

In addition, each different context needs one or more timelines, so
for example a virgl context's waiting can be independent on a
gfxstream context's waiting.

VIRTIO_GPU_FLAG_INFO_RING_IDX is introduced to specific to tell the
host which per-context command ring (or "hardware queue", distinct
from the virtio-queue) the fence should be associated with.

The new capability sets (gfxstream, venus etc.) are only defined in
the virtio-gpu spec and not defined in the header.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Lingfeng Yang <lfy@google.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210921232024.817-2-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

authored by

Gurchetan Singh and committed by
Gerd Hoffmann
34268c9d 93ee1a2c

+15 -3
+15 -3
include/uapi/linux/virtio_gpu.h
··· 59 59 * VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB 60 60 */ 61 61 #define VIRTIO_GPU_F_RESOURCE_BLOB 3 62 + /* 63 + * VIRTIO_GPU_CMD_CREATE_CONTEXT with 64 + * context_init and multiple timelines 65 + */ 66 + #define VIRTIO_GPU_F_CONTEXT_INIT 4 62 67 63 68 enum virtio_gpu_ctrl_type { 64 69 VIRTIO_GPU_UNDEFINED = 0, ··· 127 122 VIRTIO_GPU_SHM_ID_HOST_VISIBLE = 1 128 123 }; 129 124 130 - #define VIRTIO_GPU_FLAG_FENCE (1 << 0) 125 + #define VIRTIO_GPU_FLAG_FENCE (1 << 0) 126 + /* 127 + * If the following flag is set, then ring_idx contains the index 128 + * of the command ring that needs to used when creating the fence 129 + */ 130 + #define VIRTIO_GPU_FLAG_INFO_RING_IDX (1 << 1) 131 131 132 132 struct virtio_gpu_ctrl_hdr { 133 133 __le32 type; 134 134 __le32 flags; 135 135 __le64 fence_id; 136 136 __le32 ctx_id; 137 - __le32 padding; 137 + __u8 ring_idx; 138 + __u8 padding[3]; 138 139 }; 139 140 140 141 /* data passed in the cursor vq */ ··· 280 269 }; 281 270 282 271 /* VIRTIO_GPU_CMD_CTX_CREATE */ 272 + #define VIRTIO_GPU_CONTEXT_INIT_CAPSET_ID_MASK 0x000000ff 283 273 struct virtio_gpu_ctx_create { 284 274 struct virtio_gpu_ctrl_hdr hdr; 285 275 __le32 nlen; 286 - __le32 padding; 276 + __le32 context_init; 287 277 char debug_name[64]; 288 278 }; 289 279