Skip to content

Commit 59dbaf0

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

7 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/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
@@ -15,6 +15,7 @@
1515
#include "dma-fence.c"
1616
#include "dma-resv.c"
1717
#include "drm_gem.c"
18+
#include "drm_gpuvm.c"
1819
#include "drm_syncobj.c"
1920
#include "err.c"
2021
#include "iomem.c"

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)