Add support for ROCm (Radeon Open Compute) capability in virtio-gpu.
This enables GPU compute workloads using AMD's ROCm platform through
the virtio-gpu interface.
Changes include:
- Add "rocm" property to virtio-gpu-gl device
- Define VIRTIO_GPU_FLAG_ROCM_ENABLED flag
- Enable VIRGL_RENDERER_USE_ROCM flag when ROCm is enabled
- Register VIRTIO_GPU_CAPSET_ROCM (capset 8) capability
- Add virtio_gpu_rocm_enabled() helper macro
This allows guests to detect and utilize ROCm capabilities through
the virtio-gpu device when the feature is enabled.
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
hw/display/virtio-gpu-gl.c | 2 ++
hw/display/virtio-gpu-virgl.c | 12 ++++++++++++
include/hw/virtio/virtio-gpu.h | 3 +++
include/standard-headers/linux/virtio_gpu.h | 1 +
4 files changed, 18 insertions(+)
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index b98ef2ef98..f059bcb177 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -159,6 +159,8 @@ static const Property virtio_gpu_gl_properties[] = {
VIRTIO_GPU_FLAG_STATS_ENABLED, false),
DEFINE_PROP_BIT("venus", VirtIOGPU, parent_obj.conf.flags,
VIRTIO_GPU_FLAG_VENUS_ENABLED, false),
+ DEFINE_PROP_BIT("rocm", VirtIOGPU, parent_obj.conf.flags,
+ VIRTIO_GPU_FLAG_ROCM_ENABLED, false),
};
static void virtio_gpu_gl_device_unrealize(DeviceState *qdev)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index cbfb8aca3f..5e0f465c37 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -1160,6 +1160,9 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
if (virtio_gpu_venus_enabled(g->parent_obj.conf)) {
flags |= VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER;
}
+ if (virtio_gpu_rocm_enabled(g->parent_obj.conf)) {
+ flags |= (VIRGL_RENDERER_USE_ROCM);
+ }
#endif
ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs);
@@ -1218,5 +1221,14 @@ GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g)
}
}
+ if (virtio_gpu_rocm_enabled(g->parent_obj.conf)) {
+ virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_ROCM,
+ &capset_max_ver,
+ &capset_max_size);
+ if (capset_max_size) {
+ virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_ROCM);
+ }
+ }
+
return capset_ids;
}
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index fe98ea0019..a099c30377 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -101,6 +101,7 @@ enum virtio_gpu_base_conf_flags {
VIRTIO_GPU_FLAG_VENUS_ENABLED,
VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED,
VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED,
+ VIRTIO_GPU_FLAG_ROCM_ENABLED,
};
#define virtio_gpu_virgl_enabled(_cfg) \
@@ -125,6 +126,8 @@ enum virtio_gpu_base_conf_flags {
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_VENUS_ENABLED))
#define virtio_gpu_resource_userptr_enabled(_cfg) \
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED))
+#define virtio_gpu_rocm_enabled(_cfg) \
+ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_ROCM_ENABLED))
struct virtio_gpu_base_conf {
uint32_t max_outputs;
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index fe36288fe5..fe6c0f5cc4 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -315,6 +315,7 @@ struct virtio_gpu_cmd_submit {
#define VIRTIO_GPU_CAPSET_VENUS 4
#define VIRTIO_GPU_CAPSET_CROSS_DOMAIN 5
#define VIRTIO_GPU_CAPSET_DRM 6
+#define VIRTIO_GPU_CAPSET_ROCM 8
/* VIRTIO_GPU_CMD_GET_CAPSET_INFO */
struct virtio_gpu_get_capset_info {
--
2.34.1