[PATCH v5 0/4] virtio-gpu: Add userptr support and ROCm capability enhancements

Honglei Huang posted 4 patches 3 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260115082739.174224-1-honghuan@amd.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
hw/display/virtio-gpu-gl.c                  |  2 ++
hw/display/virtio-gpu-virgl.c               | 12 ++++++++++++
hw/display/virtio-gpu.c                     |  7 -------
include/hw/virtio/virtio-gpu.h              |  3 +++
include/standard-headers/linux/virtio_gpu.h |  6 ++++++
5 files changed, 23 insertions(+), 7 deletions(-)
[PATCH v5 0/4] virtio-gpu: Add userptr support and ROCm capability enhancements
Posted by Honglei Huang 3 weeks, 1 day ago
This patch series introduces enhancements to virtio-gpu to improve
memory management and GPU virtualization capabilities for ROCm (Radeon Open Compute) 
workloads.

Usage example:
  -device virtio-gpu-gl,rocm=on

The series includes:

1. Linux header updates for userptr support: Synchronizes virtio-gpu headers
   with upstream kernel changes, adding VIRTIO_GPU_F_RESOURCE_USERPTR feature
   flag and VIRTIO_GPU_BLOB_FLAG_USE_USERPTR blob flag support. This enables
   user pointer mapping for blob resources, allowing guest applications to use
   user-allocated memory for GPU resources more efficiently.

2. Removal of nr_entries limit: Removes the artificial 16384 entry limit in
   virtio_gpu_create_mapping_iov() to align with kernel driver behavior and
   support legitimate large scatter-gather operations.

3. Linux header updates for ROCm capability: Synchronizes headers to add
   VIRTIO_GPU_CAPSET_ROCM capability set definition.

4. ROCm capability support: Adds native support for AMD's ROCm (Radeon Open
   Compute) platform through a new "rocm=on" device property and capability.
   This enables GPU compute workloads using the ROCm stack through virtio-gpu.

Changes in v5:
- Split userptr header updates into dedicated patch (patch 1/4)
- Extracted nr_entries limit removal into standalone commit (patch 2/4)
- Split ROCm header updates into dedicated patch (patch 3/4)
- Removed VIRTIO_GPU_F_RESOURCE_USERPTR feature decectiontion
- Keep ROCm capability support with "rocm=on" device property (patch 4/4)
- Change corresponding commit messages, change corresponding cover letter content
- Remove RFC label

Changes in v4:
- Change this series to RFC
- Renamed HSAKMT-related functionality to ROCm for better clarity and
  alignment with the ROCm ecosystem terminology
- Changed device property from "hsakmt=on" to "rocm=on"
- Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
  VIRTIO_GPU_FLAG_ROCM_ENABLED
- Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
  VIRGL_RENDERER_USE_ROCM
- Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
  VIRTIO_GPU_CAPSET_HSAKMT (8)
- Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
  another thread

Changes in v3:
- Renamed HSAKMT-related functionality to ROCm for better clarity and
  alignment with the ROCm ecosystem terminology
- Changed device property from "hsakmt=on" to "rocm=on"
- Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
  VIRTIO_GPU_FLAG_ROCM_ENABLED
- Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
  VIRGL_RENDERER_USE_ROCM
- Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
  VIRTIO_GPU_CAPSET_HSAKMT (8)
- Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
  another thread

Changes in v2:
- Fixed error handling bug in virtio-gpu-virgl.c where the return
  value check was inverted (changed from "if (!ret)" to "if (ret != 0)")
- Added VIRGL_RENDER_USE_HSAKMT flag initialization in virtio_gpu_virgl_init()
  when HSAKMT support is enabled
- Simplified blob resource creation logic by removing complex conditional
  branching for userptr vs regular blob handling
- Updated commit messages to reflect bug fixes and improvements
- Added references to related patches in Linux kernel, virglrenderer, and
  ROCm Runtime components for complete feature implementation tracking

Related patches in other components:
- Linux kernel virtio-gpu support:
  https://lore.kernel.org/lkml/20251112072910.3716944-1-honglei1.huang@amd.com/
