drm/gpuvm: add an abstraction for a VM / BO combination
authorDanilo Krummrich <dakr@redhat.com>
Wed, 8 Nov 2023 00:12:40 +0000 (01:12 +0100)
committerDanilo Krummrich <dakr@redhat.com>
Mon, 13 Nov 2023 17:19:20 +0000 (18:19 +0100)
commit94bc2249f08e141fb4aa120bfdc392c7a5e78211
tree62c031e5a36882e79c43c5fb00afb25c4a817891
parent8af72338dd81d1f8667e0240bd28f5fc98b3f20d
drm/gpuvm: add an abstraction for a VM / BO combination

Add an abstraction layer between the drm_gpuva mappings of a particular
drm_gem_object and this GEM object itself. The abstraction represents a
combination of a drm_gem_object and drm_gpuvm. The drm_gem_object holds
a list of drm_gpuvm_bo structures (the structure representing this
abstraction), while each drm_gpuvm_bo contains list of mappings of this
GEM object.

This has multiple advantages:

1) We can use the drm_gpuvm_bo structure to attach it to various lists
   of the drm_gpuvm. This is useful for tracking external and evicted
   objects per VM, which is introduced in subsequent patches.

2) Finding mappings of a certain drm_gem_object mapped in a certain
   drm_gpuvm becomes much cheaper.

3) Drivers can derive and extend the structure to easily represent
   driver specific states of a BO for a certain GPUVM.

The idea of this abstraction was taken from amdgpu, hence the credit for
this idea goes to the developers of amdgpu.

Cc: Christian König <christian.koenig@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231108001259.15123-11-dakr@redhat.com
drivers/gpu/drm/drm_gpuvm.c
drivers/gpu/drm/nouveau/nouveau_uvmm.c
include/drm/drm_gem.h
include/drm/drm_gpuvm.h