From: Honglei Huang <honghuan@amd.com>
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>,
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>,
David Airlie <airlied@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>
Cc: Gurchetan Singh <gurchetansingh@chromium.org>,
Chia-I Wu <olvaffe@gmail.com>, Ray Huang <Ray.Huang@amd.com>,
<dri-devel@lists.freedesktop.org>,
<virtualization@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
Honglei Huang <honghuan@amd.com>
Subject: [PATCH v7 2/4] drm/virtgpu api: add blob userptr resource
Date: Fri, 18 Sep 2026 10:11:52 +0800 [thread overview]
Message-ID: <20260918021154.1432154-3-honghuan@amd.com> (raw)
In-Reply-To: <20260918021154.1432154-1-honghuan@amd.com>
Add DRM ioctl flags and a userptr address field so userspace can
request a blob backed by an existing process mapping.
UAPI changes:
- Add guest-only VIRTGPU_BLOB_FLAG_USE_USERPTR and
VIRTGPU_BLOB_FLAG_USERPTR_RDONLY flags
- Add a userptr field to drm_virtgpu_resource_create_blob
These flags select guest pin behavior in the ioctl. They are not
part of the virtio CREATE_BLOB wire ABI, so mask them out in
virtio_gpu_cmd_resource_create_blob().
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
drivers/gpu/drm/virtio/virtgpu_vq.c | 6 +++++-
include/uapi/drm/virtgpu_drm.h | 9 +++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index c02c03c10d..6830673309 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -1494,7 +1494,11 @@ virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev,
cmd_p->hdr.ctx_id = cpu_to_le32(params->ctx_id);
cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
cmd_p->blob_mem = cpu_to_le32(params->blob_mem);
- cmd_p->blob_flags = cpu_to_le32(params->blob_flags);
+ /* Guest-only flags stay off the wire. */
+ cmd_p->blob_flags = cpu_to_le32(params->blob_flags &
+ (VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE |
+ VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE |
+ VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE));
cmd_p->blob_id = cpu_to_le64(params->blob_id);
cmd_p->size = cpu_to_le64(params->size);
cmd_p->nr_entries = cpu_to_le32(nents);
diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index 95587e12ae..62c4b8f19b 100644
--- a/include/uapi/drm/virtgpu_drm.h
+++ b/include/uapi/drm/virtgpu_drm.h
@@ -186,6 +186,9 @@ struct drm_virtgpu_resource_create_blob {
#define VIRTGPU_BLOB_FLAG_USE_MAPPABLE 0x0001
#define VIRTGPU_BLOB_FLAG_USE_SHAREABLE 0x0002
#define VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
+/* Guest-only flags */
+#define VIRTGPU_BLOB_FLAG_USE_USERPTR 0x0008
+#define VIRTGPU_BLOB_FLAG_USERPTR_RDONLY 0x0010
/* zero is invalid blob_mem */
__u32 blob_mem;
__u32 blob_flags;
@@ -205,6 +208,12 @@ struct drm_virtgpu_resource_create_blob {
#define DRM_VIRTGPU_BLOB_FLAG_HINT_DEFER_MAPPING 0x0001
__u32 blob_hints;
__u32 pad2;
+
+ /*
+ * userptr: guest userspace memory address for VIRTGPU_BLOB_FLAG_USE_USERPTR.
+ * Must be 0 if VIRTGPU_BLOB_FLAG_USE_USERPTR is not set.
+ */
+ __u64 userptr;
};
#define VIRTGPU_CONTEXT_PARAM_CAPSET_ID 0x0001
--
2.34.1
next prev parent reply other threads:[~2026-09-18 2:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 2:11 [PATCH v7 0/4] virtio-gpu: Add userptr support for compute workloads Honglei Huang
2026-09-18 2:11 ` [PATCH v7 1/4] drm/virtio-gpu: Add VIRTIO_GPU_CAPSET_ROCM capability Honglei Huang
2026-09-18 2:16 ` sashiko-bot
2026-09-18 2:11 ` Honglei Huang [this message]
2026-09-18 2:19 ` [PATCH v7 2/4] drm/virtgpu api: add blob userptr resource sashiko-bot
2026-09-18 2:11 ` [PATCH v7 3/4] drm/virtio: implement userptr support for zero-copy memory access Honglei Huang
2026-09-18 2:29 ` sashiko-bot
2026-09-18 2:11 ` [PATCH v7 4/4] drm/virtio: wire blob ioctl creation to userptr objects Honglei Huang
2026-09-18 2:23 ` sashiko-bot
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=20260918021154.1432154-3-honghuan@amd.com \
--to=honghuan@amd.com \
--cc=Ray.Huang@amd.com \
--cc=airlied@redhat.com \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=olvaffe@gmail.com \
--cc=virtualization@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.