- Virglrenderer support:
  https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1568
- ROCm Runtime support (merged):
  https://github.com/ROCm/ROCR-Runtime/commit/48d3719dba6ca91f597a8179d8b341387ce155e8

Honglei Huang (4):
  virtio-gpu: Update Linux headers to add virtio-gpu userptr support
  virtio-gpu: Remove nr_entries limit check in create_mapping_iov
  virtio-gpu: Update Linux headers to add ROCM capability set
  virtio-gpu: Add ROCm capability support

 hw/display/virtio-gpu-gl.c                  |  2 ++
 hw/display/virtio-gpu-virgl.c               | 12 ++++++++++++
 hw/display/virtio-gpu.c                     |  7 -------
 include/hw/virtio/virtio-gpu.h              |  3 +++
 include/standard-headers/linux/virtio_gpu.h |  6 ++++++
 5 files changed, 23 insertions(+), 7 deletions(-)

-- 
2.34.1
Re: [PATCH v5 0/4] virtio-gpu: Add userptr support and ROCm capability enhancements
Posted by Akihiko Odaki 3 weeks, 1 day ago
On 2026/01/15 17:27, Honglei Huang wrote:
> This patch series introduces enhancements to virtio-gpu to improve
> memory management and GPU virtualization capabilities for ROCm (Radeon Open Compute)
> workloads.
> 
> Usage example:
>    -device virtio-gpu-gl,rocm=on
> 
> The series includes:
> 
> 1. Linux header updates for userptr support: Synchronizes virtio-gpu headers
>     with upstream kernel changes, adding VIRTIO_GPU_F_RESOURCE_USERPTR feature
>     flag and VIRTIO_GPU_BLOB_FLAG_USE_USERPTR blob flag support. This enables
>     user pointer mapping for blob resources, allowing guest applications to use
>     user-allocated memory for GPU resources more efficiently.
> 
> 2. Removal of nr_entries limit: Removes the artificial 16384 entry limit in
>     virtio_gpu_create_mapping_iov() to align with kernel driver behavior and
>     support legitimate large scatter-gather operations.
> 
> 3. Linux header updates for ROCm capability: Synchronizes headers to add
>     VIRTIO_GPU_CAPSET_ROCM capability set definition.
> 
> 4. ROCm capability support: Adds native support for AMD's ROCm (Radeon Open
>     Compute) platform through a new "rocm=on" device property and capability.
>     This enables GPU compute workloads using the ROCm stack through virtio-gpu.
> 
> Changes in v5:
> - Split userptr header updates into dedicated patch (patch 1/4)
> - Extracted nr_entries limit removal into standalone commit (patch 2/4)
> - Split ROCm header updates into dedicated patch (patch 3/4)
> - Removed VIRTIO_GPU_F_RESOURCE_USERPTR feature decectiontion
> - Keep ROCm capability support with "rocm=on" device property (patch 4/4)
> - Change corresponding commit messages, change corresponding cover letter content
> - Remove RFC label

It is too early to drop the RFC labell. The following should happen 
before dropping the RFC label:
- The Linux header change land in some maintainer's tree.
- The Linux headers with scripts/update-linux-headers.sh is updated
   using the tree.
- The virglrenderer change lands the upstream.
- A proper virglrenderer feature detection with a version number that is
   expected to have the change.

So the QEMU change will land the last. The patches can still be reviewed 
in the RFC state to ensure that the series will be quickly pulled when 
ready.

Regards,
Akihiko Odaki

