From: Honglei Huang <honglei1.huang@amd.com>
To: David Airlie <airlied@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Dmitry Osipenko <dmitry.osipenko@collabora.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Simona Vetter <simona@ffwll.ch>, <Ray.Huang@amd.com>
Cc: Gurchetan Singh <gurchetansingh@chromium.org>,
<odaki@rsg.ci.i.u-tokyo.ac.jp>, Chia-I Wu <olvaffe@gmail.com>,
<dri-devel@lists.freedesktop.org>,
<virtualization@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
Honglei Huang <Honglei1.Huang@amd.com>
Subject: [PATCH v4 5/5] drm/virtio: advertise base userptr feature to userspace
Date: Thu, 15 Jan 2026 15:58:51 +0800 [thread overview]
Message-ID: <20260115075851.173318-6-honglei1.huang@amd.com> (raw)
In-Reply-To: <20260115075851.173318-1-honglei1.huang@amd.com>
From: Honglei Huang <Honglei1.Huang@amd.com>
Integrate userptr functionality into the blob resource creation path:
- Add userptr flags to VIRTGPU_BLOB_FLAG_USE_MASK for validation
- Route userptr requests to virtio_gpu_userptr_create()
- Pass userptr address from ioctl to params structure
With this change, userspace can create userptr blob resources by setting
VIRTGPU_BLOB_FLAG_USE_USERPTR flag and providing a valid userptr address.
Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index c33c05736..e49f5c89b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -36,7 +36,9 @@
#define VIRTGPU_BLOB_FLAG_USE_MASK (VIRTGPU_BLOB_FLAG_USE_MAPPABLE | \
VIRTGPU_BLOB_FLAG_USE_SHAREABLE | \
- VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE)
+ VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE | \
+ VIRTGPU_BLOB_FLAG_USE_USERPTR | \
+ VIRTGPU_BLOB_FLAG_USERPTR_RDONLY)
/* Must be called with &virtio_gpu_fpriv.struct_mutex held. */
static void virtio_gpu_create_context_locked(struct virtio_gpu_device *vgdev,
@@ -489,6 +491,7 @@ static int verify_blob(struct virtio_gpu_device *vgdev,
params->size = rc_blob->size;
params->blob = true;
params->blob_flags = rc_blob->blob_flags;
+ params->userptr = rc_blob->userptr;
return 0;
}
@@ -527,8 +530,10 @@ static int virtio_gpu_resource_create_blob_ioctl(struct drm_device *dev,
vfpriv->ctx_id, NULL, NULL);
}
- if (guest_blob)
+ if (guest_blob && !params.userptr)
ret = virtio_gpu_object_create(vgdev, ¶ms, &bo, NULL);
+ else if (guest_blob && params.userptr)
+ ret = virtio_gpu_userptr_create(vgdev, file, ¶ms, &bo);
else if (!guest_blob && host3d_blob)
ret = virtio_gpu_vram_create(vgdev, ¶ms, &bo);
else
--
2.34.1
next prev parent reply other threads:[~2026-01-15 7:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 7:58 [PATCH v4 0/5] virtio-gpu: Add userptr support for compute workloads Honglei Huang
2026-01-15 7:58 ` [PATCH v4 1/5] drm/virtio-gpu: Add VIRTIO_GPU_CAPSET_ROCM capability Honglei Huang
2026-01-15 7:58 ` [PATCH v4 2/5] virtio-gpu api: add blob userptr resource Honglei Huang
2026-01-15 7:58 ` [PATCH v4 3/5] drm/virtgpu " Honglei Huang
2026-01-15 7:58 ` [PATCH v4 4/5] drm/virtio: implement userptr support for zero-copy memory access Honglei Huang
2026-01-15 7:58 ` Honglei Huang [this message]
2026-01-15 9:20 ` [PATCH v4 0/5] virtio-gpu: Add userptr support for compute workloads Akihiko Odaki
2026-01-16 7:20 ` Honglei Huang
2026-01-16 8:54 ` Akihiko Odaki
2026-01-16 9:39 ` Honglei Huang
2026-01-16 10:01 ` Akihiko Odaki
2026-01-16 10:32 ` Honglei Huang
2026-01-16 11:03 ` Akihiko Odaki
2026-01-16 12:34 ` Honglei Huang
2026-01-16 13:22 ` Akihiko Odaki
2026-09-11 14:47 ` Dmitry Osipenko
2026-09-12 13:55 ` Huang, Honglei
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=20260115075851.173318-6-honglei1.huang@amd.com \
--to=honglei1.huang@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=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=olvaffe@gmail.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox