Skip to content

Commit e3012f8

Browse files
committed
rust: drm: Add GPUVM Manager abstraction
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent a487c7e commit e3012f8

6 files changed

Lines changed: 700 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>
@@ -65,3 +67,5 @@ const xa_mark_t BINDINGS_XA_MARK_2 = XA_MARK_2;
6567
const xa_mark_t BINDINGS_XA_PRESENT = XA_PRESENT;
6668
const xa_mark_t BINDINGS_XA_MARK_MAX = XA_MARK_MAX;
6769
const xa_mark_t BINDINGS_XA_FREE_MARK = XA_FREE_MARK;
70+
71+
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>
@@ -608,6 +609,40 @@ int rust_helper_drm_gem_shmem_object_mmap(struct drm_gem_object *obj, struct vm_
608609
EXPORT_SYMBOL_GPL(rust_helper_drm_gem_shmem_object_mmap);
609610

610611
#endif
612+
613+
#ifdef CONFIG_DRM_GPUVM
614+
struct drm_gpuvm *rust_helper_drm_gpuvm_get(struct drm_gpuvm *obj)
615+
{
616+
return drm_gpuvm_get(obj);
617+
}
618+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_get);
619+
620+
void rust_helper_drm_gpuvm_exec_unlock(struct drm_gpuvm_exec *vm_exec)
621+
{
622+
return drm_gpuvm_exec_unlock(vm_exec);
623+
}
624+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_exec_unlock);
625+
626+
void rust_helper_drm_gpuva_init_from_op(struct drm_gpuva *va, struct drm_gpuva_op_map *op)
627+
{
628+
drm_gpuva_init_from_op(va, op);
629+
}
630+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuva_init_from_op);
631+
632+
struct drm_gpuvm_bo *rust_helper_drm_gpuvm_bo_get(struct drm_gpuvm_bo *vm_bo)
633+
{
634+
return drm_gpuvm_bo_get(vm_bo);
635+
}
636+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_bo_get);
637+
638+
bool rust_helper_drm_gpuvm_is_extobj(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj)
639+
{
640+
return drm_gpuvm_is_extobj(gpuvm, obj);
641+
}
642+
EXPORT_SYMBOL_GPL(rust_helper_drm_gpuvm_is_extobj);
643+
644+
#endif
645+
611646
#endif
612647

613648
/*

rust/kernel/drm/drv.rs

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

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

0 commit comments

Comments
 (0)