[PATCH drm-misc-next 0/3] [RFC] DRM GPUVA Manager GPU-VM features

Danilo Krummrich
2023-08-20T21:55:11Z

So far the DRM GPUVA manager offers common infrastructure to track GPU VA
allocations and mappings, generically connect GPU VA mappings to their
backing buffers and perform more complex mapping operations on the GPU VA
space.

However, there are more design patterns commonly used by drivers, which
can potentially be generalized in order to make the DRM GPUVA manager
represent a basic GPU-VM implementation. In this context, this patch series
aims at generalizing the following elements.

1) Provide a common dma-resv for GEM objects not being used outside of
this GPU-VM.

2) Provide tracking of external GEM objects (GEM objects which are
shared with other GPU-VMs).

3) Provide functions to efficiently lock all GEM objects dma-resv the
GPU-VM contains mappings of.

4) Provide tracking of evicted GEM objects the GPU-VM contains mappings
of, such that validation of evicted GEM objects is accelerated.

5) Provide some convinience functions for common patterns.

Rather than being designed as a "framework", the target is to make all
features appear as a collection of optional helper functions, such that
drivers are free to make use of the DRM GPUVA managers basic
functionality and opt-in for other features without setting any feature
flags, just by making use of the corresponding functions.

The implementation introduces struct drm_gpuva_gem, which serves as abstraction
combining a struct drm_gpuva_manager and struct drm_gem_object, similar to what
amdgpu does with struct amdgpu_bo_vm. While this adds a bit of complexity it
improves the efficiency of tracking evicted GEM objects. [1] provides an
alternative implementation using a maple_tree, resulting into a fairly simpler
API. [2] points to the full patch series providing the alternative
implementation. [3] points to this patch series.

[1] https://gitlab.freedesktop.org/nouvelles/kernel/-/commit/2a7e1b0ece2c3bba43376783b577d97ae6f6e54f
[2] https://gitlab.freedesktop.org/nouvelles/kernel/-/commits/gpuva-vm-resv
[3] https://gitlab.freedesktop.org/nouvelles/kernel/-/commits/gpuva-vm-resv-vm-bo

Danilo Krummrich (3):
drm: drm_exec: build always builtin
drm/gpuva_mgr: generalize dma_resv/extobj handling and GEM validation
drm/nouveau: gpuva mgr dma-resv/extobj handling, GEM validation

drivers/gpu/drm/Kconfig | 6 -
drivers/gpu/drm/Makefile | 3 +-
drivers/gpu/drm/drm_gpuva_mgr.c | 688 +++++++++++++++++++++++-
drivers/gpu/drm/nouveau/Kconfig | 1 -
drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +-
drivers/gpu/drm/nouveau/nouveau_exec.c | 51 +-
drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +-
drivers/gpu/drm/nouveau/nouveau_sched.h | 2 -
drivers/gpu/drm/nouveau/nouveau_uvmm.c | 191 +++++--
include/drm/drm_gem.h | 48 +-
include/drm/drm_gpuva_mgr.h | 302 ++++++++++-
11 files changed, 1161 insertions(+), 139 deletions(-)

base-commit: 25205087df1ffe06ccea9302944ed1f77dc68c6f
--
2.41.0