From: "Huang, Honglei" <honghuan@amd.com>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
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,
Dmitry Osipenko <dmitry.osipenko@collabora.com>,
David Airlie <airlied@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH v8 2/4] drm/virtgpu api: add blob userptr resource
Date: Fri, 18 Sep 2026 23:48:32 +0800 [thread overview]
Message-ID: <6f36d088-9366-48fa-b67a-659eabbd1c42@amd.com> (raw)
In-Reply-To: <a08fc58b-c67a-4a96-a967-7280c8f9e965@rsg.ci.i.u-tokyo.ac.jp>
On 9/18/2026 8:12 PM, Akihiko Odaki wrote:
> On 2026/09/18 18:59, Honglei Huang wrote:
>> Add a userptr address field so userspace can request a blob backed
>> by an existing process mapping. A non-zero userptr selects that
>> path; probe VIRTGPU_PARAM_USERPTR before using the field.
>>
>> GPU-readonly backing is requested with the virtio CREATE_BLOB wire
>> flag VIRTIO_GPU_BLOB_FLAG_USE_READONLY (also
>> VIRTGPU_BLOB_FLAG_USE_READONLY). The device MUST NOT write such a
>> resource. The guest pins without FOLL_WRITE only when the device
>> advertised VIRTIO_GPU_F_BLOB_READONLY (VIRTGPU_PARAM_BLOB_READONLY).
>>
>> Signed-off-by: Honglei Huang <honghuan@amd.com>
>> ---
>> include/uapi/drm/virtgpu_drm.h | 13 +++++++++++++
>> include/uapi/linux/virtio_gpu.h | 6 ++++++
>> 2 files changed, 19 insertions(+)
>>
>> diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/
>> virtgpu_drm.h
>> index 95587e12ae..80f73b3276 100644
>> --- a/include/uapi/drm/virtgpu_drm.h
>> +++ b/include/uapi/drm/virtgpu_drm.h
>> @@ -99,6 +99,8 @@ struct drm_virtgpu_execbuffer {
>> #define VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs 7 /* Bitmask of supported
>> capability set ids */
>> #define VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME 8 /* Ability to set debug
>> name from userspace */
>> #define VIRTGPU_PARAM_BLOB_ALIGNMENT 9 /* Device alignment
>> requirements for blobs */
>> +#define VIRTGPU_PARAM_USERPTR 10 /* CREATE_BLOB userptr field is
>> supported */
>> +#define VIRTGPU_PARAM_BLOB_READONLY 11 /*
>> VIRTGPU_BLOB_FLAG_USE_READONLY is honored */
>> struct drm_virtgpu_getparam {
>> __u64 param;
>> @@ -186,6 +188,10 @@ 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
>> +/* Wire flag: device MUST NOT write. Guest pins without FOLL_WRITE.
>> + * Rejected unless VIRTGPU_PARAM_BLOB_READONLY is 1.
>> + */
>
> According to Documentation/process/coding-style.rst, the preferred style
> for long (multi-line) comments is:
>
> /*
> * This is the preferred style for multi-line
> * comments in the Linux kernel source code.
> * Please use it consistently.
> *
> * Description: A column of asterisks on the left side,
> * with beginning and ending almost-blank lines.
> */
>
> So please avoid putting text on the same line as the opening /*.
>
> Furthermore, because this is a UAPI header (defining the interface
> between userspace and the kernel, rather than the guest and the host),
> it should use terminology appropriate for userspace. Kernel-internal
> implementation details like FOLL_WRITE and terms like "guest" shouldn't
> be mentioned here.
>
> That being said, I don't think this comment is necessary in the first
> place. Anyone who needs to know the exact behavior will look at the
> virtio specification. I recommend just dropping the comment entirely.
>
Thanks for the review, will remove this comment here.
>> +#define VIRTGPU_BLOB_FLAG_USE_READONLY 0x0008
>> /* zero is invalid blob_mem */
>> __u32 blob_mem;
>> __u32 blob_flags;
>> @@ -205,6 +211,13 @@ struct drm_virtgpu_resource_create_blob {
>> #define DRM_VIRTGPU_BLOB_FLAG_HINT_DEFER_MAPPING 0x0001
>> __u32 blob_hints;
>> __u32 pad2;
>> +
>> + /*
>> + * Guest VA to pin as blob backing. Non-zero selects the userptr
>> + * path and is valid only with VIRTGPU_BLOB_MEM_GUEST. Must be 0
>> + * otherwise. Probe VIRTGPU_PARAM_USERPTR before using this field.
>> + */
>
> This comment is useful since it discusses UAPI specifics. However,
> please avoid the term "Guest VA". Since guest userspace has no concept
> of a "host" or "PA" (physical address), simply saying "address" is
> sufficient and more concise.
Got it, will modify the comment in next version.
Regards,
Honglei
>
> Regards,
> Akihiko Odaki
>
>> + __u64 userptr;
>> };
>> #define VIRTGPU_CONTEXT_PARAM_CAPSET_ID 0x0001
>> diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/
>> virtio_gpu.h
>> index 3d4dfadc9d..33f5332e59 100644
>> --- a/include/uapi/linux/virtio_gpu.h
>> +++ b/include/uapi/linux/virtio_gpu.h
>> @@ -72,6 +72,10 @@
>> * must be aligned to that value.
>> */
>> #define VIRTIO_GPU_F_BLOB_ALIGNMENT 5
>> +/*
>> + * VIRTIO_GPU_BLOB_FLAG_USE_READONLY
>> + */
>> +#define VIRTIO_GPU_F_BLOB_READONLY 6
>> enum virtio_gpu_ctrl_type {
>> VIRTIO_GPU_UNDEFINED = 0,
>> @@ -415,6 +419,8 @@ struct virtio_gpu_resource_create_blob {
>> #define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001
>> #define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002
>> #define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
>> +/* Device MUST NOT write. Driver may pin read-only guest pages. */
>> +#define VIRTIO_GPU_BLOB_FLAG_USE_READONLY 0x0008
>> /* zero is invalid blob mem */
>> __le32 blob_mem;
>> __le32 blob_flags;
>
next prev parent reply other threads:[~2026-09-18 15:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 9:59 [PATCH v8 0/4] virtio-gpu: Add userptr support for compute workloads Honglei Huang
2026-09-18 9:59 ` [PATCH v8 1/4] drm/virtio-gpu: Add VIRTIO_GPU_CAPSET_ROCM capability Honglei Huang
2026-09-18 9:59 ` [PATCH v8 2/4] drm/virtgpu api: add blob userptr resource Honglei Huang
2026-09-18 12:12 ` Akihiko Odaki
2026-09-18 15:48 ` Huang, Honglei [this message]
2026-09-18 9:59 ` [PATCH v8 3/4] drm/virtio: implement userptr support for zero-copy memory access Honglei Huang
2026-09-18 9:59 ` [PATCH v8 4/4] drm/virtio: wire blob ioctl creation to userptr objects Honglei Huang
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=6f36d088-9366-48fa-b67a-659eabbd1c42@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®