Skip to content

Commit c3ac4f7

Browse files
hoshinolinajannau
authored andcommitted
rust: drm: Add GPUVM Manager abstraction
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent 4fda39c commit c3ac4f7

6 files changed

Lines changed: 713 additions & 0 deletions

File tree

drivers/gpu/drm/asahi/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ config RUST_DRM_GEM_SHMEM_HELPER
88
bool
99
select DRM_GEM_SHMEM_HELPER
1010

11+
config RUST_DRM_GPUVM
12+
bool
13+
select DRM_GPUVM
14+
1115
config RUST_APPLE_RTKIT
1216
bool
1317
select APPLE_RTKIT
@@ -23,6 +27,7 @@ config DRM_ASAHI
2327
select IOMMU_SUPPORT
2428
select IOMMU_IO_PGTABLE_LPAE
2529
select RUST_DRM_GEM_SHMEM_HELPER
30+
select RUST_DRM_GPUVM
2631
select RUST_APPLE_RTKIT
2732
help
2833
DRM driver for Apple AGX GPUs (G13x, found in the M1 SoC family)

rust/bindings/bindings_helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
#include <drm/drm_device.h>
1010
#include <drm/drm_drv.h>
11+
#include <drm/drm_exec.h>
1112
#include <drm/drm_file.h>
1213
#include <drm/drm_gem.h>
1314
#include <drm/drm_gem_shmem_helper.h>
15+
#include <drm/drm_gpuvm.h>
1416
#include <drm/drm_ioctl.h>
1517
#include <drm/drm_syncobj.h>
1618
#include <drm/gpu_scheduler.h>
@@ -75,3 +77,5 @@ const xa_mark_t BINDINGS_XA_MARK_2 = XA_MARK_2;
7577
const xa_mark_t BINDINGS_XA_PRESENT = XA_PRESENT;
7678
const xa_mark_t BINDINGS_XA_MARK_MAX = XA_MARK_MAX;
7779
const xa_mark_t BINDINGS_XA_FREE_MARK = XA_FREE_MARK;
80+
81+
const uint32_t BINDINGS_DRM_EXEC_INTERRUPTIBLE_WAIT = DRM_EXEC_INTERRUPTIBLE_WAIT;

rust/helpers.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <drm/drm_gem.h>
2424
#include <drm/drm_gem_shmem_helper.h>
25+
#include <drm/drm_gpuvm.h>
2526
#include <drm/drm_syncobj.h>
2627
#include <kunit/test-bug.h>
2728
#include <linux/bug.h>
@@ -638,6 +639,40 @@ int rust_helper_drm_gem_shmem_object_mmap(struct drm_gem_object *obj, struct vm_
638639
EXPORT_SYMBOL_GPL(rust_helper_drm_gem_shmem_object_mmap);
639640

640641
#endif
642+
643+
#ifdef CONFIG_DRM_GPUVM
644+
struct drm_gpuvm *rust_helper_drm_gpuvm_get(struct drm_gpuvm *obj)
645+
{
646+
return drm_gpuvm_get(obj);
647+
}
648+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_get);
649+
650+
void rust_helper_drm_gpuvm_exec_unlock(struct drm_gpuvm_exec *vm_exec)
651+
{
652+
return drm_gpuvm_exec_unlock(vm_exec);
653+
}
654+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_exec_unlock);
655+
656+
void rust_helper_drm_gpuva_init_from_op(struct drm_gpuva *va, struct drm_gpuva_op_map *op)
657+
{
658+
drm_gpuva_init_from_op(va, op);
659+
}
660+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuva_init_from_op);
661+
662+
struct drm_gpuvm_bo *rust_helper_drm_gpuvm_bo_get(struct drm_gpuvm_bo *vm_bo)
663+
{
664+
return drm_gpuvm_bo_get(vm_bo);
665+
}
666+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_bo_get);
667+
668+
bool rust_helper_drm_gpuvm_is_extobj(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj)
669+
{
670+
return drm_gpuvm_is_extobj(gpuvm, obj);
671+
}
672+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_is_extobj);
673+
674+
#endif
675+
641676
#endif
642677

643678
/*

rust/kernel/drm/drv.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub const FEAT_SYNCOBJ: u32 = bindings::drm_driver_feature_DRIVER_SYNCOBJ;
4040
/// Driver supports the timeline flavor of DRM sync objects for explicit synchronization of command
4141
/// submission.
4242
pub const FEAT_SYNCOBJ_TIMELINE: u32 = bindings::drm_driver_feature_DRIVER_SYNCOBJ_TIMELINE;
43+
/// Driver uses the GEM GPUVA manager.
44+
pub const FEAT_GEM_GPUVA: u32 = bindings::drm_driver_feature_DRIVER_GEM_GPUVA;
4345

4446
/// Information data for a DRM Driver.
4547
pub struct DriverInfo {

0 commit comments

Comments
 (0)