Skip to content

tests/amdgpu: add SVM (Shared Virtual Memory) test suite

Junhua Shen igt-dev 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 0 repliesNew
  2. v23 patches 2 repliesSuperseded
  3. v12 patches 0 repliesSuperseded

Changes in v3 from the cover letter

----------------
Patch 1/3:
- Sync with the updated kernel uAPI: DRM_AMDGPU_GEM_SVM is now 0x1C, AMDGPU_SVM_ATTR_HIVE_LOCAL is gone, and locations are an enum (SYSMEM/UNDEFINED/LOCAL/HIVE) instead of DRM fds.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3include/drm-uapi: sync amdgpu_drm.h for GEM_SVM uAPIinclude/drm-uapi/amdgpu_drm.h+125 -00 replies
2/3lib/amdgpu: add SVM helper librarylib/amdgpu/amd_svm.c lib/amdgpu/amd_svm.h lib/meson.build+251 -120 replies
3/3tests/amdgpu: add SVM test suitetests/amdgpu/amd_svm.c tests/amdgpu/meson.build+1833 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH i-g-t v3 0/3] tests/amdgpu: add SVM (Shared Virtual Memory) test suite

This series adds IGT coverage for the amdgpu SVM uAPI, which exposes HMM-based unified virtual memory to user space through the amdgpu render node (DRM_IOCTL_AMDGPU_GEM_SVM). Until now, SVM has only been testable via the KFD/ROCm stack; this brings equivalent coverage to the DRM render-node interface.

1. include/drm-uapi: sync amdgpu_drm.h with the kernel GEM_SVM uAPI.

2. lib/amdgpu: a small SVM helper library wrapping the SVM register/prefetch calls and the SDMA submission used to touch SVM ranges.

3. tests/amdgpu: the amd_svm test, with subtests covering system- and VRAM-backed allocation, prefetch, CPU<->GPU migration and access-in-place, range split/merge, partial unmap, eviction of system ranges and VRAM overcommit. Most subtests are adapted from the KFD SVM test suite (KFDSVMRangeTest).

Changes since v2
----------------
Patch 1/3:
- Sync with the updated kernel uAPI: DRM_AMDGPU_GEM_SVM is now 0x1C, AMDGPU_SVM_ATTR_HIVE_LOCAL is gone, and locations are an enum (SYSMEM/UNDEFINED/LOCAL/HIVE) instead of DRM fds.

Patch 2/3 (Kamil):
- Drop "(amd_svm.{c,h})" from the subject and spell out SVM on first use in the commit message and in amd_svm.h.
- Keep only the SPDX line as the license header.
- Include system headers before IGT headers and drop unused includes.
- Document all public helpers with gtk-doc comments.
- Sort the amdgpu lib_sources list in lib/meson.build alphabetically.
- Only build amd_svm.c when libdrm_amdgpu provides the SVM API; v2 was built unconditionally and broke Fi.CI.BUILD.

Patch 3/3:
- Acquire the render node's VM through KFD (AMDKFD_IOC_ACQUIRE_VM) so the kernel turns it into a compute VM with SVM enabled.
- Use AMDGPU_SVM_LOCATION_* values for prefetch/preferred locations.
- Align the registered range attributes with kfdtest's HsaSVMRange (prefetch and prefer system memory by default).
- set-get-attributes: expect the kernel defaults (HOST_ACCESS and COHERENT set).
- prefetch: on a range with mixed prefetch locations, check that GET_ATTR returns the first part's value and clips the size to it.
- split-range case 4.2: register the superset range as kfdtest does.
- Only build the test when libdrm_amdgpu provides the SVM API.

Testing
-------
Run on a VEGA20 (GFX9) dGPU with XNACK enabled, against an amdgpu kernel with the SVM series below applied. 17 subtests pass and read-only-range is skipped (the kernel write-fault path is not yet safe to exercise). The remaining subtests are kept to track kernel fixes:
- migrate-file-backed-range: registering a file-backed range with a VRAM prefetch location returns -EFAULT.
- multi-thread-migration: not run in this round; it was unstable on earlier kernels.

Dependencies
------------
Kernel:
- amdgpu SVM support on the DRM GPUSVM framework:

      https://lore.kernel.org/all/[email protected]

libdrm:
- amdgpu_svm_* wrappers in libdrm_amdgpu:
https://gitlab.freedesktop.org/mesa/libdrm/-/merge_requests/485
IGT (apply first):
- "lib/amdgpu: refactor cmd_context ownership and packet operands"

      https://lore.kernel.org/all/[email protected]
  - "lib/amdgpu: generic compute dispatch helper and copy_dword"
      https://lore.kernel.org/all/[email protected]

Junhua Shen (3):
include/drm-uapi: sync amdgpu_drm.h for GEM_SVM uAPI lib/amdgpu: add SVM helper library tests/amdgpu: add SVM test suite

 include/drm-uapi/amdgpu_drm.h |  125 +++
 lib/amdgpu/amd_svm.c          |  197 ++++
 lib/amdgpu/amd_svm.h          |   34 +
 lib/meson.build               |   32 +-
 tests/amdgpu/amd_svm.c        | 1828 +++++++++++++++++++++++++++++++++
 tests/amdgpu/meson.build      |    5 +
 6 files changed, 2209 insertions(+), 12 deletions(-)
 create mode 100644 lib/amdgpu/amd_svm.c
 create mode 100644 lib/amdgpu/amd_svm.h
 create mode 100644 tests/amdgpu/amd_svm.c
Signature · 1 line
2.34.1