qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Honglei Huang <honghuan@amd.com>
To: <alex.bennee@linaro.org>, <dmitry.osipenko@collabora.com>,
	<Ray.Huang@amd.com>
Cc: <odaki@rsg.ci.i.u-tokyo.ac.jp>, <mst@redhat.com>,
	<cohuck@redhat.com>, <pbonzini@redhat.com>,
	<qemu-devel@nongnu.org>, Honglei Huang <honghuan@amd.com>
Subject: [PATCH 3/3] virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support
Date: Wed, 12 Nov 2025 15:54:14 +0800	[thread overview]
Message-ID: <20251112075414.3719917-4-honghuan@amd.com> (raw)
In-Reply-To: <20251112075414.3719917-1-honghuan@amd.com>

This patch introduces support for the VIRTIO_GPU_F_RESOURCE_USERPTR feature
in virtio-gpu implementation:

- Add VIRTIO_GPU_F_RESOURCE_USERPTR feature flag definition
- Implement resource_userptr property as a configurable option
- Add VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED configuration flag
- Enable feature negotiation when resource_userptr is enabled

Usage:
  -device virtio-gpu-gl,userptr=on

This feature allows virtio-gpu to support user pointer resources,
enhancing memory management capabilities for GPU virtualization
scenarios.

Signed-off-by: Honglei Huang <honghuan@amd.com>
---
 hw/display/virtio-gpu-base.c                | 3 +++
 hw/display/virtio-gpu.c                     | 2 ++
 include/hw/virtio/virtio-gpu.h              | 3 +++
 include/standard-headers/linux/virtio_gpu.h | 2 ++
 4 files changed, 10 insertions(+)

diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 7269477a1c..f013a4ece6 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -264,6 +264,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features,
     if (virtio_gpu_resource_uuid_enabled(g->conf)) {
         features |= (1 << VIRTIO_GPU_F_RESOURCE_UUID);
     }
+    if (virtio_gpu_resource_userptr_enabled(g->conf)) {
+        features |= (1 << VIRTIO_GPU_F_RESOURCE_USERPTR);
+    }
 
     return features;
 }
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 956dc811fa..5f1dc80060 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1685,6 +1685,8 @@ static const Property virtio_gpu_properties[] = {
                      256 * MiB),
     DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags,
                     VIRTIO_GPU_FLAG_BLOB_ENABLED, false),
+    DEFINE_PROP_BIT("userptr", VirtIOGPU, parent_obj.conf.flags,
+                    VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED, false),
     DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0),
     DEFINE_PROP_UINT8("x-scanout-vmstate-version", VirtIOGPU, scanout_vmstate_version, 2),
 };
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index c820247db8..ff68f3c451 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_HSAKMT_ENABLED,
+    VIRTIO_GPU_FLAG_RESOURCE_USERPTR_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_hsakmt_enabled(_cfg) \
     (_cfg.flags & (1 << VIRTIO_GPU_FLAG_HSAKMT_ENABLED))
+#define virtio_gpu_resource_userptr_enabled(_cfg) \
+    (_cfg.flags & (1 << VIRTIO_GPU_FLAG_RESOURCE_USERPTR_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 6c54cb745f..321477598e 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -65,6 +65,8 @@
  */
 #define VIRTIO_GPU_F_CONTEXT_INIT        4
 
+#define VIRTIO_GPU_F_RESOURCE_USERPTR    5
+
 enum virtio_gpu_ctrl_type {
 	VIRTIO_GPU_UNDEFINED = 0,
 
-- 
2.34.1



      parent reply	other threads:[~2025-11-12 14:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12  7:54 [PATCH 0/3] virtio-gpu: Add user pointer and HSAKMT support enhancements Honglei Huang
2025-11-12  7:54 ` [PATCH 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag Honglei Huang
2025-11-12  8:44   ` Akihiko Odaki
2025-11-12 10:54     ` Honglei1.Huang@amd.com
2025-11-12  7:54 ` [PATCH 2/3] virtio-gpu: add configurable HSAKMT capset support Honglei Huang
2025-11-12  7:54 ` Honglei Huang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251112075414.3719917-4-honghuan@amd.com \
    --to=honghuan@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=alex.bennee@linaro.org \
    --cc=cohuck@redhat.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=mst@redhat.com \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).