virtio-gpu: CONTEXT_INIT feature
v3 cover virtio-gpu: CONTEXT_INIT feature
This is a different attempt at upstreaming the work I have been doing to enable support for the Venus Virtio-GPU Vulkan driver.
I believe the previous one [0] was a bit too much stuff in one place, therefore with this I would like to try a more fine-grained approach.
I will just start by the CONTEXT_INIT feature as it was the first commit of the series aforementioned and the virtio-spec has been updated recently on that regard [1]. Hopefully this would also answer Gerd's comment on the previous patch [2].
[0] https://www.mail-archive.com/[email protected]/msg826897.html
[1] https://github.com/oasis-tcs/virtio-spec/commit/aad2b6f3620ec0c9d16aaf046db8c282c24cce3e
[2] https://www.mail-archive.com/[email protected]/msg827304.html
Antonio Caggiano (1):
virtio-gpu: CONTEXT_INIT feature
hw/display/virtio-gpu-base.c | 3 +++ hw/display/virtio-gpu-virgl.c | 16 ++++++++++++++-- hw/display/virtio-gpu.c | 2 ++ include/hw/virtio/virtio-gpu.h | 3 +++ meson.build | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/1 virtio-gpu: CONTEXT_INIT feature
Create virgl renderer context with flags using context_id when valid.
v2:
- The feature can be enabled via the context_init config option.
- A warning message will be emitted and the feature will not be used when linking with virglrenderer versions without context_init support.
v3: Define HAVE_VIRGL_CONTEXT_INIT in config_host_data.
--- hw/display/virtio-gpu-base.c | 3 +++ hw/display/virtio-gpu-virgl.c | 16 ++++++++++++++-- hw/display/virtio-gpu.c | 2 ++ include/hw/virtio/virtio-gpu.h | 3 +++ meson.build | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-)
hw/display/virtio-gpu-base.c +3 -0
@@ -215,6 +215,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features,if (virtio_gpu_blob_enabled (g->conf)) { features |= (1 <<VIRTIO_GPU_F_RESOURCE_BLOB ); } +if (virtio_gpu_context_init_enabled (g->conf)) { + features |= (1 <<VIRTIO_GPU_F_CONTEXT_INIT ); + }return features; }
hw/display/virtio-gpu-virgl.c +14 -2
@@ -97,8 +97,20 @@ static void virgl_cmd_context_create(VirtIOGPU *g,trace_virtio_gpu_cmd_ctx_create (cc.hdr.ctx_id, cc.debug_name); -virgl_renderer_context_create (cc.hdr.ctx_id, cc.nlen, - cc.debug_name); +if (cc.context_init) { +#ifdef HAVE_VIRGL_CONTEXT_INIT +virgl_renderer_context_create_with_flags (cc.hdr.ctx_id, + cc.context_init, + cc.nlen, + cc.debug_name); +return ; +#else +qemu_log_mask (LOG_UNIMP , +"Linked virglrenderer does not support context-init\n" ); +#endif + } + +virgl_renderer_context_create (cc.hdr.ctx_id, cc.nlen, cc.debug_name); } static void virgl_cmd_context_destroy(VirtIOGPU *g,
hw/display/virtio-gpu.c +2 -0
@@ -1424,6 +1424,8 @@ static Property virtio_gpu_properties[] = { 256 * MiB),DEFINE_PROP_BIT ("blob" , VirtIOGPU, parent_obj.conf.flags,VIRTIO_GPU_FLAG_BLOB_ENABLED , false), +DEFINE_PROP_BIT ("context_init" , VirtIOGPU, parent_obj.conf.flags, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED , false), DEFINE_PROP_END_OF_LIST(), };
include/hw/virtio/virtio-gpu.h +3 -0
@@ -90,6 +90,7 @@ enum virtio_gpu_base_conf_flags {VIRTIO_GPU_FLAG_EDID_ENABLED ,VIRTIO_GPU_FLAG_DMABUF_ENABLED ,VIRTIO_GPU_FLAG_BLOB_ENABLED , + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, };#define virtio_gpu_virgl_enabled (_cfg) \
@@ -102,6 +103,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED))#define virtio_gpu_blob_enabled (_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled (_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED))struct virtio_gpu_base_conf {uint32_t max_outputs;
meson.build +5 -0
@@ -718,6 +718,11 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu method: 'pkg-config', required: get_option('virglrenderer'), kwargs: static_kwargs) + + config_host_data.set('HAVE_VIRGL_CONTEXT_INIT', + cc.has_function('virgl_renderer_context_create_with_flags', + prefix: '#include <virglrenderer.h>', + dependencies: virgl)) endif curl = not_found if not get_option('curl').auto() or have_block
Signature · 1 line
2.34.1
Hi
Quoted 45 lines · Antonio Caggiano
Create virgl renderer context with flags using
context_idwhen valid.v2:
- The feature can be enabled via thecontext_initconfig option.
- A warning message will be emitted and the feature will not be used when linking with virglrenderer versions withoutcontext_initsupport.v3: Define
HAVE_VIRGL_CONTEXT_INITinconfig_host_data.Signed-off-by Antonio Caggiano <[email protected]>--- hw/display/virtio-gpu-base.c | 3 +++ hw/display/virtio-gpu-virgl.c | 16 ++++++++++++++-- hw/display/virtio-gpu.c | 2 ++ include/hw/virtio/virtio-gpu.h | 3 +++ meson.build | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-)hw/display/virtio-gpu-base.c +3
-0@@ -215,6 +215,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 <<VIRTIO_GPU_F_RESOURCE_BLOB ); } +if (virtio_gpu_context_init_enabled (g->conf)) { + features |= (1 <<VIRTIO_GPU_F_CONTEXT_INIT ); + }return features;}
hw/display/virtio-gpu-virgl.c +2
-2@@ -97,8 +97,20 @@ static void virgl_cmd_context_create(VirtIOGPU *g,trace_virtio_gpu_cmd_ctx_create (cc.hdr.ctx_id, cc.debug_name); -virgl_renderer_context_create (cc.hdr.ctx_id, cc.nlen, - cc.debug_name); +if (cc.context_init) { +#ifdef HAVE_VIRGL_CONTEXT_INIT
hw/display/virtio-gpu-virgl.c static void virgl_cmd_context_create(VirtIOGPU *g, · line 111
Quoted 10 lines
hw/display/virtio-gpu-virgl.c +8
-0+virgl_renderer_context_create_with_flags (cc.hdr.ctx_id, + cc.context_init, + cc.nlen, + cc.debug_name); +return ; +#else + qemu_log_mask(LOG_UNIMP, + "Linked virglrenderer does not support context-init\n");
What is the outcome in that case?
Quoted 56 lines
hw/display/virtio-gpu-virgl.c +4
-0+#endif + } + +virgl_renderer_context_create (cc.hdr.ctx_id, cc.nlen, cc.debug_name); }static void virgl_cmd_context_destroy(VirtIOGPU *g,
hw/display/virtio-gpu.c +2
-0@@ -1424,6 +1424,8 @@ static Property virtio_gpu_properties[] = { 256 * MiB),DEFINE_PROP_BIT ("blob" , VirtIOGPU, parent_obj.conf.flags,VIRTIO_GPU_FLAG_BLOB_ENABLED , false), +DEFINE_PROP_BIT ("context_init" , VirtIOGPU, parent_obj.conf.flags, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED , false), DEFINE_PROP_END_OF_LIST(), };include/hw/virtio/virtio-gpu.h +3
-0@@ -90,6 +90,7 @@ enum virtio_gpu_base_conf_flags {VIRTIO_GPU_FLAG_EDID_ENABLED ,VIRTIO_GPU_FLAG_DMABUF_ENABLED ,VIRTIO_GPU_FLAG_BLOB_ENABLED , + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, };#define virtio_gpu_virgl_enabled (_cfg) \@@ -102,6 +103,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED))#define virtio_gpu_blob_enabled (_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled (_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED))struct virtio_gpu_base_conf {uint32_t max_outputs;meson.build +0
-0@@ -718,6 +718,11 @@ if not get_option('virglrenderer').auto() or
have_systemorhave_vhost_user_gpu
method: 'pkg-config',
required:get_option('virglrenderer'),
kwargs:static_kwargs)meson.build +4
-0+ + config_host_data.set('HAVE_VIRGL_CONTEXT_INIT', + cc.has_function('virgl_renderer_context_create_with_flags', + prefix: '#include
Quoted 10 lines
<
virglrenderer.h>',
+ dependencies: virgl))
endif
curl =not_found
if not get_option('curl').auto() orhave_block
--
2.34.1
lgtm
Signature · 1 line
Marc-André Lureau
Hi Marc-André,
Quoted 63 lines · Marc-André Lureau
Hi
On Fri, Aug 26, 2022 at 2:12 PM Antonio Caggiano <[email protected] <mailto:[email protected]>> wrote:
Create virgl renderer context with flags using context_id when valid. v2: - The feature can be enabled via the context_init config option. - A warning message will be emitted and the feature will not be used when linking with virglrenderer versions without context_init support. v3: Define HAVE_VIRGL_CONTEXT_INIT in config_host_data. Signed-off-by: Antonio Caggiano <[email protected] <mailto:[email protected]>> --- hw/display/virtio-gpu-base.c | 3 +++ hw/display/virtio-gpu-virgl.c | 16 ++++++++++++++-- hw/display/virtio-gpu.c | 2 ++ include/hw/virtio/virtio-gpu.h | 3 +++ meson.build | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index a29f191aa8..6c5f1f327f 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -215,6 +215,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } + if (virtio_gpu_context_init_enabled(g->conf)) { + features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); + } return features; } diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 73cb92c8d5..274cbc44de 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -97,8 +97,20 @@ static void virgl_cmd_context_create(VirtIOGPU *g, trace_virtio_gpu_cmd_ctx_create(cc.hdr.ctx_id, cc.debug_name); - virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, - cc.debug_name); + if (cc.context_init) { +#ifdef HAVE_VIRGL_CONTEXT_INIT + virgl_renderer_context_create_with_flags(cc.hdr.ctx_id, + cc.context_init, + cc.nlen, + cc.debug_name); + return; +#else + qemu_log_mask(LOG_UNIMP, + "Linked virglrenderer does not support context-init\n");
Quoted 1 line
What is the outcome in that case?
It's in the commit message: "A warning message will be emitted and the feature will not be used when linking with virglrenderer versions without context_init"
Quoted 73 lines
+#endif + } + + virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, cc.debug_name); } static void virgl_cmd_context_destroy(VirtIOGPU *g, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 20cc703dcc..fa667ec234 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1424,6 +1424,8 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), + DEFINE_PROP_BIT("context_init", VirtIOGPU, parent_obj.conf.flags, + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2e28507efe..c6f5cfde47 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -90,6 +90,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -102,6 +103,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; diff --git a/meson.build b/meson.build index 20fddbd707..e1071b3563 100644 --- a/meson.build +++ b/meson.build @@ -718,6 +718,11 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu method: 'pkg-config', required: get_option('virglrenderer'), kwargs: static_kwargs) + + config_host_data.set('HAVE_VIRGL_CONTEXT_INIT', + cc.has_function('virgl_renderer_context_create_with_flags', + prefix: '#include <virglrenderer.h>', + dependencies: virgl)) endif curl = not_found if not get_option('curl').auto() or have_block -- 2.34.1lgtm
Reviewed-by Marc-André Lureau <[email protected] <mailto:[email protected]>>Signature · 1 line
Marc-André Lureau
Hi
Quoted 70 lines · Antonio Caggiano
Hi Marc-André,
Quoted 27 lines · Marc-André Lureau
Hi
On Fri, Aug 26, 2022 at 2:12 PM Antonio Caggiano <[email protected] <mailto:[email protected]>>
wrote:
Create virgl renderer context with flags using
context_idwhen valid.v2:
- The feature can be enabled via thecontext_initconfig option.
- A warning message will be emitted and the feature will not be used when linking with virglrenderer versions withoutcontext_init
support.v3: Define
HAVE_VIRGL_CONTEXT_INITinconfig_host_data.Signed-off-by Antonio Caggiano <[email protected]<mailto:[email protected]>>
---
hw/display/virtio-gpu-base.c| 3 +++
hw/display/virtio-gpu-virgl.c| 16 ++++++++++++++--
hw/display/virtio-gpu.c| 2 ++
include/hw/virtio/virtio-gpu.h| 3 +++
meson.build | 5 +++++
5 files changed, 27 insertions(+), 2 deletions(-)Quoted 1 line
diff --git
a/hw/display/virtio-gpu-base.c
b/hw/display/virtio-gpu-base.cQuoted 38 lines
index a29f191aa8..6c5f1f327f 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -215,6 +215,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } + if (virtio_gpu_context_init_enabled(g->conf)) { + features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); + } return features; } diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 73cb92c8d5..274cbc44de 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -97,8 +97,20 @@ static void virgl_cmd_context_create(VirtIOGPU *g, trace_virtio_gpu_cmd_ctx_create(cc.hdr.ctx_id, cc.debug_name); - virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, - cc.debug_name); + if (cc.context_init) { +#ifdef HAVE_VIRGL_CONTEXT_INIT + virgl_renderer_context_create_with_flags(cc.hdr.ctx_id, + cc.context_init, + cc.nlen, + cc.debug_name); + return; +#else + qemu_log_mask(LOG_UNIMP, + "Linked virglrenderer does not support context-init\n");
Quoted 7 lines
Quoted 1 line
What is the outcome in that case?
It's in the commit message: "A warning message will be emitted and the feature will not be used when linking with virglrenderer versions without
context_init"
Ah ok, I didn't expect this to be under the changelog. We generally don't put it in the commit message, but rather after the three-dash line.
Quoted 77 lines
Quoted 10 lines
+#endif + } + + virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, cc.debug_name); } static void virgl_cmd_context_destroy(VirtIOGPU *g, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.cQuoted 8 lines
index 20cc703dcc..fa667ec234 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1424,6 +1424,8 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), + DEFINE_PROP_BIT("context_init", VirtIOGPU,parent_obj.conf.flags,
Quoted 56 lines
+ VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2e28507efe..c6f5cfde47 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -90,6 +90,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -102,6 +103,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; diff --git a/meson.build b/meson.build index 20fddbd707..e1071b3563 100644 --- a/meson.build +++ b/meson.build @@ -718,6 +718,11 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu method: 'pkg-config', required: get_option('virglrenderer'), kwargs: static_kwargs) + + config_host_data.set('HAVE_VIRGL_CONTEXT_INIT', + cc.has_function('virgl_renderer_context_create_with_flags', + prefix: '#include <virglrenderer.h>', + dependencies: virgl)) endif curl = not_found if not get_option('curl').auto() or have_block -- 2.34.1lgtm
Reviewed-by Marc-André Lureau <[email protected]<mailto:[email protected]>>
--
Marc-André Lureau
Signature · 1 line
Marc-André Lureau