Skip to content

Commit 435479d

Browse files
hoshinolinajannau
authored andcommitted
rust: drm: Add GPUVM Manager abstraction
rust: drm/gpuvm: Take &GpuVmBo<T> for map_and_link_va() rust: drm/gpuvm: Pass vm_bo explicitly to step_remap() We cannot drop ARef<GpuVmBo<T>> references within the step_*() calls, since the destructore takes the object lock but that is already locked here. Instead of providing a method that the callback can use to obtain a reference (which, when dropped, would deadlock), grab a reference ourselves and pass it explicitly into the callback as a &ref. Thus, we can drop it without locking again. rust: drm/gpuvm: bo_unmap() should take &GpuVmBo<T>, not ARef. rust: drm/gpuvm: Add interruptible flag to exec_lock() Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent a00839f commit 435479d

5 files changed

Lines changed: 710 additions & 0 deletions

File tree

rust/bindings/bindings_helper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
#include <linux/acpi.h>
3232
#include <drm/drm_device.h>
3333
#include <drm/drm_drv.h>
34+
#include <drm/drm_exec.h>
3435
#include <drm/drm_file.h>
3536
#include <drm/drm_gem.h>
3637
#include <drm/drm_gem_shmem_helper.h>
38+
#include <drm/drm_gpuvm.h>
3739
#include <drm/drm_ioctl.h>
3840
#include <drm/drm_syncobj.h>
3941
#include <drm/gpu_scheduler.h>
@@ -113,6 +115,7 @@ const gfp_t RUST_CONST_HELPER___GFP_ZERO = __GFP_ZERO;
113115
const gfp_t RUST_CONST_HELPER___GFP_HIGHMEM = ___GFP_HIGHMEM;
114116
const gfp_t RUST_CONST_HELPER___GFP_NOWARN = ___GFP_NOWARN;
115117
const blk_features_t RUST_CONST_HELPER_BLK_FEAT_ROTATIONAL = BLK_FEAT_ROTATIONAL;
118+
const uint32_t RUST_CONST_HELPER_DRM_EXEC_INTERRUPTIBLE_WAIT = DRM_EXEC_INTERRUPTIBLE_WAIT;
116119
const fop_flags_t RUST_CONST_HELPER_FOP_UNSIGNED_OFFSET = FOP_UNSIGNED_OFFSET;
117120

118121
const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;

rust/helpers/drm_gpuvm.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <drm/drm_gpuvm.h>
4+
5+
#ifdef CONFIG_DRM
6+
#ifdef CONFIG_DRM_GPUVM
7+
8+
struct drm_gpuvm *rust_helper_drm_gpuvm_get(struct drm_gpuvm *obj)
9+
{
10+
return drm_gpuvm_get(obj);
11+
}
12+
13+
void rust_helper_drm_gpuvm_exec_unlock(struct drm_gpuvm_exec *vm_exec)
14+
{
15+
return drm_gpuvm_exec_unlock(vm_exec);
16+
}
17+
18+
void rust_helper_drm_gpuva_init_from_op(struct drm_gpuva *va, struct drm_gpuva_op_map *op)
19+
{
20+
drm_gpuva_init_from_op(va, op);
21+
}
22+
23+
struct drm_gpuvm_bo *rust_helper_drm_gpuvm_bo_get(struct drm_gpuvm_bo *vm_bo)
24+
{
25+
return drm_gpuvm_bo_get(vm_bo);
26+
}
27+
28+
bool rust_helper_drm_gpuvm_is_extobj(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj)
29+
{
30+
return drm_gpuvm_is_extobj(gpuvm, obj);
31+
}
32+
33+
#endif
34+
#endif

rust/helpers/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "dma-mapping.c"
3030
#include "dma-resv.c"
3131
#include "drm.c"
32+
#include "drm_gpuvm.c"
3233
#include "drm_syncobj.c"
3334
#include "err.c"
3435
#include "irq.c"

0 commit comments

Comments
 (0)