> 
> Changes in v4:
> - Change this series to RFC
> - Renamed HSAKMT-related functionality to ROCm for better clarity and
>    alignment with the ROCm ecosystem terminology
> - Changed device property from "hsakmt=on" to "rocm=on"
> - Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
>    VIRTIO_GPU_FLAG_ROCM_ENABLED
> - Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
>    VIRGL_RENDERER_USE_ROCM
> - Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
>    VIRTIO_GPU_CAPSET_HSAKMT (8)
> - Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
>    another thread
> 
> Changes in v3:
> - Renamed HSAKMT-related functionality to ROCm for better clarity and
>    alignment with the ROCm ecosystem terminology
> - Changed device property from "hsakmt=on" to "rocm=on"
> - Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
>    VIRTIO_GPU_FLAG_ROCM_ENABLED
> - Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
>    VIRGL_RENDERER_USE_ROCM
> - Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
>    VIRTIO_GPU_CAPSET_HSAKMT (8)
> - Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
>    another thread
> 
> Changes in v2:
> - Fixed error handling bug in virtio-gpu-virgl.c where the return
>    value check was inverted (changed from "if (!ret)" to "if (ret != 0)")
> - Added VIRGL_RENDER_USE_HSAKMT flag initialization in virtio_gpu_virgl_init()
>    when HSAKMT support is enabled
> - Simplified blob resource creation logic by removing complex conditional
>    branching for userptr vs regular blob handling
> - Updated commit messages to reflect bug fixes and improvements
> - Added references to related patches in Linux kernel, virglrenderer, and
>    ROCm Runtime components for complete feature implementation tracking
> 
> Related patches in other components:
> - Linux kernel virtio-gpu support:
>    https://lore.kernel.org/lkml/20251112072910.3716944-1-honglei1.huang@amd.com/
> - Virglrenderer support:
>    https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1568
> - ROCm Runtime support (merged):
>    https://github.com/ROCm/ROCR-Runtime/commit/48d3719dba6ca91f597a8179d8b341387ce155e8
> 
> Honglei Huang (4):
>    virtio-gpu: Update Linux headers to add virtio-gpu userptr support
>    virtio-gpu: Remove nr_entries limit check in create_mapping_iov
>    virtio-gpu: Update Linux headers to add ROCM capability set
>    virtio-gpu: Add ROCm capability support
> 
>   hw/display/virtio-gpu-gl.c                  |  2 ++
>   hw/display/virtio-gpu-virgl.c               | 12 ++++++++++++
>   hw/display/virtio-gpu.c                     |  7 -------
>   include/hw/virtio/virtio-gpu.h              |  3 +++
>   include/standard-headers/linux/virtio_gpu.h |  6 ++++++
>   5 files changed, 23 insertions(+), 7 deletions(-)
>
Re: [PATCH v5 0/4] virtio-gpu: Add userptr support and ROCm capability enhancements
Posted by Honglei Huang 3 weeks, 1 day ago

On 2026/1/15 17:34, Akihiko Odaki wrote:
> On 2026/01/15 17:27, Honglei Huang wrote:
>> This patch series introduces enhancements to virtio-gpu to improve
>> memory management and GPU virtualization capabilities for ROCm (Radeon 
>> Open Compute)
>> workloads.
>>
>> Usage example:
>>    -device virtio-gpu-gl,rocm=on
>>
>> The series includes:
>>
>> 1. Linux header updates for userptr support: Synchronizes virtio-gpu 
>> headers
>>     with upstream kernel changes, adding VIRTIO_GPU_F_RESOURCE_USERPTR 
>> feature
>>     flag and VIRTIO_GPU_BLOB_FLAG_USE_USERPTR blob flag support. This 
>> enables
>>     user pointer mapping for blob resources, allowing guest 
>> applications to use
>>     user-allocated memory for GPU resources more efficiently.
>>
>> 2. Removal of nr_entries limit: Removes the artificial 16384 entry 
>> limit in
>>     virtio_gpu_create_mapping_iov() to align with kernel driver 
>> behavior and
>>     support legitimate large scatter-gather operations.
>>
>> 3. Linux header updates for ROCm capability: Synchronizes headers to add
>>     VIRTIO_GPU_CAPSET_ROCM capability set definition.
>>
>> 4. ROCm capability support: Adds native support for AMD's ROCm (Radeon 
>> Open
>>     Compute) platform through a new "rocm=on" device property and 
>> capability.
>>     This enables GPU compute workloads using the ROCm stack through 
>> virtio-gpu.
>>
>> Changes in v5:
>> - Split userptr header updates into dedicated patch (patch 1/4)
>> - Extracted nr_entries limit removal into standalone commit (patch 2/4)
>> - Split ROCm header updates into dedicated patch (patch 3/4)
>> - Removed VIRTIO_GPU_F_RESOURCE_USERPTR feature decectiontion
>> - Keep ROCm capability support with "rocm=on" device property (patch 4/4)
>> - Change corresponding commit messages, change corresponding cover 
>> letter content
>> - Remove RFC label
> 
> It is too early to drop the RFC labell. The following should happen 
> before dropping the RFC label:
> - The Linux header change land in some maintainer's tree.
> - The Linux headers with scripts/update-linux-headers.sh is updated
>    using the tree.
> - The virglrenderer change lands the upstream.
> - A proper virglrenderer feature detection with a version number that is
>    expected to have the change.
> 
> So the QEMU change will land the last. The patches can still be reviewed 
> in the RFC state to ensure that the series will be quickly pulled when 
> ready.
> 
> Regards,
> Akihiko Odaki

Thanks for the feedback. Totally agreed, will add RFC label in next version.

Regards,
Honglei


> 
>>
>> Changes in v4:
>> - Change this series to RFC
>> - Renamed HSAKMT-related functionality to ROCm for better clarity and
>>    alignment with the ROCm ecosystem terminology
>> - Changed device property from "hsakmt=on" to "rocm=on"
>> - Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
>>    VIRTIO_GPU_FLAG_ROCM_ENABLED
>> - Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
>>    VIRGL_RENDERER_USE_ROCM
>> - Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
>>    VIRTIO_GPU_CAPSET_HSAKMT (8)
>> - Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
>>    another thread
>>
>> Changes in v3:
>> - Renamed HSAKMT-related functionality to ROCm for better clarity and
>>    alignment with the ROCm ecosystem terminology
>> - Changed device property from "hsakmt=on" to "rocm=on"
>> - Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
>>    VIRTIO_GPU_FLAG_ROCM_ENABLED
>> - Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
>>    VIRGL_RENDERER_USE_ROCM
>> - Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
>>    VIRTIO_GPU_CAPSET_HSAKMT (8)
>> - Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
>>    another thread
>>
>> Changes in v2:
>> - Fixed error handling bug in virtio-gpu-virgl.c where the return
>>    value check was inverted (changed from "if (!ret)" to "if (ret != 0)")
>> - Added VIRGL_RENDER_USE_HSAKMT flag initialization in 
>> virtio_gpu_virgl_init()
>>    when HSAKMT support is enabled
>> - Simplified blob resource creation logic by removing complex conditional
>>    branching for userptr vs regular blob handling
>> - Updated commit messages to reflect bug fixes and improvements
>> - Added references to related patches in Linux kernel, virglrenderer, and
>>    ROCm Runtime components for complete feature implementation tracking
>>
>> Related patches in other components:
>> - Linux kernel virtio-gpu support:
>>    https://lore.kernel.org/lkml/20251112072910.3716944-1- 
>> honglei1.huang@amd.com/
>> - Virglrenderer support:
>>    https://gitlab.freedesktop.org/virgl/virglrenderer/-/ 
>> merge_requests/1568
>> - ROCm Runtime support (merged):
>>    https://github.com/ROCm/ROCR-Runtime/ 
>> commit/48d3719dba6ca91f597a8179d8b341387ce155e8
>>
>> Honglei Huang (4):
>>    virtio-gpu: Update Linux headers to add virtio-gpu userptr support
>>    virtio-gpu: Remove nr_entries limit check in create_mapping_iov
>>    virtio-gpu: Update Linux headers to add ROCM capability set
>>    virtio-gpu: Add ROCm capability support
>>
>>   hw/display/virtio-gpu-gl.c                  |  2 ++
>>   hw/display/virtio-gpu-virgl.c               | 12 ++++++++++++
>>   hw/display/virtio-gpu.c                     |  7 -------
>>   include/hw/virtio/virtio-gpu.h              |  3 +++
>>   include/standard-headers/linux/virtio_gpu.h |  6 ++++++
>>   5 files changed, 23 insertions(+), 7 deletions(-)
>>
>